fix : fuckU softlocks
release-tag / release-image (push) Failing after 6s

Attempt to fix #12
This commit is contained in:
2024-12-20 23:50:56 +01:00
parent ba5d56f7c1
commit ed49a5603e
3 changed files with 46 additions and 15 deletions
+1 -1
View File
@@ -237,7 +237,7 @@ export class TurnController {
if (!targetToken) {
throw new HttpException('Token not found', HttpStatus.NOT_FOUND);
}
await this.turnService.makeDiscard(game, targetToken, targetPlayer);
await this.turnService.addFuckUMarker(game, targetToken, targetPlayer);
const index = game.currentTurn.tokens.findIndex((t) =>
t._id.equals(targetToken._id),
);
+1 -7
View File
@@ -404,13 +404,7 @@ export const tokenMappings = {
);
}
await gameService.drawToBoard(1, player, game, session);
await player.discardMarkers++;
eventEmitter.emit('sse.game.' + game._id.toHexString(), {
type: 'player.addDiscardMarker',
operation: 1,
discardMarkers: player.discardMarkers,
playerId: player._id.toHexString(),
});
await turnService.addDiscardMarker(game, player, session);
game.currentTurn.drawAndDiscardCurrentAmount++;
game.currentTurn.drawAndDiscardCurrentEffect = effect;
},
+44 -7
View File
@@ -225,19 +225,22 @@ export class TurnService {
}
@WithTransaction
async makeDiscard(
async addFuckUMarker(
game: Document<Game> & Game,
token: Effect,
target: Player,
session?: mongoose.mongo.ClientSession,
) {
if (
target.hand.cards.length >=
target.fuckUMarkers + target.discardMarkers
) {
throw new HttpException(
"This player doesn't have enough cards in the hand",
HttpStatus.BAD_REQUEST,
);
}
target.fuckUMarkers++;
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
type: 'player.addFuckUMarker',
operation: 1,
fuckUMarkers: target.fuckUMarkers,
playerId: target._id.toHexString(),
});
const index = game.currentTurn.tokens.findIndex((t) =>
t._id.equals(token._id),
);
@@ -246,6 +249,40 @@ export class TurnService {
}
game.currentTurn.tokens.splice(index, 1);
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
type: 'player.addFuckUMarker',
operation: 1,
fuckUMarkers: target.fuckUMarkers,
playerId: target._id.toHexString(),
});
await game.save({ session });
}
@WithTransaction
async addDiscardMarker(
game: Document<Game> & Game,
target: Player,
session?: mongoose.mongo.ClientSession,
) {
if (
target.hand.cards.length >=
target.fuckUMarkers + target.discardMarkers
) {
throw new HttpException(
"This player doesn't have enough cards in the hand",
HttpStatus.BAD_REQUEST,
);
}
target.discardMarkers++;
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
type: 'player.addDiscardMarker',
operation: 1,
discardMarkers: target.discardMarkers,
playerId: target._id.toHexString(),
});
await game.save({ session });
}