Fix: Sync Enemy Attack Animation with Damage Calculation
This commit is contained in:
parent
e6facc41f8
commit
1720725826
|
|
@ -489,6 +489,14 @@ class BattleProvider with ChangeNotifier {
|
|||
),
|
||||
);
|
||||
|
||||
// Fix: Wait for animation to play before applying damage
|
||||
// Determine delay based on risk level
|
||||
int delay = GameConfig.animDelayNormal;
|
||||
if (intent.risk == RiskLevel.safe) delay = GameConfig.animDelaySafe;
|
||||
if (intent.risk == RiskLevel.risky) delay = GameConfig.animDelayRisky;
|
||||
|
||||
await Future.delayed(Duration(milliseconds: delay));
|
||||
|
||||
int incomingDamage = intent.finalValue;
|
||||
|
||||
// Calculate Damage using Calculator
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
# 64. Fix Enemy Animation Sync
|
||||
|
||||
## 1. 목표 (Goal)
|
||||
- 적 공격 시, 애니메이션이 끝나기 전에 데미지가 먼저 들어가는 동기화 문제를 해결합니다.
|
||||
|
||||
## 2. 원인 (Cause)
|
||||
- `BattleProvider`의 `_enemyTurn` 메서드에서 `EffectEvent`를 보낸 후, 애니메이션 재생 시간만큼 기다리지 않고 즉시 데미지 로직을 수행하고 있습니다.
|
||||
|
||||
## 3. 해결 방안 (Solution)
|
||||
- `_enemyTurn` 메서드 내에서 공격 성공 시, `EffectEvent`를 전송한 직후에 `Future.delayed`를 추가하여 애니메이션이 재생될 시간을 확보합니다.
|
||||
- 대기 시간은 `GameConfig`에 정의된 `animDelaySafe`, `animDelayNormal`, `animDelayRisky` 상수를 사용합니다.
|
||||
|
||||
## 4. 기대 효과 (Expected Outcome)
|
||||
- 적이 플레이어에게 돌진하여 타격하는 시점에 정확히 데미지 텍스트가 뜨고 HP가 감소합니다.
|
||||
Loading…
Reference in New Issue