Refactor player attack code