Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ehasa-mobile
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-mobile
Commits
911ff8fe
Commit
911ff8fe
authored
5 years ago
by
Taneli Riihimäki
Browse files
Options
Downloads
Patches
Plain Diff
Continue working on getting the factions and joining into them
parent
7e8674af
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/GameList.js
+38
-24
38 additions, 24 deletions
components/GameList.js
with
38 additions
and
24 deletions
components/GameList.js
+
38
−
24
View file @
911ff8fe
...
@@ -42,40 +42,53 @@ class GameList extends Component {
...
@@ -42,40 +42,53 @@ class GameList extends Component {
console
.
log
(
error
);
console
.
log
(
error
);
});
});
}
}
// Get all the factions from the server
getFactions
()
{
getFactions
()
{
fetch
(
`https://tacs-testing.cf:8443/game/
${
this
.
state
.
selectedGame
.
id
}
`
),
fetch
(
`https://tacs-testing.cf:8443/game/
${
this
.
state
.
selectedGame
.
id
}
`
,
{
{
method
:
"
GET
"
,
method
:
"
GET
"
,
headers
:
{
headers
:
{
Accept
:
"
application/json
"
,
Accept
:
"
application/json
"
,
"
Content-Type
"
:
"
application/json
"
"
Content-Type
"
:
"
application/json
"
}
}
}
.
then
(
response
=>
response
.
json
())
})
.
then
(
factions
=>
{
.
then
(
response
=>
response
.
json
())
console
.
log
(
factions
);
.
then
(
factions
=>
{
// this.setState({
console
.
log
(
factions
);
// factions,
this
.
setState
({
// selectedFaction: factions[0]
factions
:
factions
.
factions
,
// });
selectedFaction
:
factions
[
0
]
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
});
})
.
catch
(
error
=>
{
console
.
log
(
error
);
});
}
}
joinFaction
()
{}
joinFaction
()
{}
// Toggles the tracking boolean
// Toggles the tracking boolean
(some thought mistake somewhere makes this kinda weird ¯\_(ツ)_/¯ )
handleTrackingChange
()
{
handleTrackingChange
()
{
this
.
setState
({
tracking
:
!
this
.
state
.
tracking
});
this
.
setState
({
tracking
:
!
this
.
state
.
tracking
});
if
(
!
this
.
state
.
tracking
)
{
this
.
startTracking
();
}
else
if
(
this
.
state
.
tracking
)
{
this
.
stopTracking
();
}
}
}
// Start the player tracking with the wanted interval (ms)
// Start the player tracking with the wanted interval (ms)
startTracking
()
{
startTracking
()
{
let
interval
=
3000
;
this
.
getCurrentLocation
();
let
interval
=
10000
;
this
.
intervalID
=
setInterval
(()
=>
{
this
.
intervalID
=
setInterval
(()
=>
{
console
.
log
(
console
.
log
(
"
Nyt träkätää nim birusti peliä:
"
+
this
.
state
.
selectedGame
.
name
"
Nyt träkätää nim birusti peliä:
"
+
this
.
state
.
selectedGame
.
name
);
);
console
.
log
(
"
Pelaajan latitude:
"
+
this
.
state
.
userLocation
.
latitude
+
"
Pelaajan longitude:
"
+
this
.
state
.
userLocation
.
longitude
);
fetch
(
fetch
(
`https:/tacs-testing.cf:8443/tracking/location/
${
`https:/tacs-testing.cf:8443/tracking/location/
${
this
.
state
.
selectedGame
.
id
this
.
state
.
selectedGame
.
id
...
@@ -110,11 +123,11 @@ class GameList extends Component {
...
@@ -110,11 +123,11 @@ class GameList extends Component {
// Start & stop tracking depending on the boolean 'tracking' in state
// Start & stop tracking depending on the boolean 'tracking' in state
componentDidUpdate
()
{
componentDidUpdate
()
{
if
(
this
.
state
.
tracking
)
{
//
if (this.state.tracking) {
this
.
startTracking
();
//
this.startTracking();
}
else
if
(
!
this
.
state
.
tracking
)
{
//
} else if (!this.state.tracking) {
this
.
stopTracking
();
//
this.stopTracking();
}
//
}
}
}
// When you select a game with the picker, clears the tracking interval and gets the factions of the game
// When you select a game with the picker, clears the tracking interval and gets the factions of the game
selectGame
=
(
selectedGame
,
itemIndex
)
=>
{
selectGame
=
(
selectedGame
,
itemIndex
)
=>
{
...
@@ -137,6 +150,7 @@ class GameList extends Component {
...
@@ -137,6 +150,7 @@ class GameList extends Component {
};
};
navigator
.
geolocation
.
getCurrentPosition
(
navigator
.
geolocation
.
getCurrentPosition
(
position
=>
{
position
=>
{
console
.
log
(
"
Position :
"
+
position
);
this
.
setState
({
this
.
setState
({
userLocation
:
{
userLocation
:
{
latitude
:
position
.
coords
.
latitude
,
latitude
:
position
.
coords
.
latitude
,
...
...
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