Class IslandGroup

java.lang.Object
it.polimi.ingsw.eriantys.model.StudentContainer
it.polimi.ingsw.eriantys.model.IslandGroup

public class IslandGroup extends StudentContainer
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 Details

    • IslandGroup

      public IslandGroup(String id)
      Constructs a new IslandGroup with the specified id, containing no students neither no-entry tiles, and with no controller.
      Parameters:
      id - the new island's id
  • Method Details

    • merge

      Merges i1 and i2 and returns the resulting IslandGroup.
      Parameters:
      i1 - the first of the islands to merge
      i2 - the second of the islands to merge
      Returns:
      an IslandGroup containing all and only the single islands previously contained in i1 and i2, and with the same controller as them
      Throws:
      IncompatibleControllersException - if i1 and i2 are controlled by different Players
    • getId

      public String getId()
      A getter for the island's id.
      Returns:
      the island's id
    • getController

      public Player getController()
      A getter for the island's controller.
      Returns:
      the island's controller
    • setController

      public void setController(Player newController)
      Sets the island's controller to newController, unless it is null, in which case the controller stays the same.
      Parameters:
      newController - the island's new controller
    • getTowers

      public int getTowers()
      A getter for the number of towers on the IslandGroup.
      Returns:
      the number of towers on the IslandGroup
    • putNoEntryTile

      public void putNoEntryTile(int id) throws DuplicateNoEntryTileException
      Places a no-entry tile on the IslandGroup, unless there already is a no-entry tile with the same id on it.
      Parameters:
      id - the no-entry tile's identifier
      Throws:
      DuplicateNoEntryTileException - if there already is a no-entry tile with the specified id on the island
    • popNoEntryTile

      public Integer popNoEntryTile()
      Removes the latest no-entry tile to be placed on the IslandGroup and returns its id. If there are no such tiles on the island, returns null.
      Returns:
      the id of the latest no-entry tile to be added, or null if there are no such tiles on the island
    • getSize

      public Integer getSize()
      A helper-getter method to fulfill the BoardStatus creation process.
      Returns:
      a representation for the number of islands which form the aggregate
    • getNoEntryTiles

      public Integer getNoEntryTiles()
      A helper-getter method to fulfill the BoardStatus creation process.
      Returns:
      a representation for the number of no-entry tiles placed on the aggregate
    • getComponents

      protected List<String> getComponents()
      A getter for the list of the ids of the single islands components of an IslandGroup.
      Returns:
      a list of the ids of the single islands making up this IslandGroup
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object