Record Class GameSessionState

java.lang.Object
java.lang.Record
it.unisa.diem.wordageddon_g16.models.GameSessionState
Record Components:
user - L'utente a cui appartiene la sessione
questions - Lista delle domande generate
domandaRisposte - Mappa domanda --> risposta data (-1 se saltata)
currentQuestionIndex - Indice della domanda attuale
questionStartTime - Istante d'inizio delle domande (può essere null se non usato)
All Implemented Interfaces:
Serializable

public record GameSessionState(User user, List<Question> questions, Map<Question,Integer> domandaRisposte, int currentQuestionIndex, LocalDateTime questionStartTime, int scorePerQuestion, GameParams gameParams) extends Record implements Serializable
Rappresenta lo stato temporaneo di una sessione di gioco interrotta in Wordageddon.

Questa record viene serializzato per permettere il salvataggio e il recupero preciso della partita nel punto in cui l'utente ha interrotto.

See Also:
  • Field Details

    • user

      private final User user
      The field for the user record component.
    • questions

      private final List<Question> questions
      The field for the questions record component.
    • domandaRisposte

      private final Map<Question,Integer> domandaRisposte
      The field for the domandaRisposte record component.
    • currentQuestionIndex

      private final int currentQuestionIndex
      The field for the currentQuestionIndex record component.
    • questionStartTime

      private final LocalDateTime questionStartTime
      The field for the questionStartTime record component.
    • scorePerQuestion

      private final int scorePerQuestion
      The field for the scorePerQuestion record component.
    • gameParams

      private final GameParams gameParams
      The field for the gameParams record component.
    • serialVersionUID

      private static final long serialVersionUID
      See Also:
  • Constructor Details

    • GameSessionState

      public GameSessionState(User user, List<Question> questions, Map<Question,Integer> domandaRisposte, int currentQuestionIndex, LocalDateTime questionStartTime, int scorePerQuestion, GameParams gameParams)
      Creates an instance of a GameSessionState record class.
      Parameters:
      user - the value for the user record component
      questions - the value for the questions record component
      domandaRisposte - the value for the domandaRisposte record component
      currentQuestionIndex - the value for the currentQuestionIndex record component
      questionStartTime - the value for the questionStartTime record component
      scorePerQuestion - the value for the scorePerQuestion record component
      gameParams - the value for the gameParams record component
  • Method Details

    • user

      public User user()
      Returns the value of the user record component.
      Returns:
      the value of the user record component
    • questions

      public List<Question> questions()
      Returns the value of the questions record component.
      Returns:
      the value of the questions record component
    • domandaRisposte

      public Map<Question,Integer> domandaRisposte()
      Returns the value of the domandaRisposte record component.
      Returns:
      the value of the domandaRisposte record component
    • currentQuestionIndex

      public int currentQuestionIndex()
      Returns the value of the currentQuestionIndex record component.
      Returns:
      the value of the currentQuestionIndex record component
    • questionStartTime

      public LocalDateTime questionStartTime()
      Returns the value of the questionStartTime record component.
      Returns:
      the value of the questionStartTime record component
    • scorePerQuestion

      public int scorePerQuestion()
      Returns the value of the scorePerQuestion record component.
      Returns:
      the value of the scorePerQuestion record component
    • gameParams

      public GameParams gameParams()
      Returns the value of the gameParams record component.
      Returns:
      the value of the gameParams record component
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.