Class Archipelago
java.lang.Object
it.polimi.ingsw.server.model.game_logic.Archipelago
- All Implemented Interfaces:
ArchipelagoCommonInterface
- Direct Known Subclasses:
ExpertArchipelago
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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateArchipelago(int code) privateArchipelago(List<Integer> islandCodes1, List<Integer> islandCodes2, Map<Color, Integer> studentToNumber1, Map<Color, Integer> studentToNumber2, TowerColor towerColor) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStudent(Color student) Adds a student to the archipelagobooleanintgetInfluence(Set<Color> playerProfessors, TowerColor playerTowerColor) This method returns the island codes of the archipelagoThis method returns a list containing all the students on the archipelagoprotected intgetStudentsInfluence(Set<Color> playerProfessors) This method returns the influence on the archipelago given by the students that are on itThis method returns a map that maps every student color with the number of its occurrence on the archipelagoThis method returns the color of the tower(s) on the archipelagoprotected intgetTowersInfluence(TowerColor playerTowerColor) This method returns the influence given by the towers of the inputted tower color on the archipelagolightify()This method returns the light version of the archipelago to be sent over the networkbooleanmerge(Archipelago a2) This method merges two archipelagosvoidremoveStudent(Color student) This method removes a student from the archipelagovoidsetTowerColor(TowerColor towerColor) Sets the towerColor of this archipelagoMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface it.polimi.ingsw.server.model.game_logic.ArchipelagoCommonInterface
isLocked, lock, setColorThatDoesntCount, setTowersInfluence, unlock
-
Field Details
-
islandCodes
-
studentToNumber
-
towerColor
-
-
Constructor Details
-
Archipelago
private Archipelago() -
Archipelago
public Archipelago(int code) -
Archipelago
-
-
Method Details
-
merge
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
This method returns a list containing all the students on the archipelago- Returns:
- a list containing all the students on the archipelago
-
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
Adds a student to the archipelago- Parameters:
student- any student- Throws:
IllegalArgumentException- if(student == null)
-
getInfluence
- Parameters:
playerProfessors- a set containing all the color of the professors owned by the playerplayerTowerColor- 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
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
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
This method returns the island codes of the archipelago- Returns:
- a list containing the island codes of the archipelago
-
setTowerColor
Sets the towerColor of this archipelago- Throws:
IllegalArgumentException- if(towerColor == null)
-
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
This method removes a student from the archipelago- Parameters:
student- is the student that has to be removed from the archipelago
-
equals
-
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
-