Fix : various inconsistencies for effects
This commit is contained in:
@@ -192,7 +192,7 @@ export class TurnController {
|
||||
}
|
||||
|
||||
const targetPlayer = findPlayer(_playerId, game);
|
||||
if (!isInTeam(currentTeam, targetPlayer)) {
|
||||
if (isInTeam(currentTeam, targetPlayer)) {
|
||||
throw new HttpException(
|
||||
'You cannot target players in the same team as yours',
|
||||
HttpStatus.FORBIDDEN,
|
||||
@@ -324,7 +324,7 @@ export class TurnController {
|
||||
);
|
||||
}
|
||||
|
||||
const targetPlayer = findPlayer(damageChampion.player, game);
|
||||
const targetPlayer = findPlayer(damageChampion.playerId, game);
|
||||
if (!targetPlayer) {
|
||||
throw new HttpException('Player not found', HttpStatus.NOT_FOUND);
|
||||
}
|
||||
@@ -338,5 +338,7 @@ export class TurnController {
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
await this.turnService.damageChampion(game, targetPlayer, card);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class DamageChampionDTO {
|
||||
@ApiProperty()
|
||||
player: string;
|
||||
playerId: string;
|
||||
}
|
||||
|
||||
@@ -307,4 +307,30 @@ export class TurnService {
|
||||
|
||||
await game.save({ session });
|
||||
}
|
||||
|
||||
@WithTransaction
|
||||
async damageChampion(
|
||||
game: Document<Game> & Game,
|
||||
targetPlayer: Player,
|
||||
targetCard: Card,
|
||||
session?: mongoose.mongo.ClientSession,
|
||||
) {
|
||||
game.currentTurn.damage -= targetCard.defense;
|
||||
|
||||
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
|
||||
type: 'currentTurn.updateDamage',
|
||||
damage: game.currentTurn.damage,
|
||||
operation: -targetCard.defense,
|
||||
});
|
||||
|
||||
await this.gamesService.distributeCards(
|
||||
[targetCard],
|
||||
targetPlayer.board,
|
||||
targetPlayer.discard,
|
||||
game,
|
||||
session,
|
||||
);
|
||||
|
||||
await game.save({ session });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user