Class SchoolBoard

java.lang.Object
it.polimi.ingsw.server.model.game_logic.SchoolBoard
All Implemented Interfaces:
SchoolBoardCommonInterface
Direct Known Subclasses:
ExpertSchoolBoard

public class SchoolBoard extends Object implements SchoolBoardCommonInterface
  • Field Details

    • id

      protected final int id
    • diningRoomLaneColorToNumberOfStudents

      protected final Map<Color,Integer> diningRoomLaneColorToNumberOfStudents
    • towerColor

      protected final TowerColor towerColor
    • studentsInTheEntrance

      protected final List<Color> studentsInTheEntrance
    • professorsTable

      protected final Set<Color> professorsTable
    • deck

      protected final List<Card> deck
  • Constructor Details

    • SchoolBoard

      public SchoolBoard(int id, List<Color> studentsInTheEntrance, TowerColor towerColor)
      Parameters:
      id - must be a unique id for this schoolBoard in this game
      studentsInTheEntrance - students to put in the entrance of the schoolBoard
      towerColor - tower color of this schoolBoard
      Throws:
      IllegalArgumentException - if studentsInTheEntrance == null or studentsInTheEntrance contains null
    • SchoolBoard

      private SchoolBoard(int id, Map<Color,Integer> diningRoomLaneColorToNumberOfStudents, TowerColor towerColor, List<Color> studentsInTheEntrance, Set<Color> professorsTable, List<Card> deck)
  • Method Details

    • playCard

      public void playCard(Card card) throws CardIsNotInTheDeckException
      This method receives an argument of type Card and proceeds removing the corresponding card from the player's deck of playable cards.
      Parameters:
      card - the card to be played, and hence removed from the deck
      Throws:
      IllegalArgumentException - if(card == null)
      CardIsNotInTheDeckException - if the card is not contained in the deck if(!this.deck.contains(card))
    • getId

      public int getId()
      This method returns the ID associated with the schoolBoard
      Returns:
      an int representing the ID of the schoolBoard
    • isInTheEntrance

      public boolean isInTheEntrance(Color student)
      Returns:
      true if at least a student of the given color is in the entrance of the school board, false otherwise
      Throws:
      IllegalArgumentException - if(student == null)
    • moveFromEntranceToDiningRoom

      public void moveFromEntranceToDiningRoom(Color student) throws StudentNotInTheEntranceException, FullDiningRoomLaneException
      Throws:
      IllegalArgumentException - if(student == null)
      StudentNotInTheEntranceException - if the student is not in the entrance
      FullDiningRoomLaneException - if the diningRoomLane is full
    • addStudentToDiningRoom

      protected void addStudentToDiningRoom(Color student) throws FullDiningRoomLaneException
      This method adds the inputted student to the diningRoom
      Parameters:
      student - is the student that will be added to the diningRoom
      Throws:
      FullDiningRoomLaneException - if the diningRoom table corresponding to the inputted student is already full
    • removeStudentFromEntrance

      public void removeStudentFromEntrance(Color student) throws StudentNotInTheEntranceException
      Throws:
      IllegalArgumentException - if(student == null)
      StudentNotInTheEntranceException - if the student is not contained in the list representing the students in the entrance
    • addStudentToEntrance

      public void addStudentToEntrance(Color student)
      This method adds the inputted student to the entrance
      Parameters:
      student - is the student that will be added to the entrance
    • containsAllStudentsInTheEntrance

      public boolean containsAllStudentsInTheEntrance(List<Color> students)
      This method checks if the inputted list of students is a subList of the students in the entrance
      Parameters:
      students - is the list of students that have to be checked
      Returns:
      true if all the elements of the inputted list are contained in the entrance (counting duplicates), false otherwise
    • containsAllStudentsInTheDiningRoom

      public boolean containsAllStudentsInTheDiningRoom(List<Color> students)
      This method checks if the inputted list of students is a subList of the students in the diningRoom
      Parameters:
      students - is the list of students that have to be checked
      Returns:
      true if all the elements of the inputted list are contained in the diningRoom (counting duplicates), false otherwise
    • grabStudentsFromCloud

      public void grabStudentsFromCloud(List<Color> studentsGrabbed)
      Students are put in the entrance
      Parameters:
      studentsGrabbed - students grabbed from the cloud
      Throws:
      IllegalArgumentException - if(studentsGrabbed == null or studentsGrabbed contains null)
    • getProfessors

      public Set<Color> getProfessors()
      This method returns the set of professors that are controlled by the schoolBoard
      Returns:
      a set containing all the professors controlled by the schoolBoard
    • getTowerColor

      public TowerColor getTowerColor()
      This method returns the tower color of the schoolBoard
      Returns:
      the TowerColor of the schoolBoard
    • getDeck

      public List<Card> getDeck()
      Returns the deck made up by the remaining assistant cards yet to be played
      Returns:
      a list made up by the remaining assistant cards yet to be played
    • getStudentsInTheEntrance

      public List<Color> getStudentsInTheEntrance()
      Returns the list of students that are in the entrance of the schoolBoard
      Returns:
      the list of students that are in the entrance of the schoolBoard
    • addProfessor

      public void addProfessor(Color professor)
      This method adds a professor to the schoolBoard
      Parameters:
      professor - is the color representing the professor that has to be added to the schoolBoard
    • removeProfessor

      public void removeProfessor(Color professor)
      This method removes a professor from the schoolBoard
      Parameters:
      professor - is the color representing the professor that has to be removed
    • getDiningRoomLaneColorToNumberOfStudents

      public Map<Color,Integer> getDiningRoomLaneColorToNumberOfStudents()
      This method returns a map that links every diningRoom lane to the number of students that are in it
      Returns:
      a map that links every diningRoom lane to the number of students that are in it
    • lightify

      public LightSchoolBoard lightify()
      This method returns the light version of the schoolBoard, containing all the useful information that need to be sent over the network
      Returns:
      the light version of the schoolBoard, containing all the useful information that need to be sent over the network