Package rea.gameplay.games
Class TreasureHunt
java.lang.Object
rea.gameplay.games.TreasureHunt
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescription(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 -
Method Summary
Modifier and TypeMethodDescriptionboolean
gamedEnded
(GameMap gameMap) 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 playersint
At least 1 player is requiredgetName()
The name of the game as a short string.Produce a map for a game instance.
-
Field Details
-
BACKGROUND_WIDTH
static final int BACKGROUND_WIDTHThe background width- See Also:
-
BACKGROUND_HEIGHT
static final int BACKGROUND_HEIGHTThe background height- See Also:
-
LAWN_VISUAL
The visual representation of a lawn used a background -
EMPTY_ROOM_VISUAL
The visual representation of an empty room used as a background -
KEY_WIDTH
static final int KEY_WIDTHThe width of the key visual- See Also:
-
KEY_HEIGHT
static final int KEY_HEIGHTThe height of the key visual- See Also:
-
KEY_VISUAL
The visual representation of a key -
TREASURE_WIDTH
static final int TREASURE_WIDTHThe width of the treasure vsiual- See Also:
-
TREASURE_HEIGHT
static final int TREASURE_HEIGHTThe height of the treasure visual- See Also:
-
TREASURE_VISUAL
The visual representation of the treasure -
CHARACTER_X
static int CHARACTER_XThe initial position of the character's x coordinate -
CHARACTER_Y
static int CHARACTER_YThe initial position of the character's y coordinate -
HOUSE_WIDTH
static int HOUSE_WIDTHThe width of the house visual -
HOUSE_HEIGHT
static int HOUSE_HEIGHTThe height of the house visual -
HOUSE_CLOSE_DOOR_VISUAL
The visual representation of house with a closed door -
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
Description copied from interface:Gameplay
The name of the game as a short string. -
getDescription
Description copied from interface:Gameplay
A long description of the game.- Specified by:
getDescription
in interfaceGameplay
- Returns:
- description of the game
-
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 interfaceGameplay
- Returns:
- the place where the game starts
-
getAvatars
The avatars available for this game: cartoon avatars.- Specified by:
getAvatars
in interfaceGameplay
- 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 interfaceGameplay
- Returns:
- 2
-
getMinPlayers
public int getMinPlayers()At least 1 player is required- Specified by:
getMinPlayers
in interfaceGameplay
- Returns:
- 1
-
gamedEnded
Game ends when there is a passage (house with open door) and there are no items left (tresure was collected).- Specified by:
gamedEnded
in interfaceGameplay
- 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.
-