This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user