public interface Field
A field has three dimensions: width, depth, and height. In the generated
match videos, the perspective is from above, so WIDTH
and
DEPTH
refer to the width and height of the video. But do not confuse
depth with height; the y-coordinate returned by Locatable.getLocation()
represents an entirely different dimension than the y-coordinate returned by
Player.getHeight()
.
Modifier and Type | Field | Description |
---|---|---|
static double |
DEPTH |
The depth, or maximum y-coordinate, of the field.
|
static int |
MAX_FOOD |
The maximum food pieces that can exist on the field at a time.
|
static int |
TOTAL_TURNS |
The total number of turns in a match.
|
static double |
WIDTH |
The width, or maximum x-coordinate, of the field.
|
Modifier and Type | Method | Description |
---|---|---|
Set<Collision> |
getCollisions() |
Returns a set of all of the collisions that occurred on the field on the
previous turn.
|
Set<Food> |
getFood() |
Returns a set containing all of the food on the field.
|
Food |
getFood(Food.Type type) |
Returns the food piece on this field with the given type.
|
MatchType |
getMatchType() |
Returns the type of match being played on this field.
|
Player |
getPlayer(char symbol) |
Returns the player on this field with the given symbol.
|
Set<Player> |
getPlayers() |
Returns a set containing all players on the field.
|
Team |
getTeam(char symbol) |
Returns the team on this field with the given symbol.
|
Team |
getTeam(Player player) |
Returns the team for which the given player is playing.
|
Set<Team> |
getTeams() |
Returns a set containing all of the teams on the field.
|
int |
getTurnNumber() |
Returns the number of the current turn.
|
static final double DEPTH
static final double WIDTH
static final int MAX_FOOD
static final int TOTAL_TURNS
int getTurnNumber()
TOTAL_TURNS
.MatchType getMatchType()
Set<Team> getTeams()
Team getTeam(char symbol)
Team.getSymbol()
will return symbol for the returned team. If
there is no team playing on this field that has the given symbol, this
method returns null. The functionality of this method could be achieved
by iterating over the set returned by getTeams()
, but this
method exists for convenience.symbol
- the identifying symbol of the desired teamTeam getTeam(Player player)
Team.getPlayers()
will return a set that contains the given
player. If no such team exists (meaning that the player is not currently
on the field), then this method returns null. The functionality of this
method could be achieved by iterating over the set returned by
getTeams()
, but this method exists for convenience.player
- a player on the desired teamSet<Player> getPlayers()
getTeams()
, and the set returned by Team.getPlayers()
for each team, but this method exists for convenience.Player getPlayer(char symbol)
Player.getSymbol()
will return symbol for the returned player. If
there is no player playing on this field that has the given symbol, this
method returns null. The functionality of this method could be achieved
by iterating over the set returned by getTeams()
, but this
method exists for convenience.symbol
- the identifying symbol of the desired playerSet<Food> getFood()
Table
or in a player's
Inventory
; it includes only food that is on the ground or in the
air.
There are three ways for the size of this set to decrease: if a player picks up a food piece (moving the food into the player's inventory), if a player is struck by a flying food piece (despawning the food piece), or if a food piece passes over a table (moving the food onto the table).
There are also two ways for the size of this set to increase: if a player
throws a food piece (creating a new flying food piece), or if a new food
piece is spawned (creating a new food piece on the ground). A new food
piece is spawned on a turn if the total number of types of food on the
field (including tables an inventories) is less than MAX_FOOD
,
and then only with probability Food.RESPAWN_RATE
. Food pieces are
spawned at a random, non-colliding position on the field.
Food getFood(Food.Type type)
Food.getType()
will return type for the returned food piece. If
there is no food piece on this field that has the given type, this method
returns null. There will never be two food pieces of the same type on the
field at a time, so this method returns the unique food piece with the
desired type. Note that food on a Table
or in a player's
Inventory
is ignored, so if food of this type is on a table or in
a player's inventory, this method returns null. The functionality of this
method could be achieved by iterating over the set returned by
getFood()
, but this method exists for convenience.type
- the type of the desired food pieceSet<Collision> getCollisions()