All Implemented Interfaces:
TurnListener, UseListener, Killer, PuzzleEntity, Cloneable, Iterable<String>, Serializable

public class Gate extends Entity implements UseListener, TurnListener, PuzzleEntity
  • Constructor Details

    • Gate

      public Gate(String orientation, String image, ChatCondition condition)
      Create a new gate.
      Parameters:
      orientation - gate orientation. Either "v" or "h".
      image - image used for the gate
      condition - conditions required for opening the gate, or null if no checking is required
    • Gate

      public Gate()
      Create a new vertical gate.
  • Method Details

    • generateGateRPClass

      public static void generateGateRPClass()
    • open

      public void open()
      Open the gate.
    • isOpen

      public boolean isOpen()
      Check if the gate is open.
      Returns:
      true iff the gate is open
    • close

      public void close()
      Close the gate.
    • onUsed

      public boolean onUsed(RPEntity user)
      Description copied from interface: UseListener
      Invoked when the object is used.
      Specified by:
      onUsed in interface UseListener
      Parameters:
      user - the RPEntity who uses the object
      Returns:
      true if successful
    • setAutoCloseDelay

      public void setAutoCloseDelay(int seconds)
      Make the gate close automatically after specified delay once it's been opened.
      Parameters:
      seconds - time to keep the gate open
    • isAllowed

      protected boolean isAllowed(RPEntity user)
      Check if a player can use the gate.
      Parameters:
      user - player trying to close or open the gate
      Returns:
      true iff the player is allowed to use the gate
    • setOpen

      protected void setOpen(boolean open)
      Set the door open or closed.
      Parameters:
      open - true if the door is opened, false otherwise
    • getIdentifier

      public String getIdentifier()
      Get the identifier of the gate
      Returns:
      the gate's identifier
    • setIdentifier

      public void setIdentifier(String id)
      Sets this gate's identifier
      Parameters:
      id - the new identifier of the gate
    • setRefuseMessage

      public void setRefuseMessage(String message)
      Set the message to be send to the player if she's not allowed to open the gate
      Parameters:
      message -
    • getRefuseMessage

      public String getRefuseMessage()
      Retrieve message to be sent when access is refused.
    • onTurnReached

      public void onTurnReached(int currentTurn)
      Callback for the turn notifier to automatically close the gate if the interval is set
      Specified by:
      onTurnReached in interface TurnListener
      Parameters:
      currentTurn - current turn number
    • puzzleExpressionsUpdated

      public void puzzleExpressionsUpdated()
      Description copied from interface: PuzzleEntity
      invoked when the expressions of a PuzzleBuildingBlock have been updated. It is ensured that there was an actual change.
      Specified by:
      puzzleExpressionsUpdated in interface PuzzleEntity
    • setPuzzleBuildingBlock

      public void setPuzzleBuildingBlock(PuzzleBuildingBlock buildingBlock)
      Description copied from interface: PuzzleEntity
      sets the PuzzleBuildingBlock
      Specified by:
      setPuzzleBuildingBlock in interface PuzzleEntity
      Parameters:
      buildingBlock - PuzzleBuildingBlock