finish battle code