Class: Goby::Chest
Overview
A chest containing gold and/or items.
Constant Summary
Constants inherited from Event
Instance Attribute Summary collapse
-
#gold ⇒ Object
readonly
Returns the value of attribute gold.
-
#treasures ⇒ Object
readonly
Returns the value of attribute treasures.
Attributes inherited from Event
Instance Method Summary collapse
-
#initialize(mode: 0, visible: true, gold: 0, treasures: []) ⇒ Chest
constructor
A new instance of Chest.
-
#run(player) ⇒ Object
The function that runs when the player opens the chest.
Methods inherited from Event
Constructor Details
#initialize(mode: 0, visible: true, gold: 0, treasures: []) ⇒ Chest
Returns a new instance of Chest.
12 13 14 15 16 17 |
# File 'lib/goby/event/chest.rb', line 12 def initialize(mode: 0, visible: true, gold: 0, treasures: []) super(mode: mode, visible: visible) @command = "open" @gold = gold @treasures = treasures end |
Instance Attribute Details
#gold ⇒ Object (readonly)
Returns the value of attribute gold.
29 30 31 |
# File 'lib/goby/event/chest.rb', line 29 def gold @gold end |
#treasures ⇒ Object (readonly)
Returns the value of attribute treasures.
29 30 31 |
# File 'lib/goby/event/chest.rb', line 29 def treasures @treasures end |
Instance Method Details
#run(player) ⇒ Object
The function that runs when the player opens the chest.
22 23 24 25 26 27 |
# File 'lib/goby/event/chest.rb', line 22 def run(player) type("You open the treasure chest...\n\n") sleep(1) unless ENV['TEST'] player.add_loot(@gold, @treasures) @visible = false end |