class Monotony::Utility

Represents a utility tile, such as the Electricity Company or Water Works.

Public Class Methods

new(opts) click to toggle source

@param opts [Hash] @option opts [String] :name A symbol identifying this property as a member of a set of properties.

Calls superclass method Monotony::PurchasableProperty::new
# File lib/monotony/utility.rb, line 10
def initialize(opts)
        super
        @set = :utilities
        @action = Proc.new do |game, owner, player, property|
                if owner
                        rent = game.last_roll * ( owner.properties.collect { |p| p.is_a? Utility }.count == 2 ? 10 : 4 ) 
                        player.pay(owner, rent)
                else
                        player.behaviour[:purchase_possible].call(game, player, self) if player.currency >= cost
                end
        end
end