Class Archipelago

java.lang.Object
it.polimi.ingsw.server.model.game_logic.Archipelago
All Implemented Interfaces:
ArchipelagoCommonInterface
Direct Known Subclasses:
ExpertArchipelago

public class Archipelago extends Object implements ArchipelagoCommonInterface
This class generalizes the concept of island: an island is an archipelago with a single island and multiple archipelagos merge into a single archipelago
  • Field Details

  • Constructor Details

  • Method Details

    • merge

      public boolean merge(Archipelago a2)
      This method merges two archipelagos
      Parameters:
      a2 - second archipelago to be merged
      Returns:
      an Archipelago that has first islandCodes + second islandCodes and the sum of the students of the two archipelagos
    • getStudents

      public List<Color> getStudents()
      This method returns a list containing all the students on the archipelago
      Returns:
      a list containing all the students on the archipelago
    • getStudentToNumber

      public Map<Color,Integer> getStudentToNumber()
      This method returns a map that maps every student color with the number of its occurrence on the archipelago
      Returns:
      a map that maps every student color with the number of its occurrence on the archipelago
    • addStudent

      public void addStudent(Color student)
      Adds a student to the archipelago
      Parameters:
      student - any student
      Throws:
      IllegalArgumentException - if(student == null)
    • getInfluence

      public int getInfluence(Set<Color> playerProfessors, TowerColor playerTowerColor)
      Parameters:
      playerProfessors - a set containing all the color of the professors owned by the player
      playerTowerColor - the color of the towers owned by the player
      Returns:
      an int representing the value of the player's influence on this archipelago
      Throws:
      IllegalArgumentException - if the arguments representing the set of professors owned by the player is null or playerProfessors contains null or the argument representing the color of the player's tower is null or the argument representing the color of the player's tower is TowerColor.NONE
    • getTowersInfluence

      protected int getTowersInfluence(TowerColor playerTowerColor)
      This method returns the influence given by the towers of the inputted tower color on the archipelago
      Parameters:
      playerTowerColor - is the tower color
      Returns:
      the influence given by the towers of a certain color on the archipelago
    • getStudentsInfluence

      protected int getStudentsInfluence(Set<Color> playerProfessors)
      This method returns the influence on the archipelago given by the students that are on it
      Parameters:
      playerProfessors - is a Set representing the professors owned by a certain player
      Returns:
      the influence on the archipelago given by the students
    • getIslandCodes

      public List<Integer> getIslandCodes()
      This method returns the island codes of the archipelago
      Returns:
      a list containing the island codes of the archipelago
    • setTowerColor

      public void setTowerColor(TowerColor towerColor)
      Sets the towerColor of this archipelago
      Throws:
      IllegalArgumentException - if(towerColor == null)
    • getTowerColor

      public TowerColor getTowerColor()
      This method returns the color of the tower(s) on the archipelago
      Returns:
      the tower color of the tower(s) on the archipelago
    • removeStudent

      public void removeStudent(Color student)
      This method removes a student from the archipelago
      Parameters:
      student - is the student that has to be removed from the archipelago
    • equals

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

      public LightArchipelago lightify()
      This method returns the light version of the archipelago to be sent over the network
      Returns:
      a LightArchipelago comprising all the relevant information that make up the archipelago