Class: Monotony::Station

Inherits:
PurchasableProperty show all
Defined in:
lib/monotony/station.rb

Overview

Represents a railway station tile.

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

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) ⇒ Station

Returns a new instance of Station.

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :name (String)

    the name of the station.

  • :colour (Symbol)

    the colour to use when rendering this square on a GUI.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/monotony/station.rb', line 10

def initialize(opts)
  super
  @set = :stations
  @action = Proc.new do |game, owner, player, property|
    if owner
      rent = [ 25, 50, 100, 200 ]
      multiplier = owner.properties.select { |p| p.is_a? Station }.count
      player.pay(owner, rent[multiplier - 1])
    else
      player.behaviour[:purchase_possible].call(game, player, self) if player.currency >= cost
    end
  end
end