Class: GooseGame::GamePlay

Inherits:
Object
  • Object
show all
Includes:
Messages
Defined in:
lib/goose_game/gameplay.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#diceObject (readonly)

Returns the value of attribute dice.



10
11
12
# File 'lib/goose_game/gameplay.rb', line 10

def dice
  @dice
end

#gameboardObject (readonly)

Returns the value of attribute gameboard.



10
11
12
# File 'lib/goose_game/gameplay.rb', line 10

def gameboard
  @gameboard
end

#playersObject (readonly)

Returns the value of attribute players.



10
11
12
# File 'lib/goose_game/gameplay.rb', line 10

def players
  @players
end

#round_playerObject (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

#callObject



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