Class: Jewel

Inherits:
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 Exist

Exist::GETTER, Exist::PATTERN

Instance Attribute Summary collapse

Attributes inherited from Item

#container

Attributes inherited from Exist

#gameobj, #id

Instance Method Summary collapse

Methods inherited from Item

fetch, #held?, #initialize, of, #stash, #take, #to_json, #transaction, #use, #worn?

Methods inherited from Exist

#==, #deconstruct_keys, #effects, #exists?, #fetch, fetch, #gone?, #initialize, #method_missing, normalize_type_data, #respond_to_missing?, scan, #tags, #to_h, #to_s

Constructor Details

This class inherits a constructor from Item

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Exist

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, /#{Dictionary.gems[:appraise].values.join('|')}/
  case result
    when Dictionary.gems[:appraise][:gemshop]
      # handle gemshop appraisal
      @value = $1.to_i
    when Dictionary.gems[:appraise][:player]
      @value = $3.to_i
      @quality = $2
    when 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
  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 =~ Dictionary.get[:success]
end