862 B
862 B
71. Fix Null Pointer Exception on Failed Actions
1. 문제 (Problem)
BattleProvider에서 공격 실패(Miss) 또는 방어(Defend) 시_processAttackImpact를 직접 호출하고 있음._processAttackImpact는damageValue!와 같이 강제 언래핑을 수행하므로, 실패한 공격(damageValue가 null)일 경우 앱이 크래시됨(Unexpected null value).
2. 해결 방안 (Solution)
playerAction및_enemyTurn메서드에서_processAttackImpact직접 호출을 모두handleImpact(event)호출로 변경합니다.handleImpact메서드 내부에 있는if (!event.isSuccess!) return;안전 장치를 활용하여 크래시를 방지합니다.
3. 기대 효과 (Expected Outcome)
- 공격 실패 시에도 앱이 정상적으로 동작하며, 로그만 출력되고 데미지 로직은 스킵됨.