Class: Baron::Turn

Inherits:
Object
  • Object
show all
Defined in:
lib/baron/turn.rb,
lib/baron/turn/wrong_turn.rb,
lib/baron/turn/stock_turn.rb,
lib/baron/turn/operating_turn.rb,
lib/baron/turn/winner_choose_auction.rb

Overview

An turn is a group of a set of actions taken in a game

It will be triggered by an event of some sort and will include things like the following:

  • An auction of one private company

  • A players share action turn composed of buy and sell actions

  • A single company's turn turn during an operating round

Direct Known Subclasses

OperatingTurn, StockTurn, WinnerChooseAuction

Defined Under Namespace

Classes: InvalidActionError, OperatingTurn, StockTurn, WinnerChooseAuction, WrongTurn

Instance Method Summary collapse

Instance Method Details

#available_actionsArray<Baron::Action>

Returns a list of actions that the player can take

Examples:

turn.available_actions

Returns:


35
36
37
# File 'lib/baron/turn.rb', line 35

def available_actions
  fail NotImplementedError
end

#perform(action) ⇒ void

This method returns an undefined value.

Performs the action listed

Examples:

turn.perform(action)

Parameters:


20
21
22
23
24
25
26
# File 'lib/baron/turn.rb', line 20

def perform(action)
  action_method = action.symbol
  validate(action)
  action.process
  public_send(action_method, action)
  taken_actions << action
end

#playerBaron::Player

The player whose turn it is

This should be implemented by all classes which inherit from turn

Examples:

turn.player

Returns:


48
49
50
# File 'lib/baron/turn.rb', line 48

def player
  fail NotImplementedError
end