Class Board

java.lang.Object
it.polimi.ingsw.eriantys.model.Board

public class Board extends Object
This class contains the game objects that every player can interact with. It exposes methods which should generally be called by the GameManager, including one to handle the setup of the game, one to refill the cloud tiles and one to automatically check and unify islands.
  • Constructor Details

    • Board

      public Board(int cloudNumber, int cloudSize)
      Constructs a Board, initializing the islands, bag and cloud tiles. The number and capacity of the cloud tiles are constants in GameManager.
      Parameters:
      cloudNumber - the number of cloud tiles to be instantiated
      cloudSize - the size of each cloud tile
  • Method Details

    • getIsland

      public IslandGroup getIsland(String id) throws IslandNotFoundException
      Returns the IslandGroup whose id matches the specified one.
      Parameters:
      id - the requested island's identifier
      Returns:
      the IslandGroup whose id matches the specified one
      Throws:
      IslandNotFoundException - if no island matching the specified id can be found
    • getIslandNumber

      public int getIslandNumber()
      A getter for the current number of islands.
      Returns:
      the number of islands on the board
    • getMotherNatureIsland

      public IslandGroup getMotherNatureIsland()
      A getter for the IslandGroup where Mother Nature is currently located.
      Returns:
      the IslandGroup where Mother Nature is currently located, or null if Mother Nature has not been deployed yet
    • getBag

      public Bag getBag()
      A getter for the Bag of this game object.
      Returns:
      the Bag containing the student discs
    • setReturnNoEntryTile

      public void setReturnNoEntryTile(Consumer<Integer> returnTileFunction) throws InvalidArgumentException
      Sets the returnTile attribute to returnTileFunction.
      Parameters:
      returnTileFunction - the desired returnTile Consumer<Integer>
      Throws:
      InvalidArgumentException - if returnTileFunction is null
    • setup

      public void setup() throws InvalidArgumentException, NoMovementException
      Sets up the game by placing Mother Nature on a random island and placing a random student on each island, excluding the one with Mother Nature on it and the one opposite to it.
      Throws:
      InvalidArgumentException - if one or more of the islands and colors used are null
      NoMovementException - if the bag is empty
      See Also:
    • drawStudents

      public void drawStudents(int cloudIndex, Player recipient) throws InvalidArgumentException, NoMovementException
      Moves all the students on a cloud tile to the SchoolBoard entrance of the recipient.
      Parameters:
      cloudIndex - the target cloud tile's index
      recipient - the target Player
      Throws:
      InvalidArgumentException - if recipient is null or cloudIndex is out of bounds
      NoMovementException - if the cloud at index cloudIndex is empty
    • moveMotherNature

      public boolean moveMotherNature(IslandGroup destination)
      Returns true if and only if destination is a valid island, in which case the Mother Nature pawn is placed on the specified island.
      Parameters:
      destination - the desired destination for the Mother Nature pawn
      Returns:
      true if and only if destination is a valid island
    • refillClouds

      public void refillClouds() throws InvalidArgumentException, NoMovementException
      Refills the cloud tiles by taking the necessary amount of students from the bag.
      Throws:
      InvalidArgumentException - if the bag is null
      NoMovementException - if the bag does not contain enough students to fill the clouds
    • noEntryEnforced

      public boolean noEntryEnforced(IslandGroup island)
      Returns true if and only if the specified island has at least one no-entry tile on it, in which case the last added tile is removed and returned to the HerbGranny character card.
      Parameters:
      island - the IslandGroup on which the no-entry tile could be placed
      Returns:
      true if and only if the specified island has at least one no-entry tile on it
    • unifyIslands

      public void unifyIslands(IslandGroup target) throws IslandNotFoundException, InvalidArgumentException
      Checks if the island whose id matches target can be unified with any of the neighboring islands, and if so unifies them. This method should be called every time the player controlling an island changes.
      Parameters:
      target - the target island
      Throws:
      IslandNotFoundException - if the specified target cannot be found
      InvalidArgumentException - if target is null
    • getDistanceFromMotherNature

      public int getDistanceFromMotherNature(IslandGroup target)
      A getter for the steps required by Mother Nature pawn to reach the target island.
      Parameters:
      target - the destination island
      Returns:
      the number of steps required for Mother Nature to move from the island where it is currently placed to the target island
    • getIslandsRepresentation

      public List<String> getIslandsRepresentation()
      A helper-getter method to fulfill the BoardStatus creation process.
      Returns:
      a representation for the islands on the game field
    • getCloudTiles

      public Map<String,Map<String,Integer>> getCloudTiles()
      A helper-getter method to fulfill the BoardStatus creation process.
      Returns:
      a representation for the cloud tiles on the game field