Class: Baron::Action::BuyCertificate

Inherits:
Baron::Action show all
Defined in:
lib/baron/action/buy_certificate.rb

Overview

Buy certificate allows a player to purchase a certificate from a shareholder. Usually the initial offering or the bank pool.

Direct Known Subclasses

SelectCertificate

Instance Attribute Summary collapse

Attributes inherited from Baron::Action

#player

Instance Method Summary collapse

Methods inherited from Baron::Action

#process, #symbol

Constructor Details

#initialize(player, source, certificate) ⇒ BuyCertificate

Create a buy certificate action

Examples:

Baron::Action::BuyCertificate.new(player, certificate, source)

Parameters:


25
26
27
28
29
# File 'lib/baron/action/buy_certificate.rb', line 25

def initialize(player, source, certificate)
  @player = player
  @source = source
  @certificate = certificate
end

Instance Attribute Details

#certificateBaron::Certificate (readonly)

The certificate being purchased

Examples:

action.certificate

Returns:


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

def certificate
  @certificate
end

Instance Method Details

#create_transactionBaron::Transaction

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.

Create a transaction to transfer the certificate for money

Returns:


35
36
37
38
39
40
41
42
# File 'lib/baron/action/buy_certificate.rb', line 35

def create_transaction
  Transaction.new(
    player,
    [certificate],
    @source,
    [@source.cost(certificate)]
  )
end