class TriviaCrack::Game
Attributes
Public: Array of available crowns that can be won by the user.
Public: The datetime on which the game was created.
Public: The datetime on which the game will expire.
Public: The current status of the game (e.g. :active, :ended, :pending_approval).
Public: The unique identifier of the game.
Public: Boolean indicating whether the game was created with a random opponent.
Public: The language used for the game (e.g. :en).
Public: The datetime on which the last turn was taken.
Public: TriviaCrack::GameStatistics
for the user.
Public: Boolean indicating whether it is the user's turn.
Public: The TriviaCrack::User
information for the opponent.
Public: TriviaCrack::GameStatistics
for the opponent.
Public: Array of questions that can be answered by the user. This array will be empty if the user is unable to play (i.e. not their turn).
Public: The number of the current round.
Public: The status version.
Public: The type of the game (:normal, :duel)
Public: Number of unread messages.
Public Class Methods
# File lib/triviacrack/game.rb, line 61 def initialize(id:, opponent: nil, game_status: nil, language: nil, created: nil, last_turn: nil, type: nil, expiration_date: nil, my_turn: nil, round_number: nil, is_random: nil, unread_messages: nil, status_version: nil, available_crowns: nil, questions: nil, my_statistics: nil, opponent_statistics: nil) @id = id @opponent = opponent @game_status = game_status @language = language @created = created @last_turn = last_turn @type = type @expiration_date = expiration_date @my_turn = my_turn @round_number = round_number @is_random = is_random @unread_messages = unread_messages @status_version = status_version @available_crowns = available_crowns @questions = questions @my_statistics = my_statistics @opponent_statistics = opponent_statistics end
Public Instance Methods
Public: Returns true if the game has not ended and it is the user's turn.
Examples
if game.playable? ... do something ... end
Returns a boolean indicating if the game is playable.
# File lib/triviacrack/game.rb, line 95 def playable? @my_turn && @game_status != :ended end