Package it.polimi.ingsw.Model
Class IslandField
java.lang.Object
it.polimi.ingsw.Model.IslandField
- All Implemented Interfaces:
Serializable
All
IslandGroup
s in the game need to be contained in a circular structure. This class does just that - along
joining the groups and tracking Mother Nature's position- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final int
private final ArrayList<IslandGroup>
private IslandGroup
private static final long
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetMutableIslandById
(int id) getMutableIslandGroupById
(int id) private void
ifJoinableThenJoin
(IslandGroup motherGroup, IslandGroup otherGroup) Two groups are considered joinable if they share the same tower colour.void
When called, this method will join the groups adjacent to mother nature following the game's rules.protected void
moveMotherNature
(int moves) this method is Package-private - moving mother nature through this method does not enact its power. it is therefore unsafe to call this outside of very specific circumstances.private IslandGroup
nextGroup
(IslandGroup curr) searches for theIslandGroup
adjacent to a selected oneprivate IslandGroup
prevGroup
(IslandGroup curr) searches for theIslandGroup
adjacent to a selected one
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
FIELD_SIZE
private static final int FIELD_SIZE- See Also:
-
groups
-
islands
-
motherNaturePosition
-
-
Constructor Details
-
IslandField
public IslandField()Creates the Field, populating it with 12Island
s and 12IslandGroup
s. The generated elements are populated with following the rules of the game.
-
-
Method Details
-
getMutableGroups
- Returns:
- an unmodifiable
List
containing all theIslandGroup
s on the field. Each element on the list CAN be modified, the list itself can't.
-
getMutableIslands
-
getMutableIslandGroupById
- Parameters:
id
- the ID of the group to search for- Returns:
- the
IslandGroup
matching the ID on the input - Throws:
InvalidContainerIndexException
- if the specified ID is not in the list of currently active groups, this exception is thrown
-
getMutableIslandById
- Parameters:
id
- the ID of the island to search for- Returns:
- the
Island
matching the ID on the input - Throws:
InvalidContainerIndexException
- if the specified ID is not in the list of currently active islands, this exception is thrown
-
moveMotherNature
protected void moveMotherNature(int moves) this method is Package-private - moving mother nature through this method does not enact its power. it is therefore unsafe to call this outside of very specific circumstances.- Parameters:
moves
- the amount of moves mother nature will move.
-
joinGroups
public void joinGroups()When called, this method will join the groups adjacent to mother nature following the game's rules. -
getMutableMotherNaturePosition
- Returns:
- the
IslandGroup
matching the position of mother nature
-
nextGroup
searches for theIslandGroup
adjacent to a selected one- Parameters:
curr
- theIslandGroup
you wish to find the next adjacent one- Returns:
- the
IslandGroup
that comes after the one in input
-
prevGroup
searches for theIslandGroup
adjacent to a selected one- Parameters:
curr
- theIslandGroup
you wish to find the previous adjacent one- Returns:
- the
IslandGroup
that comes before the one in input
-
ifJoinableThenJoin
Two groups are considered joinable if they share the same tower colour.- Parameters:
motherGroup
- the group on which Mother nature is standingotherGroup
- a group adjacent to motherGroup
-