Class: GooseGame::Cell::Goose

Inherits:
Base
  • Object
show all
Defined in:
lib/goose_game/cell.rb

Instance Attribute Summary

Attributes inherited from Base

#gameboard, #num

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_s

Constructor Details

This class inherits a constructor from GooseGame::Cell::Base

Instance Method Details

#call(player, dice) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
# 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