Package rea.components
Class Place
java.lang.Object
rea.components.Component
rea.components.Place
- All Implemented Interfaces:
Element
A place in the game. A place can contain connections to other places and game components
such as characters, items, etc.
- Author:
- José Paulo Leal
jpleal@fc.up.pt
- Implementation Note:
- Corresponds to a Container in the Composite design pattern.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Position
Position where the character enters this place.(package private) List
<Positionable> The positionable components in this place.Fields inherited from class rea.components.Component
description, visual
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Accept a visitor.addGameComponent
(Positionable positionable, Position position) Get the characters in this place.The entrance to this place.getItems()
Get the items in this place.Get the list of game positionable components in this place.boolean
removeGameComponent
(Positionable positionable) Methods inherited from class rea.components.Component
getDescription, getVisual, toString
-
Field Details
-
entrance
Position where the character enters this place. -
positionables
List<Positionable> positionablesThe positionable components in this place.- Implementation Note:
- cannot be a
Set
because positionable are mutable and this interferes with theSet.contains(Object)
method.
-
-
Constructor Details
-
Place
Create a place.- Parameters:
background
- showing this place.description
- of this place.entrance
- position where the characters enter this place.
-
-
Method Details
-
getEntrance
The entrance to this place.- Returns:
- the position where the character enters this place.
-
addGameComponent
Add a positionable component, such asItem
orCharacter
to this place. It returns the place itself to allow chaining.- Parameters:
positionable
- component to add.position
- where to add the component.- Returns:
- the place itself.
-
removeGameComponent
Remove a positionable component, such asItem
orCharacter
from this place. It returnstrue
if the component was removed,false
otherwise.- Parameters:
positionable
- component to remove.- Returns:
true
if the component was removed,false
otherwise.
-
getPositionables
Get the list of game positionable components in this place.- Returns:
- the list of positionable components.
-
getCharacters
Get the characters in this place. Convinience methods to get the positionables that are players.- Returns:
- the set of players in this place.
-
getItems
Get the items in this place. Convinience methods to get the positionables that are item.- Returns:
- the set of items in this place.
-
accept
Accept a visitor.- Parameters:
visitor
- the visitor to accept
-