Class: Monotony::Square

Inherits:
Object
  • Object
show all
Defined in:
lib/monotony/square.rb

Overview

Represents any landable square on the board.

Direct Known Subclasses

Chance, CommunityChest, PurchasableProperty

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Square

Returns a new instance of Square.

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :set (Symbol)

    a symbol identifying this property as a member of a set of properties.

  • :name (String)

    the name of the property.

  • :action (Proc)

    a procedure to run when a player lands on this square.

  • :colour (Symbol)

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



15
16
17
18
19
20
21
# File 'lib/monotony/square.rb', line 15

def initialize(opts)
	@owner = nil
	@set = opts[:set] || nil
	@name = opts[:name]
	@action = opts[:action] || Proc.new {|game, owner, player, property|}
	@colour = opts[:colour] || ( String.colors.include? opts[:set] ? opts[:set] : :light_black )
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



5
6
7
# File 'lib/monotony/square.rb', line 5

def action
  @action
end

#colourObject

Returns the value of attribute colour.



5
6
7
# File 'lib/monotony/square.rb', line 5

def colour
  @colour
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/monotony/square.rb', line 5

def name
  @name
end

#ownerObject

Returns the value of attribute owner.



5
6
7
# File 'lib/monotony/square.rb', line 5

def owner
  @owner
end

#setSymbol

Returns the name of the set containing this property.

Returns:

  • (Symbol)

    Returns the name of the set containing this property.



8
9
10
# File 'lib/monotony/square.rb', line 8

def set
  @set
end