Interface GameModelIF

All Known Implementing Classes:
GameModel

public interface GameModelIF
Immutable version of GameModel class.
It is used to provide a read-only version of the game status to the view, by providing only the necessary methods to fetch the data.
  • Method Details

    • getGameId

      int getGameId()
      Returns:
      Unique number indicating the actual game model (hence the game/match to its all entirety)
    • fetchPlayersLobby

      List<PlayerLobby> fetchPlayersLobby()
      Returns:
      List of players, decontextualized from game (their nicknames/tokens, nothing else)
    • fetchPlayers

      List<PlayerIF> fetchPlayers()
      Returns:
      List of players. The order is the one followed in a round, from the first player to the last one
    • fetchFirstPlayer

      PlayerLobby fetchFirstPlayer()
      The first player of the match is the one that will do the first play of the card in phase IN_GAME
      Returns:
      The first player of the match
    • fetchCurrentPlayer

      PlayerLobby fetchCurrentPlayer()
      Returns:
      the player who is playing in the current turn. Null if the game phase is different from IN_GAME or FINAL_PHASE (the 2 phases divided in turns)
    • fetchGameStatus

      GameStatus fetchGameStatus()
      Returns:
      the status of the game. See class GameStatus for more details
    • fetchPoints

      Map<PlayerLobby,Integer> fetchPoints()
      Returns:
      A map of points accumalated till this point for each player. If the turn-bases phases haven't started yet, the points will be 0
    • fetchPickables

      List<CardPlayableIF> fetchPickables()
      List of all visible cards (that are pickable during turn phases). The list is of size 6, with order: top of deck (with getVisibleSide()==Side.SIDEBACK), and 2 visible cards (with getVisibleSide()==Side.SIDEFRONT), and repetion of this. Elements can be null. If a deck is empty but both its cards are present, only the first element of the set of 3 will be null. Besides this first element of the set, also one or both of the other ones can be null (if it remains only one or no cards of this type to be picked)
      Returns:
      a new list containing the 6 cards on the table that can be picked by players The order: top of resource deck, 2 visible resource cards, top of gold deck, 2 visible gold cards
    • fetchCommonObjectives

      List<CardObjectiveIF> fetchCommonObjectives()
      Returns the visible cards for the common objectives. Note that the deck of objective cards is always visible, with top card visible from its back side. Hence, this information is not included in the list
      Returns:
      the list of the 2 common objectives.
    • fetchPersonalObjectives

      Method callable only during INIT phase. Returns the 2 possible objective cards the player can choose
      Parameters:
      player - who should be contained in players
      Returns:
      a list containing the two objective cards the player can choose from
      Throws:
      GameStatusException - if this method isn't called in the INIT phase
      InvalidPlayerException - if the player is not one of the players of this match
    • fetchStarter

      CardStarterIF fetchStarter(PlayerLobby player) throws InvalidPlayerException
      Parameters:
      player - One of the players of the match
      Returns:
      The starter card assigned to player. Null if player has not been assigned a starter card yet
      Throws:
      InvalidPlayerException - If the player is not among the playing players in the match
    • fetchHandPlayable

      List<CardPlayableIF> fetchHandPlayable(PlayerLobby player) throws InvalidPlayerException
      Parameters:
      player - one of the players of the match
      Returns:
      the cards in the hand of the player. The list if empty if player has no cards yet
      Throws:
      InvalidPlayerException - if the player is not one of the players of the match
    • fetchHandObjective

      CardObjectiveIF fetchHandObjective(PlayerLobby player) throws InvalidPlayerException
      Parameters:
      player - one of the players of the match
      Returns:
      the personal objective of the player. Null if it hasn't been initialized yet
      Throws:
      InvalidPlayerException - if the passed player is not one of the players of the match
    • fetchAvailableCoord

      List<Coordinates> fetchAvailableCoord(PlayerLobby player) throws InvalidPlayerException
      Returns:
      the List of coordinates in which new cards can be played If game has not started yet, the list is empty
      Throws:
      InvalidPlayerException - If player is not among this match's players
    • fetchPlayerField

      FieldIF fetchPlayerField(PlayerLobby player) throws InvalidPlayerException
      Parameters:
      player - Player whose field is returned
      Returns:
      Field (interface) of the given player
      Throws:
      InvalidPlayerException - If the player is not among the playing players in the match
    • fetchWinner

      List<PlayerLobby> fetchWinner()
      Returns:
      Winner of the game if the phase is ENDED, null otherwise