Skip to content
Snippets Groups Projects
Commit 99969276 authored by ivarnm's avatar ivarnm
Browse files

#10 Add getTournamentsForPlayer

parent 6bd0b75b
No related branches found
No related tags found
1 merge request!34Resolve "SinglePlayerSelectGameState"
......@@ -10,6 +10,7 @@ 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 com.gameware.game.models.Tournament;
import java.io.IOException;
import java.util.ArrayList;
......@@ -109,4 +110,23 @@ public class QueryIntermediate {
return games;
}
// ---------------- Tournaments methods ----------------
public static List<Tournament> getTournamentsForPlayer(String playerId) throws IOException {
String route = "tournament/player/" + playerId + "/true/";
List<Tournament> tournaments = new ArrayList<>();
String[] response = sendGetRequest(route);
checkStatusCode(response);
JsonValue base = jsonReader.parse(response[1]);
JsonValue.JsonIterator iterator = base.iterator();
while (iterator.hasNext()) {
Tournament tournament = json.fromJson(Tournament.class, iterator.next().toString());
tournaments.add(tournament);
}
return tournaments;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment