Class TreasureHunt

java.lang.Object
rea.gameplay.games.TreasureHunt
All Implemented Interfaces:
Gameplay

public class TreasureHunt extends Object implements Gameplay
A simple game where the player has to look for a treasure hidden inside a house with a colsed door. The player has to find a key to open the door and get the treasure.
Author:
José Paulo Leal jpleal@fc.up.pt
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final int
    The background height
    (package private) static final int
    The background width
    (package private) static int
    The initial position of the character's x coordinate
    (package private) static int
    The initial position of the character's y coordinate
    (package private) static final Visual
    The visual representation of an empty room used as a background
    (package private) static final Visual
    The visual representation of house with a closed door
    (package private) static int
    The height of the house visual
    (package private) static final Visual
    The visual representation of a house with an open door
    (package private) static int
    The width of the house visual
    (package private) static final int
    The height of the key visual
    (package private) static final Visual
    The visual representation of a key
    (package private) static final int
    The width of the key visual
    (package private) static final Visual
    The visual representation of a lawn used a background
    (package private) static final int
    The height of the treasure visual
    (package private) static final Visual
    The visual representation of the treasure
    (package private) static final int
    The width of the treasure vsiual
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new instance of the game
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Game ends when there is a passage (house with open door) and there are no items left (tresure was collected).
    The avatars available for this game: cartoon avatars.
    A long description of the game.
    int
    Can have up to 2 players
    int
    At least 1 player is required
    The name of the game as a short string.
    Produce a map for a game instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BACKGROUND_WIDTH

      static final int BACKGROUND_WIDTH
      The background width
      See Also:
    • BACKGROUND_HEIGHT

      static final int BACKGROUND_HEIGHT
      The background height
      See Also:
    • LAWN_VISUAL

      static final Visual LAWN_VISUAL
      The visual representation of a lawn used a background
    • EMPTY_ROOM_VISUAL

      static final Visual EMPTY_ROOM_VISUAL
      The visual representation of an empty room used as a background
    • KEY_WIDTH

      static final int KEY_WIDTH
      The width of the key visual
      See Also:
    • KEY_HEIGHT

      static final int KEY_HEIGHT
      The height of the key visual
      See Also:
    • KEY_VISUAL

      static final Visual KEY_VISUAL
      The visual representation of a key
    • TREASURE_WIDTH

      static final int TREASURE_WIDTH
      The width of the treasure vsiual
      See Also:
    • TREASURE_HEIGHT

      static final int TREASURE_HEIGHT
      The height of the treasure visual
      See Also:
    • TREASURE_VISUAL

      static final Visual TREASURE_VISUAL
      The visual representation of the treasure
    • CHARACTER_X

      static int CHARACTER_X
      The initial position of the character's x coordinate
    • CHARACTER_Y

      static int CHARACTER_Y
      The initial position of the character's y coordinate
    • HOUSE_WIDTH

      static int HOUSE_WIDTH
      The width of the house visual
    • HOUSE_HEIGHT

      static int HOUSE_HEIGHT
      The height of the house visual
    • HOUSE_CLOSE_DOOR_VISUAL

      static final Visual HOUSE_CLOSE_DOOR_VISUAL
      The visual representation of house with a closed door
    • HOUSE_OPEN_DOOR_VISUAL

      static final Visual HOUSE_OPEN_DOOR_VISUAL
      The visual representation of a house with an open door
  • Constructor Details

    • TreasureHunt

      public TreasureHunt()
      Create a new instance of the game
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Gameplay
      The name of the game as a short string.
      Specified by:
      getName in interface Gameplay
      Returns:
      name of the game
    • getDescription

      public String getDescription()
      Description copied from interface: Gameplay
      A long description of the game.
      Specified by:
      getDescription in interface Gameplay
      Returns:
      description of the game
    • makeGameMap

      public GameMap makeGameMap()
      Description copied from interface: Gameplay
      Produce a map for a game instance. A map is a collection of interconnected places. This method returns the place where the game starts. When players enter the game they will be in this place The place can (and should) be connected to other places. Each invocation of this method must return a new instance, although with a similar structure.
      Specified by:
      makeGameMap in interface Gameplay
      Returns:
      the place where the game starts
    • getAvatars

      public Set<Avatar> getAvatars()
      The avatars available for this game: cartoon avatars.
      Specified by:
      getAvatars in interface Gameplay
      Returns:
      set of cartoon avatars
      Implementation Note:
      The avatars are the enum constants of the CartoonAvatar class
    • getMaxPlayers

      public int getMaxPlayers()
      Can have up to 2 players
      Specified by:
      getMaxPlayers in interface Gameplay
      Returns:
      2
    • getMinPlayers

      public int getMinPlayers()
      At least 1 player is required
      Specified by:
      getMinPlayers in interface Gameplay
      Returns:
      1
    • gamedEnded

      public boolean gamedEnded(GameMap gameMap)
      Game ends when there is a passage (house with open door) and there are no items left (tresure was collected).
      Specified by:
      gamedEnded in interface Gameplay
      Parameters:
      gameMap - for this game instance
      Returns:
      true if game has ended, false otherwise.
      Implementation Note:
      uses the SimpleVisitor to check if there, and if more than the initial place where visited.