Class: Jewel

Inherits:
Olib::Item show all
Defined in:
lib/Olib/objects/jewel.rb

Overview

Class to interact with gems overwriting Gem is a bad idea

Constant Summary

Constants inherited from Olib::Item

Olib::Item::SOLD, Olib::Item::TYPES, Olib::Item::WORTHLESS, Olib::Item::WRONG_SHOP

Instance Attribute Summary collapse

Attributes inherited from Olib::Item

#container, #props

Attributes inherited from Olib::Gameobj_Extender

#type

Instance Method Summary collapse

Methods inherited from Olib::Item

#==, #_drag, #_inspect, #acquire_from_shop, #action, #add, #affordable?, #analyze, #buy, #buyable?, #cost, #crawl, #define, #drop, #exists?, #give, #has?, #in, #initialize, #is?, #look, #missing?, #price, #pull, #pullable?, #read, #remove, #shake, #shop_sell, #stash, #tag, #tags, #take, #tap, #to_s, #turn, type_methods, #untag, #use, #wear, #worn?

Methods inherited from Olib::Gameobj_Extender

#__extend__, #at, #echo, #initialize

Constructor Details

This class inherits a constructor from Olib::Item

Instance Attribute Details

#qualityObject

Returns the value of attribute quality


4
5
6
# File 'lib/Olib/objects/jewel.rb', line 4

def quality
  @quality
end

#valueObject

Returns the value of attribute value


4
5
6
# File 'lib/Olib/objects/jewel.rb', line 4

def value
  @value
end

Instance Method Details

#appraiseObject


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/Olib/objects/jewel.rb', line 6

def appraise
  result = dothistimeout "appraise ##{@id}", 3, /#{Olib::Dictionary.gems[:appraise].values.join('|')}/
  case result
    when Olib::Dictionary.gems[:appraise][:gemshop]
      # handle gemshop appraisal
      @value = $1.to_i
    when Olib::Dictionary.gems[:appraise][:player]
      @value = $3.to_i
      @quality = $2
    when Olib::Dictionary.gems[:appraise][:failure]
      waitrt?
      self.appraise
    else
      respond result
      Client.notify "Error during gem appraisal"
  end
end

#normalized_nameObject


24
25
26
# File 'lib/Olib/objects/jewel.rb', line 24

def normalized_name
  Olib::Dictionary.gems[:singularize].call(@name)
end

#sellObject


28
29
30
31
# File 'lib/Olib/objects/jewel.rb', line 28

def sell
  result = take
  fput "sell ##{@id}" if result =~ Olib::Dictionary.get[:success]
end