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
Commits
65a0e7c7
Commit
65a0e7c7
authored
5 years ago
by
Samuli Virtapohja
Browse files
Options
Downloads
Patches
Plain Diff
ticking works
parent
f647667e
No related branches found
No related tags found
3 merge requests
!59
Development to master
,
!54
Development to testing
,
!51
Scoretick
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/game/game.service.ts
+1
-2
1 addition, 2 deletions
src/game/game.service.ts
src/main.ts
+1
-1
1 addition, 1 deletion
src/main.ts
src/score/score.service.ts
+39
-8
39 additions, 8 deletions
src/score/score.service.ts
with
41 additions
and
11 deletions
src/game/game.service.ts
+
1
−
2
View file @
65a0e7c7
import
{
Injectable
,
HttpException
,
HttpStatus
}
from
'
@nestjs/common
'
;
import
{
Injectable
,
HttpException
,
HttpStatus
,
Inject
}
from
'
@nestjs/common
'
;
import
{
InjectRepository
}
from
'
@nestjs/typeorm
'
;
import
{
InjectRepository
}
from
'
@nestjs/typeorm
'
;
import
{
Repository
,
Not
}
from
'
typeorm
'
;
import
{
Repository
,
Not
}
from
'
typeorm
'
;
...
@@ -30,7 +30,6 @@ export class GameService {
...
@@ -30,7 +30,6 @@ export class GameService {
>
,
>
,
private
notificationGateway
:
NotificationGateway
,
private
notificationGateway
:
NotificationGateway
,
)
{}
)
{}
// create a new game
// create a new game
async
createNewGame
(
personId
:
PersonEntity
,
gameData
:
GameDTO
)
{
async
createNewGame
(
personId
:
PersonEntity
,
gameData
:
GameDTO
)
{
// checks if a game with the same name exists already
// checks if a game with the same name exists already
...
...
This diff is collapsed.
Click to expand it.
src/main.ts
+
1
−
1
View file @
65a0e7c7
...
@@ -7,7 +7,7 @@ import { AppModule } from './app.module';
...
@@ -7,7 +7,7 @@ import { AppModule } from './app.module';
*/
*/
async
function
bootstrap
()
{
async
function
bootstrap
()
{
const
app
=
await
NestFactory
.
create
(
AppModule
);
const
app
=
await
NestFactory
.
create
(
AppModule
,
{
logger
:
console
}
);
// Cors is needed for application/json POST
// Cors is needed for application/json POST
app
.
enableCors
();
app
.
enableCors
();
await
app
.
listen
(
5000
);
await
app
.
listen
(
5000
);
...
...
This diff is collapsed.
Click to expand it.
src/score/score.service.ts
+
39
−
8
View file @
65a0e7c7
import
{
Injectable
,
HttpException
,
HttpStatus
}
from
'
@nestjs/common
'
;
import
{
Injectable
,
HttpException
,
HttpStatus
,
Logger
,
OnModuleInit
,
}
from
'
@nestjs/common
'
;
import
{
InjectRepository
}
from
'
@nestjs/typeorm
'
;
import
{
InjectRepository
}
from
'
@nestjs/typeorm
'
;
import
{
Repository
}
from
'
typeorm
'
;
import
{
Repository
}
from
'
typeorm
'
;
...
@@ -24,7 +30,10 @@ export class ScoreService {
...
@@ -24,7 +30,10 @@ export class ScoreService {
@
InjectRepository
(
FactionEntity
)
@
InjectRepository
(
FactionEntity
)
private
factionRepository
:
Repository
<
FactionEntity
>
,
private
factionRepository
:
Repository
<
FactionEntity
>
,
private
notificationGateway
:
NotificationGateway
,
private
notificationGateway
:
NotificationGateway
,
)
{}
)
{
// initialize timer when service is loaded
this
.
startTimer
();
}
async
addScore
(
scoreData
:
ScoreDTO
,
gameId
:
GameEntity
)
{
async
addScore
(
scoreData
:
ScoreDTO
,
gameId
:
GameEntity
)
{
// check if faction exists
// check if faction exists
...
@@ -110,10 +119,32 @@ export class ScoreService {
...
@@ -110,10 +119,32 @@ export class ScoreService {
);
);
return
scores
;
return
scores
;
}
}
}
//
// Hae kaikki Objective pointit
// tickinterval in milliseconds (10 minutes = 600 000)
// aja map funktio pelin objective pointteihin
private
readonly
tickInterval
:
number
=
5000
;
// jokaisella objective point ID:llä hae historystä
// dictionary to push gameId linked to start state
// relaatio, missä uusin timestamp
private
ongoingGames
=
{};
// katso uusimmista history entrystä omistaja
// initializing timer
async
startTimer
()
{
setInterval
(
this
.
Tick
,
this
.
tickInterval
);
}
async
addToTimer
(
gameId
:
string
)
{
this
.
Tick
();
this
.
ongoingGames
[
gameId
]
=
Date
.
now
();
}
async
removeFromTimer
(
gameId
:
string
)
{
delete
this
.
ongoingGames
[
gameId
];
}
// tick score for games with STARTED-status
Tick
=
()
=>
{
if
(
this
.
ongoingGames
!=
null
)
{
for
(
var
game
in
this
.
ongoingGames
)
{
console
.
log
(
game
);
}
}
};
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment