Class: Baron::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/baron/action.rb,
lib/baron/action/bid.rb,
lib/baron/action/done.rb,
lib/baron/action/pass.rb,
lib/baron/action/payout.rb,
lib/baron/action/retain.rb,
lib/baron/action/buy_train.rb,
lib/baron/action/run_trains.rb,
lib/baron/action/place_tile.rb,
lib/baron/action/place_token.rb,
lib/baron/action/start_company.rb,
lib/baron/action/company_action.rb,
lib/baron/action/buy_certificate.rb,
lib/baron/action/sell_certificates.rb,
lib/baron/action/illegal_bid_amount.rb,
lib/baron/action/select_certificate.rb,
lib/baron/action/non_available_action.rb

Overview

The base class for all actions. Actions should inherit from this class.

Defined Under Namespace

Classes: Bid, BuyCertificate, BuyTrain, CompanyAction, Done, IllegalBidAmount, NonAvailableAction, Pass, Payout, PlaceTile, PlaceToken, Retain, RunTrains, SelectCertificate, SellCertificates, StartCompany

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(player) ⇒ Action

Create the action

Examples:

Baron::Action.new(player)

21
22
23
# File 'lib/baron/action.rb', line 21

def initialize(player)
  @player = player
end

Instance Attribute Details

#playerBaron::Player (readonly)

The player who has taken this action

Examples:

action.player

12
13
14
# File 'lib/baron/action.rb', line 12

def player
  @player
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.

Execute any additional logic for this action

This can be overridden by child classes in order to perform additional operations after the action has been validated.


42
43
# File 'lib/baron/action.rb', line 42

def process
end

#symbolSymbol

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.

Returns a symbol representation of this action

This is used to determine how to delegate the methods within the turn


31
32
33
# File 'lib/baron/action.rb', line 31

def symbol
  self.class.name.split('::').last.downcase.to_sym
end