Skip to content

Commit 37bbc59

Browse files
authored
Merge pull request #50 from Valforte/main
deploy
2 parents af7eb44 + b3d43e2 commit 37bbc59

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/InitiativeManager.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,14 @@ function addCombatant(name: string, HP: number, initiative: number, visibility:
314314
}
315315
316316
function removeCombatant(index: number): void {
317-
combatants.value.splice(index, 1)
317+
// The index comes from orderedCombatants (sorted array),
318+
// but we need to remove from the unsorted combatants array
319+
const combatantToRemove = orderedCombatants.value[index]
320+
const actualIndex = combatants.value.findIndex((c: Combatant) => c === combatantToRemove)
321+
322+
if (actualIndex === -1) return // Safety check
323+
324+
combatants.value.splice(actualIndex, 1)
318325
if (index < turn.value) {
319326
turn.value -= 1
320327
} else if (index == combatants.value.length) {

0 commit comments

Comments
 (0)