State.StateView¶
-
public static class
StateView
implements Serializable¶
Methods¶
canSee¶
-
public boolean
canSee
(int x, int y)¶ Returns whether the selected coordinates are visible to the player through the fog of war.
Parameters: - x –
- y –
getAllResourceIds¶
getAllResourceNodes¶
-
public List<ResourceNode.ResourceView>
getAllResourceNodes
()¶ Get the views of all of the resource nodes that you can see
getAllTemplateIds¶
getAllTemplates¶
-
public List<TemplateView>
getAllTemplates
()¶ Get the views of all the templates. If you are not an observer, it will only give you yours if fog of war is on
getClosestOpenPosition¶
-
public int[]
getClosestOpenPosition
(int x, int y)¶ Gets the closest position that you can see.
Parameters: - x –
- y –
getPlayerNumbers¶
getResourceAmount¶
-
public Integer
getResourceAmount
(int playerid, ResourceType type)¶ Get the amount of wood or gold (specified by the type) available to a specific player. If you are not an observer, it will not work on other people with fog of war on
Parameters: - player –
- type – The type of resource
getResourceNode¶
-
public ResourceNode.ResourceView
getResourceNode
(int resourceID)¶ Get the resource node with the selected ID (if you can see it)
Parameters: - resourceID –
Returns: The resource node with id resourceID, or null if you can’t see it or if there isn’t one.
getResourceNodeIds¶
-
public List<Integer>
getResourceNodeIds
(ResourceNode.Type type)¶ Get the IDs of all of the resource nodes of a type that you can see
Parameters: - type – Gold mine or Tree
getResourceNodes¶
-
public List<ResourceNode.ResourceView>
getResourceNodes
(ResourceNode.Type type)¶ Get the views of all of the resource nodes of a type that you can see
Parameters: - type – Gold mine or Tree
getStateCreator¶
-
public StateCreator
getStateCreator
()¶ If the player can see the whole state, get a StateCreator that will rebuild the state as it is when this is called. This can be used as an immutable and repeatable deep copy of the underlying state.
Throws: - IOException –
Returns: When fog of war is on and the player is not an observer: null;otherwise: A StateCreator that rebuilds the underlying state.
getSupplyAmount¶
getSupplyCap¶
getSupplyCapEarned¶
-
public Integer
getSupplyCapEarned
(int playerid)¶ Get the maximum amount of supply (food) earned by a specific player. This is the amount given by the farms and town halls or their alternatives. This should be used for calculating effect of farms/townhalls dying, not for calculating whether you can make a unit. If you are not an observer, it will not work on other people with fog of war on
Parameters: - player –
getSupplyCapMaximum¶
-
public int
getSupplyCapMaximum
()¶ Get the maximum amount of supply that could ever be available to any player. This should be used in conjunction with getSupplyCapEarned to determine the effect of building a new farm/townhall.
getTemplate¶
-
public Template.TemplateView
getTemplate
(int templateID)¶ Get a template with a specific ID If you are not an observer, it won’t work with somebody else’s template with fog of war on
Parameters: - templateID –
getTemplate¶
-
public Template.TemplateView
getTemplate
(int player, String name)¶ Get a template with that name owned by that player
Parameters: - player –
- name –
Returns: The view of the first (and what should be the only) template that has the specified name, or null if that player does not have a template by that name
getTemplateIds¶
getTemplates¶
-
public List<TemplateView>
getTemplates
(int playerid)¶ Get a player’s template views If you are not an observer, you can’t get other people’s templates if fog of war is on
Parameters: - playerid –
getUnit¶
getUnitIds¶
getUnits¶
hasUnit¶
-
public boolean
hasUnit
(int playerNumber, int templateid)¶ Get whether a player has a unit of a certain type. (Say, a tech building). If you are not an observer, then this will not work on other players with fog of war on
Parameters: - playerNumber –
- buildingtemplateid –
Returns: Whether the player with id playerid has a unit with a template with the template id templateid, or false if the player is not you
hasUpgrade¶
-
public boolean
hasUpgrade
(int upgradeid, int playerid)¶ Get whether a player has researched a specific upgrade. If you are not an observer, then this will not work on other players with fog of war on
Parameters: - upgradeid –
- playerid –
Returns: Whether the player has researched an upgrade with id upgradeid. Always false if you try it on someone else.
inBounds¶
-
public boolean
inBounds
(int x, int y)¶ Find whether a position is in bounds.
Parameters: - x –
- y –
isFogOfWar¶
-
public boolean
isFogOfWar
()¶ Get whether fog of war (partial observability) is activated
isResourceAt¶
-
public boolean
isResourceAt
(int x, int y)¶ Find whether there is a resource at the position
Parameters: - x –
- y –
Returns: Whether there is a resource there (always false if you can’t see there)
isUnitAt¶
-
public boolean
isUnitAt
(int x, int y)¶ Find if there is a unit at a position
Parameters: - x –
- y –
Returns: Whether there is a unit at the position (always false if you can’t see there)