Package it.polimi.ingsw.eriantys.model
Class IslandGroup
java.lang.Object
it.polimi.ingsw.eriantys.model.StudentContainer
it.polimi.ingsw.eriantys.model.IslandGroup
This class represents a group of islands, which contains at least one island.
At the beginning of the game, each
IslandGroup is made up of a single island,
but its size can grow during the game as more islands are unified.-
Constructor Summary
ConstructorsConstructorDescriptionIslandGroup(String id) Constructs a newIslandGroupwith the specifiedid, containing no students neither no-entry tiles, and with no controller. -
Method Summary
Modifier and TypeMethodDescriptionbooleanA getter for the list of theids of the single islands components of anIslandGroup.A getter for the island'scontroller.getId()A getter for the island'sid.A helper-getter method to fulfill theBoardStatuscreation process.getSize()A helper-getter method to fulfill theBoardStatuscreation process.intA getter for the number of towers on theIslandGroup.inthashCode()static IslandGroupmerge(IslandGroup i1, IslandGroup i2) Removes the latest no-entry tile to be placed on theIslandGroupand returns itsid.voidputNoEntryTile(int id) Places a no-entry tile on theIslandGroup, unless there already is a no-entry tile with the sameidon it.voidsetController(Player newController) Sets the island'scontrollertonewController, unless it isnull, in which case thecontrollerstays the same.Methods inherited from class it.polimi.ingsw.eriantys.model.StudentContainer
empty, fill, getQuantity, getRepresentation, moveAllTo, moveTo, moveTo, refillFrom, remainingCapacity, swap
-
Constructor Details
-
IslandGroup
Constructs a newIslandGroupwith the specifiedid, containing no students neither no-entry tiles, and with no controller.- Parameters:
id- the new island'sid
-
-
Method Details
-
merge
public static IslandGroup merge(IslandGroup i1, IslandGroup i2) throws IncompatibleControllersException - Parameters:
i1- the first of the islands to mergei2- the second of the islands to merge- Returns:
- an
IslandGroupcontaining all and only the single islands previously contained ini1andi2, and with the same controller as them - Throws:
IncompatibleControllersException- ifi1andi2are controlled by differentPlayers
-
getId
A getter for the island'sid.- Returns:
- the island's
id
-
getController
A getter for the island'scontroller.- Returns:
- the island's
controller
-
setController
Sets the island'scontrollertonewController, unless it isnull, in which case thecontrollerstays the same.- Parameters:
newController- the island's newcontroller
-
getTowers
public int getTowers()A getter for the number of towers on theIslandGroup.- Returns:
- the number of towers on the
IslandGroup
-
putNoEntryTile
Places a no-entry tile on theIslandGroup, unless there already is a no-entry tile with the sameidon it.- Parameters:
id- the no-entry tile's identifier- Throws:
DuplicateNoEntryTileException- if there already is a no-entry tile with the specifiedidon the island
-
popNoEntryTile
Removes the latest no-entry tile to be placed on theIslandGroupand returns itsid. If there are no such tiles on the island, returnsnull.- Returns:
- the
idof the latest no-entry tile to be added, ornullif there are no such tiles on the island
-
getSize
A helper-getter method to fulfill theBoardStatuscreation process.- Returns:
- a representation for the number of islands which form the aggregate
-
getNoEntryTiles
A helper-getter method to fulfill theBoardStatuscreation process.- Returns:
- a representation for the number of no-entry tiles placed on the aggregate
-
getComponents
A getter for the list of theids of the single islands components of anIslandGroup.- Returns:
- a list of the
ids of the single islands making up thisIslandGroup
-
equals
-
hashCode
public int hashCode()
-