refactored a lot of js and added more battle page functionality