From 9b83bc5a9939403caf70259759e8f144bd2e7ae7 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Fri, 2 Aug 2024 08:52:23 +0200 Subject: [PATCH] Fix : rampage --- src/games/services/turn.service.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/games/services/turn.service.ts b/src/games/services/turn.service.ts index c217457..52ce093 100644 --- a/src/games/services/turn.service.ts +++ b/src/games/services/turn.service.ts @@ -377,18 +377,17 @@ export class TurnService { } game.currentTurn.drawAndDiscardCurrentAmount = 0; - game.currentTurn.drawAndDiscardCurrentEffect = null; - // if (token) { - // const index = game.currentTurn.tokens.findIndex((t) => - // t._id.equals(token._id), - // ); - // game.currentTurn.tokens.splice(index, 1); - // this.eventEmitter.emit('sse.game.' + game._id.toHexString(), { - // type: 'currentTurn.useToken', - // tokenId: token._id.toHexString(), - // }); - // game.currentTurn.drawAndDiscardCurrentEffect = null; - // } + if (game.currentTurn.drawAndDiscardCurrentEffect) { + const tokenIndex = game.currentTurn.tokens.findIndex((t) => + t._id.equals(game.currentTurn.drawAndDiscardCurrentEffect._id), + ); + game.currentTurn.tokens.splice(tokenIndex, 1); + this.eventEmitter.emit('sse.game.' + game._id.toHexString(), { + type: 'currentTurn.useToken', + tokenId: game.currentTurn.drawAndDiscardCurrentEffect._id.toHexString(), + }); + game.currentTurn.drawAndDiscardCurrentEffect = null; + } await game.save({ session }); }