reworked battle code