Package it.polimi.ingsw.Model
Class IslandField
java.lang.Object
it.polimi.ingsw.Model.IslandField
- All Implemented Interfaces:
Serializable
All
IslandGroups 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
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final ArrayList<IslandGroup>private IslandGroupprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetMutableIslandById(int id) getMutableIslandGroupById(int id) private voidifJoinableThenJoin(IslandGroup motherGroup, IslandGroup otherGroup) Two groups are considered joinable if they share the same tower colour.voidWhen called, this method will join the groups adjacent to mother nature following the game's rules.protected voidmoveMotherNature(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 IslandGroupnextGroup(IslandGroup curr) searches for theIslandGroupadjacent to a selected oneprivate IslandGroupprevGroup(IslandGroup curr) searches for theIslandGroupadjacent 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 12Islands and 12IslandGroups. The generated elements are populated with following the rules of the game.
-
-
Method Details
-
getMutableGroups
- Returns:
- an unmodifiable
Listcontaining all theIslandGroups 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
IslandGroupmatching 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
Islandmatching 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
IslandGroupmatching the position of mother nature
-
nextGroup
searches for theIslandGroupadjacent to a selected one- Parameters:
curr- theIslandGroupyou wish to find the next adjacent one- Returns:
- the
IslandGroupthat comes after the one in input
-
prevGroup
searches for theIslandGroupadjacent to a selected one- Parameters:
curr- theIslandGroupyou wish to find the previous adjacent one- Returns:
- the
IslandGroupthat 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
-