Chore : various fixes
This commit is contained in:
@@ -61,6 +61,12 @@ export class TurnController {
|
||||
HttpStatus.FORBIDDEN,
|
||||
);
|
||||
}
|
||||
if (currentPlayer.discardMarkers || currentPlayer.fuckUMarkers) {
|
||||
throw new HttpException(
|
||||
'You cannot lock a card while having discard markers',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
if (game.currentTurn.cardsLocked.some((c) => c._id.equals(card._id))) {
|
||||
throw new HttpException('Card already locked', HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
@@ -92,6 +98,12 @@ export class TurnController {
|
||||
HttpStatus.FORBIDDEN,
|
||||
);
|
||||
}
|
||||
if (currentPlayer.discardMarkers || currentPlayer.fuckUMarkers) {
|
||||
throw new HttpException(
|
||||
'You cannot buy a card while having discard markers',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
if (!game.market.cards.some((c) => c._id.equals(card._id))) {
|
||||
throw new HttpException(
|
||||
'Card not in current game market',
|
||||
@@ -126,6 +138,12 @@ export class TurnController {
|
||||
HttpStatus.FORBIDDEN,
|
||||
);
|
||||
}
|
||||
if (currentPlayer.discardMarkers || currentPlayer.fuckUMarkers) {
|
||||
throw new HttpException(
|
||||
'You cannot buy a card while having discard markers',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
if (game.fireGems.cards.length < 1) {
|
||||
throw new HttpException('No Gems left', HttpStatus.NOT_FOUND);
|
||||
}
|
||||
@@ -156,6 +174,12 @@ export class TurnController {
|
||||
HttpStatus.FORBIDDEN,
|
||||
);
|
||||
}
|
||||
if (currentPlayer.discardMarkers || currentPlayer.fuckUMarkers) {
|
||||
throw new HttpException(
|
||||
'You cannot lock an effect while having discard markers',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
if (game.currentTurn.lockedEffects.some((e) => e._id.equals(effect._id))) {
|
||||
throw new HttpException('Effect already locked', HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
@@ -206,6 +230,14 @@ export class TurnController {
|
||||
throw new HttpException('Token not found', HttpStatus.NOT_FOUND);
|
||||
}
|
||||
await this.turnService.makeDiscard(game, targetToken, targetPlayer);
|
||||
const index = game.currentTurn.tokens.findIndex((t) =>
|
||||
t._id.equals(targetToken._id),
|
||||
);
|
||||
game.currentTurn.tokens.splice(index, 1);
|
||||
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
|
||||
type: 'currentTurn.useToken',
|
||||
tokenId: targetToken._id.toHexString(),
|
||||
});
|
||||
}
|
||||
|
||||
@Post('useToken/:tokenId')
|
||||
@@ -227,6 +259,7 @@ export class TurnController {
|
||||
HttpStatus.FORBIDDEN,
|
||||
);
|
||||
}
|
||||
|
||||
if (!game.currentTurn.tokens.some((t) => t._id.equals(token._id))) {
|
||||
throw new HttpException('Token not found', HttpStatus.NOT_FOUND);
|
||||
}
|
||||
@@ -239,6 +272,7 @@ export class TurnController {
|
||||
const marketTokens = [
|
||||
CardEffects.STACK_NEXT_ACTION_BOUGHT,
|
||||
CardEffects.STACK_NEXT_CARD_BOUGHT,
|
||||
CardEffects.PLAY_NEXT_CARD_BOUGHT,
|
||||
];
|
||||
|
||||
let targetCard: Card;
|
||||
@@ -258,9 +292,18 @@ export class TurnController {
|
||||
);
|
||||
}
|
||||
|
||||
if (!targetCard) {
|
||||
throw new HttpException('Card not found', HttpStatus.NOT_FOUND);
|
||||
if (token.effect != CardEffects.DRAW_AND_DISCARD) {
|
||||
if (currentPlayer.discardMarkers || currentPlayer.fuckUMarkers) {
|
||||
throw new HttpException(
|
||||
'You cannot use a token while having discard markers',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
if (!targetCard) {
|
||||
throw new HttpException('Card not found', HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
await this.turnService.useToken(game, targetPlayer, token, targetCard);
|
||||
}
|
||||
|
||||
@@ -290,6 +333,12 @@ export class TurnController {
|
||||
}
|
||||
|
||||
const targetPlayer = findPlayer(playerId, game);
|
||||
if (targetPlayer.board.cards.some((c) => c.guard)) {
|
||||
throw new HttpException(
|
||||
'You cannot target this player while there is a guard',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
await this.turnService.damagePlayer(
|
||||
game,
|
||||
damagePlayerDTO.amount,
|
||||
@@ -339,6 +388,49 @@ export class TurnController {
|
||||
);
|
||||
}
|
||||
|
||||
if (!card.guard) {
|
||||
if (targetPlayer.board.cards.some((c) => c.guard)) {
|
||||
throw new HttpException(
|
||||
'You cannot target this champion while there is a guard',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
}
|
||||
await this.turnService.damageChampion(game, targetPlayer, card);
|
||||
}
|
||||
|
||||
@Post('discardCard/:cardId')
|
||||
@ApiOperation({
|
||||
summary: 'Discard a card if you have fuckU or discard markers',
|
||||
})
|
||||
@UseGuards(AuthGuard)
|
||||
async discardCard(
|
||||
@Param('gameId') _gameId: string,
|
||||
@Param('cardId') _cardId: string,
|
||||
@Param('gameId', GameStartedPipe) game: Document<Game> & Game,
|
||||
@Param('cardId', CardPipe) card: Document<Card> & Card,
|
||||
@Session() session: Record<string, string>,
|
||||
) {
|
||||
const currentPlayer = getPlayer(session, game);
|
||||
const currentTeam = getCurrentTeam(game);
|
||||
if (!isInTeam(currentTeam, currentPlayer)) {
|
||||
throw new HttpException(
|
||||
'It is not your turn to play',
|
||||
HttpStatus.FORBIDDEN,
|
||||
);
|
||||
}
|
||||
|
||||
if (currentPlayer.discardMarkers == 0 && currentPlayer.fuckUMarkers == 0) {
|
||||
throw new HttpException(
|
||||
'You do not have any discard or fuckU markers',
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
|
||||
if (!currentPlayer.board.cards.some((c) => c._id.equals(_cardId))) {
|
||||
throw new HttpException('Card not found in board', HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
await this.turnService.discardCard(game, currentPlayer, card);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user