Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ehasa-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WIMMA Lab 2019
Overflow
ehasa-backend
Merge requests
!58
Development to testing
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Development to testing
Development
into
testing
Overview
0
Commits
50
Pipelines
0
Changes
1
Merged
Ghost User
requested to merge
Development
into
testing
5 years ago
Overview
0
Commits
50
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
7cfed59c
Prev
Next
Show latest version
1 file
+
13
−
1
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
7cfed59c
add games with started state to ticks
· 7cfed59c
Samuli Virtapohja
authored
5 years ago
src/game/tick.service.ts
+
13
−
1
Options
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