Class: XO::GameOver

Inherits:
GameState
  • Object
show all
Defined in:
lib/xo/engine/game_over.rb

Instance Method Summary collapse

Instance Method Details

#continue_playingObject

Starts another new game.

The token that won plays first, otherwise the game was squashed and so the next token plays first.

The engine is transitioned into the Playing state and the event

{ name: :game_started, type: :continue_playing }

is triggered.



28
29
30
31
# File 'lib/xo/engine/game_over.rb', line 28

def continue_playing
  game_context.set_turn_and_clear_grid(game_context.turn)
  engine.transition_to_state_and_send_event(Playing, :game_started, type: :continue_playing)
end

#stopObject

Stops and resets a game.

The engine is transitioned into the Init state and the event

{ name: :game_stopped }

is triggered.



14
15
16
# File 'lib/xo/engine/game_over.rb', line 14

def stop
  stop_game
end