Class: Gemwarrior::Locker
- Defined in:
- lib/gemwarrior/entities/items/locker.rb
Instance Attribute Summary collapse
-
#locked ⇒ Object
Returns the value of attribute locked.
Attributes inherited from Item
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
-
#initialize ⇒ Locker
constructor
A new instance of Locker.
- #use(world) ⇒ Object
Methods inherited from Item
Methods inherited from Entity
Constructor Details
#initialize ⇒ Locker
Returns a new instance of Locker.
10 11 12 13 14 15 16 17 18 |
# File 'lib/gemwarrior/entities/items/locker.rb', line 10 def initialize super self.name = 'locker' self.name_display = 'Locker' self.description = 'A small, locked locker with a lock on it. You will need to unlock it to gain access to its insides.' self.takeable = false self.locked = true end |
Instance Attribute Details
#locked ⇒ Object
Returns the value of attribute locked.
8 9 10 |
# File 'lib/gemwarrior/entities/items/locker.rb', line 8 def locked @locked end |
Instance Method Details
#use(world) ⇒ Object
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/locker.rb', line 20 def use(world) cur_location = world.location_by_coords(world.player.cur_coords) locker = cur_location.get_item_ref('locker') if locker.locked puts 'You pull on the lock, hoping it will unlock and leave the locker unlocked, but it is no good. You will need something else to unlock this locked locker.' return { type: nil, data: nil } else if self.used puts 'The locker is open and you can see a shiny gem inside.' return { type: nil, data: nil } else self.used = true puts 'You open the unlocked locker and look inside. Thereabouts, is a shiny gem of some sort.' cur_location.add_item('sand_jewel') return { type: nil, data: nil } end end end |