Class: Baron::Action::BuyTrain

Inherits:
CompanyAction show all
Defined in:
lib/baron/action/buy_train.rb

Overview

BuyTrain allows a company to purchase a train from either the initial offering, bank pool, or another company

Instance Attribute Summary collapse

Attributes inherited from CompanyAction

#turn

Attributes inherited from Baron::Action

#player

Instance Method Summary collapse

Methods inherited from Baron::Action

#symbol

Constructor Details

#initialize(turn, source, train, amount) ⇒ BuyTrain

Create a buy train action

purchased for. If not specified, it will be bought at face value

Examples:

Baron::Action::BuyTrain.new(company, source, train, amount)

Parameters:


27
28
29
30
31
32
# File 'lib/baron/action/buy_train.rb', line 27

def initialize(turn, source, train, amount)
  super(turn)
  @source = source
  @train = train
  @amount = amount
end

Instance Attribute Details

#trainBaron::Train (readonly)

The train being purchased

Examples:

action.train

Returns:


14
15
16
# File 'lib/baron/action/buy_train.rb', line 14

def train
  @train
end

Instance Method Details

#processvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Create a transaction to transfer the certificate for money


38
39
40
41
42
43
44
45
46
# File 'lib/baron/action/buy_train.rb', line 38

def process
  Transaction.new(
    turn.company,
    [train],
    @source,
    [@amount]
  )
  turn.game.add_next_level_of_trains
end