add battle logic javascript