Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Progark gruppe 3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Tobias Ingebrigt Ørstad
Progark gruppe 3
Commits
6bd0b75b
Commit
6bd0b75b
authored
5 years ago
by
ivarnm
Browse files
Options
Downloads
Patches
Plain Diff
#10
Add getGames()
parent
bb640854
No related branches found
No related tags found
1 merge request
!34
Resolve "SinglePlayerSelectGameState"
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/core/src/com/gameware/game/QueryIntermediate.java
+20
-1
20 additions, 1 deletion
frontend/core/src/com/gameware/game/QueryIntermediate.java
frontend/core/src/com/gameware/game/models/Game.java
+5
-0
5 additions, 0 deletions
frontend/core/src/com/gameware/game/models/Game.java
with
25 additions
and
1 deletion
frontend/core/src/com/gameware/game/QueryIntermediate.java
+
20
−
1
View file @
6bd0b75b
...
...
@@ -7,15 +7,20 @@ import com.badlogic.gdx.Net.HttpRequest;
import
com.badlogic.gdx.Net.HttpResponse
;
import
com.badlogic.gdx.net.HttpParametersUtils
;
import
com.badlogic.gdx.utils.Json
;
import
com.badlogic.gdx.utils.JsonReader
;
import
com.badlogic.gdx.utils.JsonValue
;
import
com.gameware.game.models.Game
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.NoSuchElementException
;
public
class
QueryIntermediate
{
private
static
String
baseUrl
=
"http://localhost:3001/api/"
;
private
static
Json
json
=
new
Json
();
private
static
JsonReader
jsonReader
=
new
JsonReader
();
private
static
String
[]
sendGetRequest
(
String
route
)
{
HttpRequest
request
=
new
HttpRequest
(
HttpMethods
.
GET
);
...
...
@@ -81,7 +86,7 @@ public class QueryIntermediate {
}
// ---------------- Games methods ----------------
public
static
Game
getGameById
(
String
gameId
)
throws
IOException
{
public
static
Game
getGameById
(
String
gameId
)
throws
IOException
,
NoSuchElementException
{
String
route
=
"games/gamename/"
+
gameId
;
String
[]
response
=
sendGetRequest
(
route
);
checkStatusCode
(
response
);
...
...
@@ -90,4 +95,18 @@ public class QueryIntermediate {
return
game
;
}
public
static
List
<
Game
>
getGames
()
throws
IOException
{
String
route
=
"games/"
;
List
<
Game
>
games
=
new
ArrayList
<>();
String
[]
response
=
sendGetRequest
(
route
);
checkStatusCode
(
response
);
JsonValue
base
=
jsonReader
.
parse
(
response
[
1
]);
JsonValue
.
JsonIterator
iterator
=
base
.
iterator
();
while
(
iterator
.
hasNext
())
{
Game
game
=
json
.
fromJson
(
Game
.
class
,
iterator
.
next
().
toString
());
games
.
add
(
game
);
}
return
games
;
}
}
This diff is collapsed.
Click to expand it.
frontend/core/src/com/gameware/game/models/Game.java
+
5
−
0
View file @
6bd0b75b
...
...
@@ -22,6 +22,11 @@ public class Game {
return
name
;
}
@Override
public
String
toString
()
{
return
this
.
name
;
}
public
void
reset
()
{
this
.
_id
=
null
;
this
.
name
=
null
;
...
...
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