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
02eeccde
Commit
02eeccde
authored
5 years ago
by
Ronnie Friman
Browse files
Options
Downloads
Patches
Plain Diff
service returns flagbox-events
parent
bbcce13a
No related branches found
Branches containing commit
No related tags found
3 merge requests
!59
Development to master
,
!58
Development to testing
,
!55
Flagbox replay
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/game/game.service.ts
+59
-5
59 additions, 5 deletions
src/game/game.service.ts
with
59 additions
and
5 deletions
src/game/game.service.ts
+
59
−
5
View file @
02eeccde
...
...
@@ -83,6 +83,14 @@ export class GameService {
HttpStatus
.
BAD_REQUEST
,
);
}
// check that there's location data for each added objective point
gameData
.
objective_points
.
forEach
(
obj
=>
{
if
(
!
obj
[
'
data
'
])
throw
new
HttpException
(
'
Objective Point error. Add location for each Objective Point.
'
,
HttpStatus
.
BAD_REQUEST
,
);
});
// get factions that have been added previously
let
factions
=
await
this
.
factionRepository
.
find
({
game
:
id
});
...
...
@@ -121,8 +129,10 @@ export class GameService {
({
objectivePointId
})
=>
objectivePointId
,
);
flagboxes
.
map
(
async
flagbox
=>
{
if
(
!
flagboxIds
.
includes
(
flagbox
.
objectivePointDescription
))
{
await
this
.
objectivePointRepository
.
delete
(
flagbox
);
if
(
!
flagboxIds
.
includes
(
flagbox
.
objectivePointId
))
{
await
this
.
objectivePointRepository
.
delete
({
objectivePointId
:
flagbox
.
objectivePointId
,
});
}
});
gameData
.
objective_points
.
map
(
async
flagbox
=>
{
...
...
@@ -136,8 +146,6 @@ export class GameService {
await
this
.
objectivePointRepository
.
delete
({
game
:
id
});
}
// TO DO: ADD FLAGBOX LOCATION TO MAPDRAWING ENTITY
return
{
message
:
'
Game updated
'
,
};
...
...
@@ -209,7 +217,7 @@ export class GameService {
}
// returns information about a game identified by id
async
returnGameInfo
(
id
:
string
)
{
async
returnGameInfo
(
id
)
{
const
game
=
await
this
.
gameRepository
.
findOne
({
where
:
{
id
:
id
},
relations
:
[
'
factions
'
,
'
objective_points
'
],
...
...
@@ -221,6 +229,52 @@ export class GameService {
return
game
;
}
// returns information about game's flagboxes and their most recent event
async
returnObjectivePointInfo
(
gameId
)
{
const
info
=
await
this
.
objectivePointRepository
.
find
({
where
:
{
game
:
gameId
},
relations
:
[
'
history
'
,
'
history.owner
'
,
'
history.capture
'
],
});
let
response
=
await
Promise
.
all
(
info
.
map
(
async
obj
=>
{
let
history
=
obj
.
history
.
pop
();
return
await
{
objectivePointId
:
obj
.
objectivePointId
,
objectivePointDescription
:
obj
.
objectivePointDescription
,
objectivePointMultiplier
:
obj
.
objectivePointMultiplier
,
action
:
{
status
:
history
.
action
,
message
:
{
0
:
'
No capture ongoing
'
,
1
:
`Captured by
${
history
.
owner
?
history
.
owner
.
factionName
:
'
neutral
'
}
`
,
2
:
`Being captured by
${
history
.
capture
?
history
.
capture
.
factionName
:
'
neutral
'
}
`
,
}[
history
.
action
],
},
owner
:
await
this
.
infoHelper
(
history
.
owner
),
capture
:
await
this
.
infoHelper
(
history
.
capture
),
data
:
obj
.
data
,
};
}),
);
return
response
;
}
private
async
infoHelper
(
obj
)
{
return
(
await
obj
)
?
{
factionName
:
obj
.
factionName
,
colour
:
obj
.
colour
,
}
:
{
factionName
:
'
neutral
'
,
colour
:
'
#000000
'
,
};
}
// returns flagbox settings
async
flagboxQuery
(
gameId
)
{
const
game
=
await
this
.
gameRepository
.
findOne
({
id
:
gameId
});
...
...
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