Class: Game
- Inherits:
-
Object
- Object
- Game
- Defined in:
- lib/game.rb
Overview
require ‘board’
Direct Known Subclasses
Instance Attribute Summary collapse
-
#game_state ⇒ Object
Returns the value of attribute game_state.
-
#players ⇒ Object
Returns the value of attribute players.
Instance Method Summary collapse
- #active_player_class ⇒ Object
- #check_win ⇒ Object
-
#initialize ⇒ Game
constructor
A new instance of Game.
- #switch_active_player ⇒ Object
Constructor Details
#initialize ⇒ Game
Returns a new instance of Game.
6 7 8 |
# File 'lib/game.rb', line 6 def initialize @players = {:one => nil, :two => nil} end |
Instance Attribute Details
#game_state ⇒ Object
Returns the value of attribute game_state.
4 5 6 |
# File 'lib/game.rb', line 4 def game_state @game_state end |
#players ⇒ Object
Returns the value of attribute players.
4 5 6 |
# File 'lib/game.rb', line 4 def players @players end |
Instance Method Details
#active_player_class ⇒ Object
22 23 24 |
# File 'lib/game.rb', line 22 def active_player_class @game_state.active_player_class end |
#check_win ⇒ Object
18 19 20 |
# File 'lib/game.rb', line 18 def check_win @game_state.check_win end |
#switch_active_player ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/game.rb', line 10 def switch_active_player if @game_state.active_player == @players[:one] @game_state.active_player = @players[:two] elsif @game_state.active_player == @players[:two] @game_state.active_player = @players[:one] end end |