Related to heronfief/front#71
This commit is contained in:
@@ -288,7 +288,7 @@ export class GameService {
|
|||||||
});
|
});
|
||||||
await game.save({ session });
|
await game.save({ session });
|
||||||
if (game.teams.length <= 1) {
|
if (game.teams.length <= 1) {
|
||||||
await this.endGame(game, session);
|
await this.endGame(game, game.teams[0], session);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -359,10 +359,12 @@ export class GameService {
|
|||||||
@WithTransaction
|
@WithTransaction
|
||||||
async endGame(
|
async endGame(
|
||||||
game: Document<Game> & Game,
|
game: Document<Game> & Game,
|
||||||
|
winner: Team,
|
||||||
session?: mongoose.mongo.ClientSession,
|
session?: mongoose.mongo.ClientSession,
|
||||||
) {
|
) {
|
||||||
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
|
this.eventEmitter.emit('sse.game.' + game._id.toHexString(), {
|
||||||
type: 'endGame',
|
type: 'endGame',
|
||||||
|
winner: winner._id.toHexString(),
|
||||||
});
|
});
|
||||||
await game.deleteOne({ session });
|
await game.deleteOne({ session });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user