Skip to content

Commit

Permalink
fix(games): fix game references
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc committed Aug 3, 2021
1 parent e4c1121 commit 334c249
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/games/services/game-event-handler.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Events } from '@/events/events';
import { SlotStatus } from '../models/slot-status';
import { GameState } from '../models/game-state';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { Model, Types } from 'mongoose';
import { Tf2ClassName } from '@/shared/models/tf2-class-name';

@Injectable()
Expand All @@ -24,7 +24,7 @@ export class GameEventHandlerService {

async onMatchStarted(gameId: string) {
const game = await this.gameModel.findOneAndUpdate(
{ _id: gameId, state: GameState.launching },
{ _id: new Types.ObjectId(gameId), state: GameState.launching },
{ state: GameState.started },
{ new: true },
);
Expand All @@ -37,7 +37,7 @@ export class GameEventHandlerService {

async onMatchEnded(gameId: string) {
const game = await this.gameModel.findOneAndUpdate(
{ _id: gameId, state: GameState.started },
{ _id: new Types.ObjectId(gameId), state: GameState.started },
{
state: GameState.ended,
'slots.$[element].status': `${SlotStatus.active}`,
Expand Down Expand Up @@ -70,7 +70,7 @@ export class GameEventHandlerService {

async onLogsUploaded(gameId: string, logsUrl: string) {
const game = await this.gameModel.findOneAndUpdate(
{ _id: gameId },
{ _id: new Types.ObjectId(gameId) },
{ logsUrl },
{ new: true },
);
Expand Down Expand Up @@ -125,7 +125,7 @@ export class GameEventHandlerService {
async onScoreReported(gameId: string, teamName: string, score: string) {
const fixedTeamName = teamName.toLowerCase().substring(0, 3); // converts Red to 'red' and Blue to 'blu'
const game = await this.gameModel.findOneAndUpdate(
{ _id: gameId },
{ _id: new Types.ObjectId(gameId) },
{ [`score.${fixedTeamName}`]: parseInt(score, 10) },
{ new: true },
);
Expand Down

0 comments on commit 334c249

Please sign in to comment.