Skip to content

Commit

Permalink
fix(combat): combat ends correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 31, 2023
1 parent 0846bb2 commit 983e075
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions server/src/modules/fight/fight.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class FightService {

public async removeFight(fightId: string) {
const fight = await this.fights.findOne({ _id: new ObjectId(fightId) });
if (!fight) throw new BadRequestException('Fight not found');
if (!fight) return;

return this.em.remove<Fight>(fight);
}
Expand Down Expand Up @@ -375,10 +375,6 @@ export class FightService {
}

async setNextTurn(fight: Fight): Promise<void> {
if (isFightOver(fight)) {
return this.startEndFightSequence(fight);
}

const currentTurnIndex = fight.turnOrder.findIndex(
(turn) => turn === fight.currentTurn,
);
Expand Down Expand Up @@ -460,10 +456,7 @@ export class FightService {

await this.processActionIntoAbility(fight, character, action, targetParams);

// in case the fight ends during the action (flee)
if (!isFightOver(fight)) {
await this.setAndTakeNextTurn(fight);
}
await this.setAndTakeNextTurn(fight);
}

async processActionIntoAbility(
Expand Down

0 comments on commit 983e075

Please sign in to comment.