Class 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.
    • 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 method selectSlot has to be called immediately before this method, to avoid a IndexOutOfBoundsException. 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 hand
        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​(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.
      • 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 Marketplace
        food - How much food to sell
        materials - 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