public abstract class Game
extends java.lang.Object
This is only used starting in Checkpoint 4.
Constructor and Description |
---|
Game(java.lang.String setEmail,
com.google.android.gms.maps.GoogleMap setMap,
com.neovisionaries.ws.client.WebSocket setWebSocket,
com.google.gson.JsonObject initialState,
android.content.Context setContext)
Sets up this Game.
|
Modifier and Type | Method and Description |
---|---|
protected android.content.Context |
getContext()
Gets the UI context.
|
protected java.lang.String |
getEmail()
Gets the user's email address.
|
protected com.google.android.gms.maps.GoogleMap |
getMap()
Gets the Google Maps view used by this Game.
|
int |
getMyTeam()
Gets the user's team ID in this game.
|
abstract int |
getTeamScore(int teamId)
Gets a team's score.
|
int |
getWinningTeam()
Determines which team has the most points.
|
boolean |
handleMessage(com.google.gson.JsonObject message)
Processes an update from the server.
|
void |
locationUpdated(com.google.android.gms.maps.model.LatLng location)
Processes a location change and makes appropriate changes/notifications.
|
protected void |
sendMessage(com.google.gson.JsonObject message)
Sends a message to the server.
|
public Game(java.lang.String setEmail, com.google.android.gms.maps.GoogleMap setMap, com.neovisionaries.ws.client.WebSocket setWebSocket, com.google.gson.JsonObject initialState, android.content.Context setContext)
setEmail
- the player's email (from Firebase)setMap
- the Google Maps view to render tosetWebSocket
- the websocket to send events toinitialState
- the "full" update from the serversetContext
- the Android UI contextprotected final android.content.Context getContext()
protected final java.lang.String getEmail()
protected final com.google.android.gms.maps.GoogleMap getMap()
public final int getMyTeam()
public abstract int getTeamScore(int teamId)
teamId
- the team IDpublic final int getWinningTeam()
You do not need to consider ties - you may do anything you think is reasonable in that case.
@CallSuper public boolean handleMessage(com.google.gson.JsonObject message)
message
- JSON from the server (the "type" property indicates the type)@CallSuper public void locationUpdated(com.google.android.gms.maps.model.LatLng location)
location
- the player's most recently known locationprotected final void sendMessage(com.google.gson.JsonObject message)
message
- JSON object to send