Class: Table
- Inherits:
-
Object
- Object
- Table
- Defined in:
- lib/table.rb
Overview
A Table is where players come to play a game (possibly as part of a match as part of a tournament if required) Essentially a Table is a Game Controller
Instance Attribute Summary collapse
-
#games ⇒ Object
readonly
Returns the value of attribute games.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
-
#quiet ⇒ Object
Returns the value of attribute quiet.
Instance Method Summary collapse
-
#initialize(game, players) ⇒ Table
constructor
A new instance of Table.
- #play_game ⇒ Object
Constructor Details
#initialize(game, players) ⇒ Table
Returns a new instance of Table.
7 8 9 10 |
# File 'lib/table.rb', line 7 def initialize game, players @game = game @players = players end |
Instance Attribute Details
#games ⇒ Object (readonly)
Returns the value of attribute games.
4 5 6 |
# File 'lib/table.rb', line 4 def games @games end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
4 5 6 |
# File 'lib/table.rb', line 4 def players @players end |
#quiet ⇒ Object
Returns the value of attribute quiet.
5 6 7 |
# File 'lib/table.rb', line 5 def quiet @quiet end |
Instance Method Details
#play_game ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/table.rb', line 12 def play_game until @game.won? || @game.drawn? next_player = @players[@game.next_player] move = next_player.get_move @game.current_position, @game.move_list unless @quiet p "player #{@game.next_player} plays move #{move }" end @game.play_move @game.next_player, move end end |