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 }); }