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
21cbd659
Commit
21cbd659
authored
5 years ago
by
L4168
Browse files
Options
Downloads
Patches
Plain Diff
added path&service for modifying gamestate
parent
cbcf068c
No related branches found
No related tags found
3 merge requests
!59
Development to master
,
!36
Development
,
!32
Game state
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/game/game.controller.ts
+10
-2
10 additions, 2 deletions
src/game/game.controller.ts
src/game/game.service.ts
+13
-1
13 additions, 1 deletion
src/game/game.service.ts
with
23 additions
and
3 deletions
src/game/game.controller.ts
+
10
−
2
View file @
21cbd659
...
@@ -14,9 +14,9 @@ import {
...
@@ -14,9 +14,9 @@ import {
import
{
GameService
}
from
'
./game.service
'
;
import
{
GameService
}
from
'
./game.service
'
;
import
{
AuthGuard
}
from
'
../shared/auth.guard
'
;
import
{
AuthGuard
}
from
'
../shared/auth.guard
'
;
import
{
User
}
from
'
../user/user.decorator
'
;
import
{
User
}
from
'
../user/user.decorator
'
;
import
{
GameDTO
,
FlagboxEventDTO
}
from
'
./game.dto
'
;
import
{
GameDTO
,
FlagboxEventDTO
,
GameStateDTO
}
from
'
./game.dto
'
;
import
{
ValidationPipe
}
from
'
../shared/validation.pipe
'
;
import
{
ValidationPipe
}
from
'
../shared/validation.pipe
'
;
import
{
Roles
}
from
'
../shared/
roles
.decorator
'
;
import
{
Roles
,
GameStates
}
from
'
../shared/
guard
.decorator
'
;
import
{
GameEntity
}
from
'
./game.entity
'
;
import
{
GameEntity
}
from
'
./game.entity
'
;
@
Controller
(
'
game
'
)
@
Controller
(
'
game
'
)
...
@@ -32,11 +32,19 @@ export class GameController {
...
@@ -32,11 +32,19 @@ export class GameController {
@
Put
(
'
edit/:id
'
)
@
Put
(
'
edit/:id
'
)
@
Roles
(
'
admin
'
)
@
Roles
(
'
admin
'
)
@
GameStates
(
'
CREATED
'
)
@
UsePipes
(
new
ValidationPipe
())
@
UsePipes
(
new
ValidationPipe
())
async
editGame
(@
Param
(
'
id
'
)
id
:
string
,
@
Body
()
body
:
GameDTO
)
{
async
editGame
(@
Param
(
'
id
'
)
id
:
string
,
@
Body
()
body
:
GameDTO
)
{
return
this
.
gameservice
.
editGame
(
id
,
body
);
return
this
.
gameservice
.
editGame
(
id
,
body
);
}
}
@
Put
(
'
edit-state/:id
'
)
@
Roles
(
'
admin
'
)
@
UsePipes
(
new
ValidationPipe
())
async
updateGameState
(@
Param
(
'
id
'
)
id
:
string
,
@
Body
()
body
:
GameStateDTO
)
{
return
this
.
gameservice
.
updateGameStatus
(
body
);
}
@
Get
(
'
listgames
'
)
@
Get
(
'
listgames
'
)
async
listGames
()
{
async
listGames
()
{
return
this
.
gameservice
.
listGames
();
return
this
.
gameservice
.
listGames
();
...
...
This diff is collapsed.
Click to expand it.
src/game/game.service.ts
+
13
−
1
View file @
21cbd659
...
@@ -8,7 +8,7 @@ import {
...
@@ -8,7 +8,7 @@ import {
ObjectivePointEntity
,
ObjectivePointEntity
,
ObjectivePoint_HistoryEntity
,
ObjectivePoint_HistoryEntity
,
}
from
'
./game.entity
'
;
}
from
'
./game.entity
'
;
import
{
GameDTO
,
FlagboxEventDTO
}
from
'
./game.dto
'
;
import
{
GameDTO
,
FlagboxEventDTO
,
GameStateDTO
}
from
'
./game.dto
'
;
import
{
PersonEntity
}
from
'
../user/user.entity
'
;
import
{
PersonEntity
}
from
'
../user/user.entity
'
;
import
{
FactionEntity
}
from
'
../faction/faction.entity
'
;
import
{
FactionEntity
}
from
'
../faction/faction.entity
'
;
import
{
NotificationGateway
}
from
'
../notifications/notifications.gateway
'
;
import
{
NotificationGateway
}
from
'
../notifications/notifications.gateway
'
;
...
@@ -39,6 +39,7 @@ export class GameService {
...
@@ -39,6 +39,7 @@ export class GameService {
}
}
// else add the game to the database
// else add the game to the database
const
game
=
await
this
.
gameRepository
.
create
(
gameData
);
const
game
=
await
this
.
gameRepository
.
create
(
gameData
);
game
.
state
=
'
CREATED
'
;
await
this
.
gameRepository
.
insert
(
game
);
await
this
.
gameRepository
.
insert
(
game
);
// add gamePerson with role admin to the game
// add gamePerson with role admin to the game
const
gamePerson
=
await
this
.
game_PersonRepository
.
create
({
const
gamePerson
=
await
this
.
game_PersonRepository
.
create
({
...
@@ -112,6 +113,17 @@ export class GameService {
...
@@ -112,6 +113,17 @@ export class GameService {
};
};
}
}
async
updateGameStatus
(
game
:
GameStateDTO
)
{
const
updatedGame
=
await
this
.
gameRepository
.
create
(
game
);
await
this
.
gameRepository
.
save
(
updatedGame
);
// notify players about game state change
this
.
notificationGateway
.
server
.
emit
(
game
.
id
,
'
event update
'
);
return
{
code
:
200
,
message
:
'
State was updated
'
,
};
}
async
listFactions
(
game
:
GameEntity
)
{
async
listFactions
(
game
:
GameEntity
)
{
return
this
.
factionRepository
.
find
({
game
});
return
this
.
factionRepository
.
find
({
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