Class: GooseGame::GamePlay
- Inherits:
-
Object
- Object
- GooseGame::GamePlay
- Includes:
- Messages
- Defined in:
- lib/goose_game/gameplay.rb
Instance Attribute Summary collapse
-
#dice ⇒ Object
readonly
Returns the value of attribute dice.
-
#gameboard ⇒ Object
readonly
Returns the value of attribute gameboard.
-
#players ⇒ Object
readonly
Returns the value of attribute players.
-
#round_player ⇒ Object
readonly
Returns the value of attribute round_player.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(players: [], gameboard: GameBoard.new, output: STDOUT) ⇒ GamePlay
constructor
A new instance of GamePlay.
Constructor Details
#initialize(players: [], gameboard: GameBoard.new, output: STDOUT) ⇒ GamePlay
Returns a new instance of GamePlay.
12 13 14 15 16 |
# File 'lib/goose_game/gameplay.rb', line 12 def initialize(players: [], gameboard: GameBoard.new, output: STDOUT) @players = players @gameboard = gameboard @output = output end |
Instance Attribute Details
#dice ⇒ Object (readonly)
Returns the value of attribute dice.
10 11 12 |
# File 'lib/goose_game/gameplay.rb', line 10 def dice @dice end |
#gameboard ⇒ Object (readonly)
Returns the value of attribute gameboard.
10 11 12 |
# File 'lib/goose_game/gameplay.rb', line 10 def gameboard @gameboard end |
#players ⇒ Object (readonly)
Returns the value of attribute players.
10 11 12 |
# File 'lib/goose_game/gameplay.rb', line 10 def players @players end |
#round_player ⇒ Object (readonly)
Returns the value of attribute round_player.
10 11 12 |
# File 'lib/goose_game/gameplay.rb', line 10 def round_player @round_player end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/goose_game/gameplay.rb', line 18 def call loop do res = play(STDIN.gets) break if res == :exit break if players.any?(&:won?) end end |