Skip to content
Snippets Groups Projects

Development to testing

Merged Ghost User requested to merge Development into testing
1 file
+ 13
1
Compare changes
  • Side-by-side
  • Inline
+ 13
1
import { Injectable, Logger } from '@nestjs/common';
import { Injectable, Logger } from '@nestjs/common';
import { ScoreService } from '../score/score.service';
import { ScoreService } from '../score/score.service';
 
import { GameService } from './game.service';
@Injectable()
@Injectable()
export class TickService {
export class TickService {
constructor(private scoreService: ScoreService) {
constructor(
 
private scoreService: ScoreService,
 
private gameService: GameService,
 
) {
// whenever Tickservice is called, it will start ticktimer
// whenever Tickservice is called, it will start ticktimer
/*
/*
WARNING: multiple calls start multiple timers,
WARNING: multiple calls start multiple timers,
@@ -21,6 +25,14 @@ export class TickService {
@@ -21,6 +25,14 @@ export class TickService {
async startTimer() {
async startTimer() {
this.logger.log('Started timer');
this.logger.log('Started timer');
setInterval(this.Tick, this.tickInterval);
setInterval(this.Tick, this.tickInterval);
 
 
// get games with STARTED value
 
let games = await this.gameService.listGames('STARTED');
 
 
// add STARTED games to dictionary
 
games.map(game => {
 
this.ongoingGames[game.id] = Date.now();
 
});
}
}
// add the game to tick queue
// add the game to tick queue
Loading