Class Controller
- java.lang.Object
-
- page.codeberg.terratactician_expandoria.bots.Controller
-
public class Controller extends java.lang.Object
Controller for the challenge mode. This is a wrapper for ActionsList. The Controller is used to schedule game actions. All actions will be executed after the executeTurn method has returned. In an usual game only one action can be submitted.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Controller.TooManyActionsException
TooManyActionsException is a RuntimeException indicating that adding a action failed, because the limit was reached.
-
Constructor Summary
Constructors Constructor Description Controller(ChallengeTickEvent event)
Creates a new challenge controller.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
actionPossible()
Returns whether its possible to add another action to the current ChallengeTick.void
collectReward(CubeCoordinate coord)
Every few seconds small rewards spawn over the map.void
configureMarket(CubeCoordinate coord, double food, double materials)
A Marketplace tile can sell materials and food, produced in proximity to it.ActionsList
getActionList()
The Controller is a wrapper for ActionsList.void
injectActionList(ActionsList list)
The Controller is a wrapper for ActionsList.void
placeTile(int slot, CubeCoordinate coord)
This method places a tile from the hand on the map.void
placeTile(CubeCoordinate coord)
This method places the selected tile in the hand on the map.void
placeTile(Tile.TileType tileType, CubeCoordinate coord)
This method places a tile of given type on the map.void
placeTile(Tile tile, CubeCoordinate coord)
This method places the selected tile on the map.void
redraw()
This method refills the hand with new cards.void
selectSlot(int slot)
Select a slot in the hand.void
takeTile(CubeCoordinate coord)
This method takes one tile from the map and puts it back to the hand.
-
-
-
Constructor Detail
-
Controller
public Controller(ChallengeTickEvent event)
Creates a new challenge controller. This needs the current challenge ticks, to get some information about the game.- Parameters:
event
- ChallengeTickEvent to answer to.
-
-
Method Detail
-
actionPossible
public boolean actionPossible()
Returns whether its possible to add another action to the current ChallengeTick.- Returns:
- actions limit not reached
-
selectSlot
public void selectSlot(int slot) throws java.lang.IndexOutOfBoundsException
Select a slot in the hand. This method is not part of the actions Limit. The selected Slot has to exists.- Parameters:
slot
- Slot to select.- Throws:
java.lang.IndexOutOfBoundsException
- On invalid hand slot.
-
placeTile
public void placeTile(CubeCoordinate coord) throws Controller.TooManyActionsException, java.lang.IndexOutOfBoundsException
This method places the selected tile in the hand on the map. The methodselectSlot
has to be called immediately before this method, to avoid aIndexOutOfBoundsException
. This action is part of the action limit.- Parameters:
coord
- targeted Coordinate- Throws:
Controller.TooManyActionsException
- When too many actions are scheduled. The limit is usually 1.java.lang.IndexOutOfBoundsException
- On invalid hand slot.
-
placeTile
public void placeTile(int slot, CubeCoordinate coord) throws Controller.TooManyActionsException, java.lang.IndexOutOfBoundsException
This method places a tile from the hand on the map. The slot index must not exceed the the hand size. This action is part of the action limit.- Parameters:
slot
- selected slot from the handcoord
- targeted Coordinate- Throws:
Controller.TooManyActionsException
- When too many actions are scheduled. The limit is usually 1.java.lang.IndexOutOfBoundsException
- On invalid hand slot.
-
placeTile
public void placeTile(Tile tile, CubeCoordinate coord) throws Controller.TooManyActionsException
This method places the selected tile on the map. The tile has to be in the hand. This action is part of the action limit.- Parameters:
tile
- tile to be placed (tile will be cloned)coord
- targeted Coordinate- Throws:
Controller.TooManyActionsException
- When too many actions are scheduled. The limit is usually 1.
-
placeTile
public void placeTile(Tile.TileType tileType, CubeCoordinate coord) throws Controller.TooManyActionsException
This method places a tile of given type on the map. The tile has to be in the hand. This action is part of the action limit.- Parameters:
tileType
- tile to be placed (tile will be cloned)coord
- targeted Coordinate- Throws:
Controller.TooManyActionsException
- When too many actions are scheduled. The limit is usually 1.
-
takeTile
public void takeTile(CubeCoordinate coord) throws Controller.TooManyActionsException
This method takes one tile from the map and puts it back to the hand. This is only possible if the hand has a free space and the tile was recently placed (The reclaim timeout is not over). The tile is only available in the next turn. This action is part of the action limit.- Parameters:
coord
- targeted Coordinate- Throws:
Controller.TooManyActionsException
- When too many actions are scheduled. The limit is usually 1.
-
redraw
public void redraw() throws Controller.TooManyActionsException
This method refills the hand with new cards. This action costs resources/metrics and is only possible when the player has enough of them. If the redraw was for free hand will just be refilled, otherwise all tiles will be replaced. This action is part of the action limit.- Throws:
Controller.TooManyActionsException
- When too many actions are scheduled. The limit is usually 1.
-
collectReward
public void collectReward(CubeCoordinate coord) throws Controller.TooManyActionsException
Every few seconds small rewards spawn over the map. This method can be used to collect them. You have to supply the coordinate of the reward. This action is part of the action limit.- Parameters:
coord
- Coordinate of the Reward.- Throws:
Controller.TooManyActionsException
- When too many actions are scheduled. The limit is usually 1.
-
configureMarket
public void configureMarket(CubeCoordinate coord, double food, double materials) throws Controller.TooManyActionsException, java.lang.IllegalArgumentException
A Marketplace tile can sell materials and food, produced in proximity to it. Use this action to change the sell ratio. The ratio has to supplied with values between 0 and 1. This action is part of the action limit.- Parameters:
coord
- Coordinate of the Marketplacefood
- How much food to sellmaterials
- How much materials to sell- Throws:
Controller.TooManyActionsException
- When too many actions are scheduled. The limit is usually 1.java.lang.IllegalArgumentException
- Gets thrown, if invalid sell ratios are supplied.
-
injectActionList
public void injectActionList(ActionsList list) throws java.lang.NullPointerException
The Controller is a wrapper for ActionsList. With this method a custom ActionList can be injected. The old one will be overwritten. This feature is for advanced users only. It is possible to inject too many actions without any warning. The limit is enforced in the game itself.- Parameters:
list
- ActionList to be injected.- Throws:
java.lang.NullPointerException
- When too many actions are scheduled. The limit is usually 1.
-
getActionList
public ActionsList getActionList()
The Controller is a wrapper for ActionsList. This method allows to edit the Internal ActionsList. This feature is for advanced users only. It is possible to add too many actions without any warning. The limit is enforced in the game itself.- Returns:
- current Action list
-
-