game/prompt/71_fix_null_error.md

13 lines
862 B
Markdown

# 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)
- 공격 실패 시에도 앱이 정상적으로 동작하며, 로그만 출력되고 데미지 로직은 스킵됨.