From a586e1d73ccdb7652078679752638669a7fc3f3f Mon Sep 17 00:00:00 2001 From: legonzaur Date: Sat, 21 Dec 2024 15:50:51 +0100 Subject: [PATCH] feat: reactivate basic effects on prepare Close #19 --- src/games/services/effect.functions.ts | 4 ++-- src/games/services/turn.service.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/games/services/effect.functions.ts b/src/games/services/effect.functions.ts index 83c2afb..d081897 100644 --- a/src/games/services/effect.functions.ts +++ b/src/games/services/effect.functions.ts @@ -179,7 +179,7 @@ export const tokenMappings = { [CardEffects.PREPARE]: async ( game: Document & Game, _effect: Effect, - _player: Player, + player: Player, card: Card, _gameService: GameService, turnService: TurnService, @@ -208,7 +208,7 @@ export const tokenMappings = { } for (const e of targetEffects) { - await turnService.unlockEffect(game, e, session); + await turnService.unlockEffect(game, player, e, card, session); } }, [CardEffects.STUN]: async ( diff --git a/src/games/services/turn.service.ts b/src/games/services/turn.service.ts index d161916..4ac4aa0 100644 --- a/src/games/services/turn.service.ts +++ b/src/games/services/turn.service.ts @@ -61,7 +61,9 @@ export class TurnService { @WithTransaction async unlockEffect( game: Document & Game, + player: Player, effect: Effect, + card: Card, session: mongoose.mongo.ClientSession, ) { const index = game.currentTurn.lockedEffects.findIndex((ee) => @@ -75,7 +77,13 @@ export class TurnService { }); for (const sub of effect.subEffects) { - await this.unlockEffect(game, sub, session); + await this.unlockEffect(game, player, sub, card, session); + } + + for (const e of [effect, ...effect.subEffects]) { + if (isAutoActivable(e)) { + await this.lockEffect(game, player, e, card, session); + } } await game.save({ session }); }