Chore : various fixes
This commit is contained in:
@@ -232,6 +232,12 @@ export class TurnService {
|
||||
session?: mongoose.mongo.ClientSession,
|
||||
) {
|
||||
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),
|
||||
);
|
||||
@@ -265,14 +271,21 @@ export class TurnService {
|
||||
this.eventEmitter,
|
||||
session,
|
||||
);
|
||||
const index = game.currentTurn.tokens.findIndex((t) =>
|
||||
t._id.equals(token._id),
|
||||
);
|
||||
game.currentTurn.tokens.splice(index, 1);
|
||||
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
|
||||
type: 'currentTurn.useToken',
|
||||
tokenId: token._id.toHexString(),
|
||||
});
|
||||
if (
|
||||
token.effect != CardEffects.DRAW_AND_DISCARD ||
|
||||
(token.effect == CardEffects.DRAW_AND_DISCARD &&
|
||||
token.times >= game.currentTurn.drawAndDiscardCurrentAmount)
|
||||
) {
|
||||
const index = game.currentTurn.tokens.findIndex((t) =>
|
||||
t._id.equals(token._id),
|
||||
);
|
||||
game.currentTurn.tokens.splice(index, 1);
|
||||
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
|
||||
type: 'currentTurn.useToken',
|
||||
tokenId: token._id.toHexString(),
|
||||
});
|
||||
}
|
||||
|
||||
await game.save({ session });
|
||||
}
|
||||
|
||||
@@ -333,4 +346,52 @@ export class TurnService {
|
||||
|
||||
await game.save({ session });
|
||||
}
|
||||
|
||||
@WithTransaction
|
||||
async discardCard(
|
||||
game: Document<Game> & Game,
|
||||
player: Player,
|
||||
card: Card,
|
||||
session?: mongoose.mongo.ClientSession,
|
||||
) {
|
||||
await this.gamesService.distributeCards(
|
||||
[card],
|
||||
player.board,
|
||||
player.discard,
|
||||
game,
|
||||
);
|
||||
if (player.discardMarkers > 0) {
|
||||
player.discardMarkers--;
|
||||
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
|
||||
type: 'player.removeDiscardMarker',
|
||||
operation: -1,
|
||||
discardMarkers: player.discardMarkers,
|
||||
playerId: player._id.toHexString(),
|
||||
});
|
||||
} else if (player.fuckUMarkers > 0) {
|
||||
player.fuckUMarkers--;
|
||||
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
|
||||
type: 'player.removeFuckUMarker',
|
||||
operation: -1,
|
||||
fuckUMarkers: player.fuckUMarkers,
|
||||
playerId: player._id.toHexString(),
|
||||
});
|
||||
}
|
||||
|
||||
game.currentTurn.drawAndDiscardCurrentAmount = 0;
|
||||
game.currentTurn.drawAndDiscardCurrentEffect = null;
|
||||
// if (token) {
|
||||
// const index = game.currentTurn.tokens.findIndex((t) =>
|
||||
// t._id.equals(token._id),
|
||||
// );
|
||||
// game.currentTurn.tokens.splice(index, 1);
|
||||
// this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
|
||||
// type: 'currentTurn.useToken',
|
||||
// tokenId: token._id.toHexString(),
|
||||
// });
|
||||
// game.currentTurn.drawAndDiscardCurrentEffect = null;
|
||||
// }
|
||||
|
||||
await game.save({ session });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user