End of refactoring battle.js