class Goby::Chest

A chest containing gold and/or items.

Attributes

gold[R]
treasures[R]

Public Class Methods

new(mode: 0, visible: true, gold: 0, treasures: []) click to toggle source

@param [Integer] mode convenient way for a chest to have multiple actions. @param [Boolean] visible whether the chest can be seen/activated. @param [Integer] gold the amount of gold in this chest. @param [[Item]] treasures the items found in this chest.

Calls superclass method
# 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

Public Instance Methods

run(player) click to toggle source

The function that runs when the player opens the chest.

@param [Player] player the one opening the chest.

# 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