debuged battle loop