Skip to content

Commit 1568202

Browse files
committed
fix: 🐛 out of bounds when duplicating more than 10 combatants for one token
1 parent b65e8d2 commit 1568202

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/combat/combatant.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,10 @@ export default class YearZeroCombatant extends Combatant {
230230

231231
/* ------------------------------------------ */
232232
#getSingleActionStatus(combatant) {
233-
const as = combatant.combat.turns.filter(t => t.tokenId === combatant.tokenId);
234-
for (let i = 0; i < as.length && i < YZEC.StatusEffects.singleAction.length; i++) {
233+
const as = combatant.combat.turns
234+
.filter(t => t.tokenId === combatant.tokenId)
235+
.slice(0, YZEC.StatusEffects.singleAction.length);
236+
for (let i = 0; i < as.length; i++) {
235237
as[i] = {
236238
id: as[i].id,
237239
action: as[i].token.hasStatusEffect(YZEC.StatusEffects.singleAction[i].id),
@@ -244,6 +246,7 @@ export default class YearZeroCombatant extends Combatant {
244246
const post = this.#getSingleActionStatus(combatant);
245247
for (let i = 0; i < post.length; i++) {
246248
const preIndex = preCombatantActions.findIndex(e => e.id === post[i].id);
249+
if (preIndex < 0) continue;
247250
const preAction = preCombatantActions[preIndex].action;
248251
const postAction = post[i].action;
249252
if (preAction != postAction) {

0 commit comments

Comments
 (0)