Class: Gemwarrior::Tree

Inherits:
Item show all
Defined in:
lib/gemwarrior/entities/items/tree.rb

Instance Attribute Summary

Attributes inherited from Item

#is_armor, #is_weapon

Attributes inherited from Entity

#consumable, #describe, #describe_detailed, #description, #display_shopping_cart, #equippable, #equipped, #name, #name_display, #number_of_uses, #takeable, #talkable, #useable, #useable_battle, #used, #used_again

Instance Method Summary collapse

Methods inherited from Item

#describe_detailed

Methods inherited from Entity

#puts

Constructor Details

#initializeTree

Returns a new instance of Tree.



8
9
10
11
12
13
14
# File 'lib/gemwarrior/entities/items/tree.rb', line 8

def initialize
  super

  self.name         = 'tree'
  self.name_display = 'Tree'
  self.description  = 'A mighty representation of nature, older than your father\'s father\'s second great-uncle.'
end

Instance Method Details

#use(world) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gemwarrior/entities/items/tree.rb', line 16

def use(world)
  if self.used_again
    puts 'The tree, its trunk, and the hole in its side all seem fairly unremarkable to you now.'

    return { type: nil, data: nil }
  elsif self.used
    self.used_again = true

    Audio.play_synth(:uncover_secret)

    puts 'Looking further into the small opening in the trunk your eye catches the light glinting off a few small metallic objects.'

    cur_loc = world.location_by_name('forest-southeast')
    cur_loc.items.push(Bullet.new)
    cur_loc.items.push(Bullet.new)
    cur_loc.items.push(Bullet.new)

    return { type: nil, data: nil }
  else
    self.used = true

    puts 'Taking a passing glance into the only hole in the tree big enough for anything to exist inside, you don\'t quite see anything of value.'

    { type: nil, data: nil }
  end
end