Class: Monotony::Utility
- Inherits:
-
PurchasableProperty
- Object
- Square
- PurchasableProperty
- Monotony::Utility
- Defined in:
- lib/monotony/utility.rb
Overview
Represents a utility tile, such as the Electricity Company or Water Works.
Instance Attribute Summary
Attributes inherited from PurchasableProperty
#cost, #is_mortgaged, #mortgage_value, #owner, #value
Attributes inherited from Square
#action, #colour, #name, #owner, #set
Instance Method Summary collapse
-
#initialize(opts) ⇒ Utility
constructor
A new instance of Utility.
Methods inherited from PurchasableProperty
#give_to, #is_mortgaged?, #mortgage, #number_in_set, #number_of_set_owned, #place_offer, #properties_in_set, #sell_to, #set_owned?, #unmortgage
Constructor Details
#initialize(opts) ⇒ Utility
Returns a new instance of Utility.
10 11 12 13 14 15 16 17 18 19 20 21 |
# 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 |