Class CurrentState

java.lang.Object
it.polimi.ingsw.gc14.Model.GamePackage.CurrentState
All Implemented Interfaces:
Serializable

public class CurrentState extends Object implements Serializable
Represents the current state of the game. A CurrentState object stores the current player, slot, era, round, remaining upper and lower cards, and the current game stage.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
    The current era of the game.
    private GameStages
    The current stage of the game.
    private int
    The number of lower cards currently available.
    private int
    The number of upper cards currently available.
    private Player
    The current player associated with the game state.
    private int
    The current round of the game.
    private Slot
    The current slot associated with the game state.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new CurrentState object with default initial values.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Increments the current era by 1.
    void
    Updates the current game stage.
    Returns the current player.
    int
    Returns the current era of the game.
    Returns the current stage of the game.
    int
    Returns the number of lower cards currently available.
    int
    Returns the number of upper cards currently available.
    int
    Returns the current round of the game.
    Returns the current slot.
    void
    Decrements the number of lower cards by 1.
    void
    playerUpdate(Player player, Slot slot)
    Updates the current player, slot, and available draws.
    void
    Increments the current round by 1.
    Returns a formatted ASCII table representation of the current game state.
    void
    Decrements the number of upper cards by 1.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • player

      private Player player
      The current player associated with the game state.
    • slot

      private Slot slot
      The current slot associated with the game state.
    • era

      private int era
      The current era of the game.
    • round

      private int round
      The current round of the game.
    • nUpper

      private int nUpper
      The number of upper cards currently available.
    • nLower

      private int nLower
      The number of lower cards currently available.
    • gameStage

      private GameStages gameStage
      The current stage of the game.
  • Constructor Details

    • CurrentState

      public CurrentState()
      Creates a new CurrentState object with default initial values. The initial player and slot are null, the era and round are set to 1, the number of upper and lower cards is set to 0, and the game stage is set to WAITING.
  • Method Details

    • getCurrentPlayer

      public Player getCurrentPlayer()
      Returns the current player.
      Returns:
      the current player.
    • getSlot

      public Slot getSlot()
      Returns the current slot.
      Returns:
      the current slot.
    • getEra

      public int getEra()
      Returns the current era of the game.
      Returns:
      the current era of the game.
    • getRound

      public int getRound()
      Returns the current round of the game.
      Returns:
      the current round of the game.
    • getNUpper

      public int getNUpper()
      Returns the number of upper cards currently available.
      Returns:
      the number of upper cards currently available.
    • getNLower

      public int getNLower()
      Returns the number of lower cards currently available.
      Returns:
      the number of lower cards currently available.
    • getGameStage

      public GameStages getGameStage()
      Returns the current stage of the game.
      Returns:
      the current stage of the game.
    • eraUpdate

      public void eraUpdate()
      Increments the current era by 1.
    • roundUpdate

      public void roundUpdate()
      Increments the current round by 1.
    • upperDrawn

      public void upperDrawn()
      Decrements the number of upper cards by 1.
    • lowerDrawn

      public void lowerDrawn()
      Decrements the number of lower cards by 1.
    • gameStageUpdate

      public void gameStageUpdate(GameStages stage)
      Updates the current game stage.
      Parameters:
      stage - the new game stage.
    • playerUpdate

      public void playerUpdate(Player player, Slot slot)
      Updates the current player, slot, and available draws. If slot is null, both nUpper and nLower are reset to 0. Otherwise, they are set from the slot's values.
      Parameters:
      player - the new current player.
      slot - the new current slot, or null when no slot is active.
    • toString

      public String toString()
      Returns a formatted ASCII table representation of the current game state. Columns: Player, Round, Era, GameStage.
      Overrides:
      toString in class Object
      Returns:
      a String containing the ASCII table.