diff --git a/src/cards/schemas/cards.schema.ts b/src/cards/schemas/cards.schema.ts index 21b26a9..f27fe87 100644 --- a/src/cards/schemas/cards.schema.ts +++ b/src/cards/schemas/cards.schema.ts @@ -2,6 +2,7 @@ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; import { CardFaction, CardRole, CardType } from './cards.types'; import mongoose, { Types } from 'mongoose'; import { Effect } from './effect.schema'; +import { Game } from 'src/games/schemas/game.schema'; @Schema() export class Card extends Types.ObjectId { @@ -41,6 +42,10 @@ export class Card extends Types.ObjectId { @Prop() pack: string; + + isLocked(game: Game) { + return game.currentTurn.cardsLocked.some((c) => this.equals(c)); + } } export const CardSchema = SchemaFactory.createForClass(Card); diff --git a/src/games/services/turn.service.ts b/src/games/services/turn.service.ts index 652ff41..0849597 100644 --- a/src/games/services/turn.service.ts +++ b/src/games/services/turn.service.ts @@ -265,8 +265,9 @@ export class TurnService { target: Player, session?: mongoose.mongo.ClientSession, ) { + const unlockedCards = target.board.cards.filter((c) => !c.isLocked(game)); if ( - target.hand.cards.length >= + target.hand.cards.length + unlockedCards.length >= target.fuckUMarkers + target.discardMarkers ) { throw new HttpException(