update
This commit is contained in:
@@ -243,7 +243,7 @@ class BattleProvider with ChangeNotifier {
|
||||
|
||||
/// Handle player's action choice
|
||||
|
||||
void playerAction(ActionType type, RiskLevel risk) {
|
||||
Future<void> playerAction(ActionType type, RiskLevel risk) async {
|
||||
if (!isPlayerTurn || player.isDead || enemy.isDead || showRewardPopup)
|
||||
return;
|
||||
|
||||
@@ -303,8 +303,12 @@ class BattleProvider with ChangeNotifier {
|
||||
if (type == ActionType.attack) {
|
||||
int damage = (player.totalAtk * efficiency).toInt();
|
||||
|
||||
final eventId =
|
||||
DateTime.now().millisecondsSinceEpoch.toString() +
|
||||
Random().nextInt(1000).toString();
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
id: eventId,
|
||||
type: ActionType.attack,
|
||||
risk: risk,
|
||||
target: EffectTarget.enemy,
|
||||
@@ -312,6 +316,15 @@ class BattleProvider with ChangeNotifier {
|
||||
),
|
||||
);
|
||||
|
||||
// Animation Delays to sync with Impact
|
||||
if (risk == RiskLevel.safe) {
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
} else if (risk == RiskLevel.normal) {
|
||||
await Future.delayed(const Duration(milliseconds: 400));
|
||||
} else if (risk == RiskLevel.risky) {
|
||||
await Future.delayed(const Duration(milliseconds: 1100));
|
||||
}
|
||||
|
||||
int damageToHp = 0;
|
||||
if (enemy.armor > 0) {
|
||||
if (enemy.armor >= damage) {
|
||||
@@ -339,6 +352,9 @@ class BattleProvider with ChangeNotifier {
|
||||
} else {
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
id:
|
||||
DateTime.now().millisecondsSinceEpoch.toString() +
|
||||
Random().nextInt(1000).toString(),
|
||||
type: ActionType.defend,
|
||||
risk: risk,
|
||||
target: EffectTarget.player,
|
||||
@@ -355,6 +371,9 @@ class BattleProvider with ChangeNotifier {
|
||||
_addLog("Player's attack missed!");
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
id:
|
||||
DateTime.now().millisecondsSinceEpoch.toString() +
|
||||
Random().nextInt(1000).toString(),
|
||||
type: type,
|
||||
risk: risk,
|
||||
target: EffectTarget.enemy, // 공격 실패는 적 위치에 MISS
|
||||
@@ -365,6 +384,9 @@ class BattleProvider with ChangeNotifier {
|
||||
_addLog("Player's defense failed!");
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
id:
|
||||
DateTime.now().millisecondsSinceEpoch.toString() +
|
||||
Random().nextInt(1000).toString(),
|
||||
type: type,
|
||||
risk: risk,
|
||||
target: EffectTarget.player, // 방어 실패는 내 위치에 FAILED
|
||||
@@ -429,6 +451,9 @@ class BattleProvider with ChangeNotifier {
|
||||
if (intent.isSuccess) {
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
id:
|
||||
DateTime.now().millisecondsSinceEpoch.toString() +
|
||||
Random().nextInt(1000).toString(),
|
||||
type: ActionType.attack,
|
||||
risk: intent.risk,
|
||||
target: EffectTarget.player,
|
||||
@@ -465,6 +490,9 @@ class BattleProvider with ChangeNotifier {
|
||||
_addLog("Enemy's ${intent.risk.name} attack missed!");
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
id:
|
||||
DateTime.now().millisecondsSinceEpoch.toString() +
|
||||
Random().nextInt(1000).toString(),
|
||||
type: ActionType.attack, // 적의 공격이므로 ActionType.attack
|
||||
risk: intent.risk,
|
||||
target: EffectTarget.player, // 플레이어가 회피했으므로 플레이어 위치에 이펙트
|
||||
@@ -777,6 +805,9 @@ class BattleProvider with ChangeNotifier {
|
||||
_addLog("Enemy prepares defense! (+$armor Armor)");
|
||||
_effectEventController.sink.add(
|
||||
EffectEvent(
|
||||
id:
|
||||
DateTime.now().millisecondsSinceEpoch.toString() +
|
||||
Random().nextInt(1000).toString(),
|
||||
type: ActionType.defend,
|
||||
risk: risk,
|
||||
target: EffectTarget.enemy,
|
||||
|
||||
Reference in New Issue
Block a user