class Olib::Jar
Attributes
count[RW]
empty[RW]
full[RW]
gem[RW]
initial_count[RW]
pullable[RW]
stacked[RW]
Public Class Methods
new(item)
click to toggle source
Calls superclass method
Olib::Item::new
# File lib/Olib/objects/jar.rb, line 5 def initialize(item) super(item) @count = 0 # for empty jars @full = false @empty = false _extract self end
Public Instance Methods
_extract()
click to toggle source
# File lib/Olib/objects/jar.rb, line 14 def _extract jem = @after_name.gsub('containing', '').strip if jem != '' @gem = Gemstone_Regex.gems[:singularize].call(jem) look_result = self.look if look_result =~ /^Inside .*? you see ([0-9]+) portion/ @count = $1.to_i @initial_count = @count @full = look_result.include?('It is full') ? true : false else respond "[0lib] Oddity detected in extracting Jar data" end else @empty = true end self end
acquire()
click to toggle source
# File lib/Olib/objects/jar.rb, line 52 def acquire if pullable? result = Library.do "pull ##{@id}", /^You pull/ @stacked = true if result =~ /([0-9]+) left/ else result = Library.do "buy ##{@id}", /You hand over/ unless result =~ /^You hand over/ Client.end "[FATAL] Logic flaw, not enough coins to acquire #{@name}" end end self end
add(g)
click to toggle source
# File lib/Olib/objects/jar.rb, line 88 def add(g) result = Library.do "_drag ##{g.id} ##{@id}", /^You add|^You put|is full|does not appear to be a suitable container for|^You can't do that/ result = Library.do "put ##{g.id} in my #{@noun}", /^You add|^You put|is full|does not appear to be a suitable container for/ if result =~ /^You can't do that/ case result when /^You add .* filling it/ then inc.fill when /^You add|^You put/ then inc when /does not appear to be a suitable container for/ then return false when /is full/ then fill; return false else return false end return true end
empty?()
click to toggle source
# File lib/Olib/objects/jar.rb, line 43 def empty? @empty end
fill()
click to toggle source
# File lib/Olib/objects/jar.rb, line 83 def fill @full = true return self end
full?()
click to toggle source
# File lib/Olib/objects/jar.rb, line 39 def full? @full end
inc()
click to toggle source
# File lib/Olib/objects/jar.rb, line 78 def inc @count = @count+1 return self end
look()
click to toggle source
# File lib/Olib/objects/jar.rb, line 65 def look Library.do "look in ##{@id}", /^Inside .*? you see [0-9]+ portion|The .*? is empty./ end
pullable?()
click to toggle source
# File lib/Olib/objects/jar.rb, line 69 def pullable? unless @pullable Library.do "get ##{@id}", /^Looking closely/ result = Library.timeoutfor "You can PULL", "You'll have to buy it if you want it" if result =~ /^You can PULL/ then @pullable = true else @pullable = false end end @pullable end
shake()
click to toggle source
# File lib/Olib/objects/jar.rb, line 32 def shake result = Library.do "shake ##{@id}", /^You give your #{@noun} a hard shake|before you realize that it is empty/ @empty = true if result =~ /realize that it is empty/ return Gem_O.new(GameObj.left_hand) if GameObj.right_hand.id == @id return Gem_O.new(GameObj.right_hand) if GameObj.left_hand.id == @id end
stash()
click to toggle source
# File lib/Olib/objects/jar.rb, line 47 def stash take unless GameObj.right_hand.id == @id or GameObj.left_hand == @id Library.do "shop sell 1", /^You place your/ end