private void parseLoadout(JSONObject o) throws ProtocolException { try { if (!(o.get("message").equals("loadout"))) { throw new ProtocolException("Expected 'loadout', but got '" + o.get("message") + "' key"); } if (!Util.validateWeapon(o.getString("primary-weapon"))) { throw new ProtocolException( "Invalid primary weapon: '" + o.getString("primary-weapon") + "'"); } if (!Util.validateWeapon(o.getString("secondary-weapon"))) { throw new ProtocolException( "Invalid secondary weapon: '" + o.getString("secondary-weapon") + "'"); } if (o.getString("primary-weapon").equals(o.getString("secondary-weapon"))) { throw new ProtocolException("Invalid loadout: Can't have the same weapon twice."); } primaryWeapon = o.getString("primary-weapon"); secondaryWeapon = o.getString("secondary-weapon"); Debug.info( username + " selected loadout: " + primaryWeapon + " and " + secondaryWeapon + "."); gotLoadout.set(true); } catch (JSONException e) { throw new ProtocolException("Invalid or incomplete packet: " + e.getMessage()); } }
void givePoints(int points) { Debug.info("got awarded " + points + " points"); score += points; }
public synchronized void setSpawnpoint(Tile spawnpoint) { Debug.info("Player '" + username + "' spawns at " + spawnpoint.coords.getString()); position = spawnpoint; spawnTile = spawnpoint; position.playerOnTile = this; }