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
ConstructorDescriptionIslandGroup
(String id) Constructs a newIslandGroup
with the specifiedid
, containing no students neither no-entry tiles, and with no controller. -
Method Summary
Modifier and TypeMethodDescriptionboolean
A getter for the list of theid
s 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 theBoardStatus
creation process.getSize()
A helper-getter method to fulfill theBoardStatus
creation process.int
A getter for the number of towers on theIslandGroup
.int
hashCode()
static IslandGroup
merge
(IslandGroup i1, IslandGroup i2) Removes the latest no-entry tile to be placed on theIslandGroup
and returns itsid
.void
putNoEntryTile
(int id) Places a no-entry tile on theIslandGroup
, unless there already is a no-entry tile with the sameid
on it.void
setController
(Player newController) Sets the island'scontroller
tonewController
, unless it isnull
, in which case thecontroller
stays 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 newIslandGroup
with 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
IslandGroup
containing all and only the single islands previously contained ini1
andi2
, and with the same controller as them - Throws:
IncompatibleControllersException
- ifi1
andi2
are controlled by differentPlayer
s
-
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'scontroller
tonewController
, unless it isnull
, in which case thecontroller
stays 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 sameid
on it.- Parameters:
id
- the no-entry tile's identifier- Throws:
DuplicateNoEntryTileException
- if there already is a no-entry tile with the specifiedid
on the island
-
popNoEntryTile
Removes the latest no-entry tile to be placed on theIslandGroup
and returns itsid
. If there are no such tiles on the island, returnsnull
.- Returns:
- the
id
of the latest no-entry tile to be added, ornull
if there are no such tiles on the island
-
getSize
A helper-getter method to fulfill theBoardStatus
creation process.- Returns:
- a representation for the number of islands which form the aggregate
-
getNoEntryTiles
A helper-getter method to fulfill theBoardStatus
creation process.- Returns:
- a representation for the number of no-entry tiles placed on the aggregate
-
getComponents
A getter for the list of theid
s of the single islands components of anIslandGroup
.- Returns:
- a list of the
id
s of the single islands making up thisIslandGroup
-
equals
-
hashCode
public int hashCode()
-