Sha256: 0e62de49afbc73d45f172dae9ceb745185ed660f2da8ccde97d3537beb8a342f

Contents?: true

Size: 703 Bytes

Versions: 2

Compression:

Stored size: 703 Bytes

Contents

require 'monotony/square'
require 'monotony/purchasable'

module Monotony
	# Represents a utility tile, such as the Electricity Company or Water Works.
	class Utility < PurchasableProperty

		# @param opts [Hash]
		# @option opts [String] :name A symbol identifying this property as a member of a set of properties.
		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
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
monotony-0.0.2 lib/monotony/utility.rb
monotony-0.0.1 lib/monotony/utility.rb