pokemon-io-core 0.0.105 → 0.0.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -102,30 +102,58 @@ export const applyEffectsOnTarget = (state, actor, target, moveTypeId, isCritica
|
|
|
102
102
|
case "modify_stats": {
|
|
103
103
|
const { primary, isSelf } = resolveEffectTarget(eff, currentActor, currentTarget);
|
|
104
104
|
const newStages = { ...primary.statStages };
|
|
105
|
-
|
|
105
|
+
// We apply changes cumulatively but emit events SEPARATELY
|
|
106
|
+
// to ensure the frontend narrates and replays them sequentially.
|
|
106
107
|
if (eff.offenseDelta) {
|
|
108
|
+
const oldVal = newStages.offense;
|
|
107
109
|
newStages.offense = Math.max(-6, Math.min(6, newStages.offense + eff.offenseDelta));
|
|
108
|
-
|
|
110
|
+
const diff = newStages.offense - oldVal;
|
|
111
|
+
if (diff !== 0) {
|
|
112
|
+
events.push({
|
|
113
|
+
...createBaseEvent(state.turnNumber, "stats_changed", `Ataque cambiado`),
|
|
114
|
+
targetId: primary.fighterId,
|
|
115
|
+
changes: { offense: diff }
|
|
116
|
+
});
|
|
117
|
+
}
|
|
109
118
|
}
|
|
110
119
|
if (eff.defenseDelta) {
|
|
120
|
+
const oldVal = newStages.defense;
|
|
111
121
|
newStages.defense = Math.max(-6, Math.min(6, newStages.defense + eff.defenseDelta));
|
|
112
|
-
|
|
122
|
+
const diff = newStages.defense - oldVal;
|
|
123
|
+
if (diff !== 0) {
|
|
124
|
+
events.push({
|
|
125
|
+
...createBaseEvent(state.turnNumber, "stats_changed", `Defensa cambiada`),
|
|
126
|
+
targetId: primary.fighterId,
|
|
127
|
+
changes: { defense: diff }
|
|
128
|
+
});
|
|
129
|
+
}
|
|
113
130
|
}
|
|
114
131
|
if (eff.speedDelta) {
|
|
132
|
+
const oldVal = newStages.speed;
|
|
115
133
|
newStages.speed = Math.max(-6, Math.min(6, newStages.speed + eff.speedDelta));
|
|
116
|
-
|
|
134
|
+
const diff = newStages.speed - oldVal;
|
|
135
|
+
if (diff !== 0) {
|
|
136
|
+
events.push({
|
|
137
|
+
...createBaseEvent(state.turnNumber, "stats_changed", `Velocidad cambiada`),
|
|
138
|
+
targetId: primary.fighterId,
|
|
139
|
+
changes: { speed: diff }
|
|
140
|
+
});
|
|
141
|
+
}
|
|
117
142
|
}
|
|
118
143
|
if (eff.critDelta) {
|
|
144
|
+
const oldVal = newStages.crit;
|
|
119
145
|
newStages.crit = Math.max(0, Math.min(6, newStages.crit + eff.critDelta));
|
|
120
|
-
|
|
146
|
+
const diff = newStages.crit - oldVal;
|
|
147
|
+
if (diff !== 0) {
|
|
148
|
+
events.push({
|
|
149
|
+
...createBaseEvent(state.turnNumber, "stats_changed", `Crítico cambiado`),
|
|
150
|
+
targetId: primary.fighterId,
|
|
151
|
+
changes: { crit: diff }
|
|
152
|
+
});
|
|
153
|
+
}
|
|
121
154
|
}
|
|
122
155
|
let updated = { ...primary, statStages: newStages };
|
|
123
156
|
updated = recomputeEffectiveStatsForFighter(state, updated);
|
|
124
|
-
events.push({
|
|
125
|
-
...createBaseEvent(state.turnNumber, "stats_changed", `Estadísticas cambiadas`),
|
|
126
|
-
targetId: primary.fighterId,
|
|
127
|
-
changes
|
|
128
|
-
});
|
|
129
157
|
if (isSelf)
|
|
130
158
|
currentActor = updated;
|
|
131
159
|
else
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { applyStatusToFighter } from "../status/apply.js";
|
|
1
2
|
// Simple ID generator (no external dependency)
|
|
2
3
|
const generateId = () => `evt_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
3
4
|
/**
|
|
@@ -202,6 +203,14 @@ const applySingleEffectToFighter = (state, playerKey, fighter, effect) => {
|
|
|
202
203
|
timestamp: Date.now(),
|
|
203
204
|
});
|
|
204
205
|
break;
|
|
206
|
+
case "apply_status":
|
|
207
|
+
if (effect.statusId) {
|
|
208
|
+
// Cast state to RuntimeBattleState as required by status system
|
|
209
|
+
const result = applyStatusToFighter(state, updatedFighter, effect.statusId);
|
|
210
|
+
updatedFighter = result.updated;
|
|
211
|
+
events.push(...result.events);
|
|
212
|
+
}
|
|
213
|
+
break;
|
|
205
214
|
default:
|
|
206
215
|
break;
|
|
207
216
|
}
|