Sha256: b672603bd205534e2e79c84ebd5970cc21ffc49575ca2c39e08b400a0bdc36fc

Contents?: true

Size: 1.27 KB

Versions: 21

Compression:

Stored size: 1.27 KB

Contents

# lib/gemwarrior/entities/items/locker.rb
# Entity::Item::Locker

require_relative '../item'

module Gemwarrior
  class Locker < Item
    attr_accessor :locked
  
    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

    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
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
gemwarrior-0.15.20 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.19 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.18 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.17 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.16 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.15 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.14 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.13 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.12 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.11 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.10 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.9 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.8 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.7 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.6 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.5 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.4 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.3 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.2 lib/gemwarrior/entities/items/locker.rb
gemwarrior-0.15.1 lib/gemwarrior/entities/items/locker.rb