class GooseGame::Cell::Goose

Public Instance Methods

call(player, dice) click to toggle source
Calls superclass method GooseGame::Cell::Base#call
# File lib/goose_game/cell.rb, line 75
def call(player, dice)
  tokens = []
  super.tap do |pos|
    while goose?(pos)
      pos += dice.to_i
      tokens << "The Goose. #{player} moves again and goes to #{pos}"
    end
    @tokens << tokens.join(", ")
    player.position = pos
    return pos
  end
end

Private Instance Methods

goose?(n) click to toggle source
# File lib/goose_game/cell.rb, line 88
        def goose?(n)
  gameboard[n].instance_of? Goose
end