public final class AreaGame extends Game
Constructor and Description |
---|
AreaGame(java.lang.String email,
com.google.android.gms.maps.GoogleMap map,
com.neovisionaries.ws.client.WebSocket webSocket,
com.google.gson.JsonObject fullState,
android.content.Context context)
Creates a game in area mode.
|
Modifier and Type | Method and Description |
---|---|
int |
getTeamScore(int teamId)
Gets a team's score in this area mode game.
|
boolean |
handleMessage(com.google.gson.JsonObject message)
Processes an update from the server.
|
void |
locationUpdated(com.google.android.gms.maps.model.LatLng location)
Called when the user's location changes.
|
getContext, getEmail, getMap, getMyTeam, getWinningTeam, sendMessage
public AreaGame(java.lang.String email, com.google.android.gms.maps.GoogleMap map, com.neovisionaries.ws.client.WebSocket webSocket, com.google.gson.JsonObject fullState, android.content.Context context)
Loads the current game state from JSON into instance variables and populates the map to show existing cell captures.
Note that the player may or may not have already captured some cells.
email
- the player's emailmap
- the Google map to render towebSocket
- the websocket to send updates tofullState
- the "full" update from the servercontext
- the Android UI contextpublic int getTeamScore(int teamId)
getTeamScore
in class Game
teamId
- the team IDpublic boolean handleMessage(com.google.gson.JsonObject message)
Since playerCellCapture events are specific to area mode games, this function handles those. ALl other message types are delegated to the superclass.
handleMessage
in class Game
message
- JSON from the server (the "type" property indicates the update type)public void locationUpdated(com.google.android.gms.maps.model.LatLng location)
Area mode games detect whether the player is in an uncaptured cell. Capture is possible if the player has no path yet or if the cell shares a side with the previous cell captured by the player. If capture occurs, this method sends a cellCapture event to the server.
locationUpdated
in class Game
location
- the player's most recently known location