Olib 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9444e0a1af442c6bae2e3a598e14fd46fc425339
4
- data.tar.gz: d6b71051ce755ee9a168f1af77332bf9e99659b2
3
+ metadata.gz: 3a05957b07155806a7e7734bb11d9c5ee8747b9f
4
+ data.tar.gz: b67bd020ff43158986fc731be1191a77219c0493
5
5
  SHA512:
6
- metadata.gz: 1e70553557e7d4df9f41324efd47e518f459a1affcac8d4c91a3a5a0e41f3d3cce4d0456b0886775232fb3b47562286948a8647deac1d80959d22043e3d63449
7
- data.tar.gz: 599506fc2ce7aeb6fca4e90df8954869dbb60ee7a00ef14d9a7729e4b37873cb963c349a8cd955e1eedc8ad6e31fdb9dbb7e94df273a1cb8fa5d2e264b2d51f7
6
+ metadata.gz: 31b56fe1ef2e65c7885154dca6ffe50b86a18c9f29bb80daad5bf483f544ee10e33113b4a69fe66caab8059339faf8306b55b05243021b219dea27f322f66770
7
+ data.tar.gz: 35cce00b0592507e586b32d0833e2d85476424bd21de07ea63e88769fafc43ee46409195715c464b41fb42847b39699973e42b53930e01d9de29205a2958b616
@@ -0,0 +1,17 @@
1
+ lib = File.expand_path("../lib/", __FILE__)
2
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'Olib'
6
+ s.version = '0.0.5'
7
+ s.date = '2014-09-12'
8
+ s.summary = "Useful Lich extensions for Gemstone IV"
9
+ s.description = "Useful Lich extensions for Gemstone IV including hostile creature management, group management, syntactically pleasing movement, locker management, etc"
10
+ s.authors = ["Ondreian Shamsiel"]
11
+ s.email = 'ondreian.shamsiel@gmail.com'
12
+ s.homepage = 'https://github.com/ondreian/Olib'
13
+ s.files = %w[Olib.gemspec] + Dir['*.md', 'lib/**/*.rb']
14
+ #s.require_paths = %w[lib]
15
+ # s.add_runtime_dependency 'shoes'
16
+ s.license = 'MIT'
17
+ end
@@ -0,0 +1,21 @@
1
+ ## Olib
2
+
3
+ `gem install Olib`
4
+
5
+ This offers a lot of syntatic sugar for scripting in GS
6
+
7
+ examples:
8
+
9
+ ``` ruby
10
+ Creatures.magical.each { |creature|
11
+ creature.kill
12
+ }
13
+ ```
14
+
15
+ ``` ruby
16
+ Group.members.each { |char|
17
+ haste(char)
18
+ }
19
+ ```
20
+
21
+ Pull requests and the like as welcome.
@@ -0,0 +1,4 @@
1
+ # TODOS
2
+
3
+ + Add Documentation
4
+ + Better tagging for items
@@ -3,6 +3,17 @@ require 'json'
3
3
 
4
4
  module Olib
5
5
 
6
+
7
+ # load core first
8
+ Dir[File.dirname(__FILE__) + '/Olib/core/**/*.rb'].each {|file|
9
+ require file
10
+ }
11
+
12
+ # load things that depend on core extensions
13
+ Dir[File.dirname(__FILE__) + '/Olib/**/*.rb'].each {|file|
14
+ require file
15
+ }
16
+
6
17
  def Olib.update_notifier
7
18
  begin
8
19
  request = Net::HTTP::Get.new('/api/v1/gems/Olib.json', initheader = {'Content-Type' =>'application/json'})
@@ -31,18 +42,6 @@ module Olib
31
42
 
32
43
  Vars.Olib ||= Hash.new
33
44
 
34
- require 'Olib/group'
35
- require 'Olib/creature'
36
- require 'Olib/creatures'
37
- require 'Olib/extender'
38
- require 'Olib/transport'
39
- require 'Olib/item'
40
- require 'Olib/dictionary'
41
- require 'Olib/errors'
42
- require 'Olib/container'
43
- require "Olib/inventory"
44
- require "Olib/shops"
45
- require 'Olib/help_menu'
46
- require "Olib/utils"
45
+
47
46
 
48
47
  end
@@ -0,0 +1,52 @@
1
+ module Olib
2
+ class Bounty
3
+ @@re = {}
4
+ @@re[:herb] = /requires (?:a|an|some) ([a-zA-Z '-]+) found (?:in|on|around) ([a-zA-Z '-]+). These samples must be in pristine condition. You have been tasked to retrieve ([0-9]+)/
5
+ @@re[:escort] = /Go to the (.*?) and WAIT for (?:him|her|them) to meet you there. You must guarantee (?:his|her|their) safety to ([a-zA-Z '-]+) as soon as/
6
+ @@re[:gem] = /has received orders from multiple customers requesting (?:a|an|some) ([a-zA-Z '-]+). You have been tasked to retrieve ([0-9]+)/
7
+ @@re[:heirloom] = /You have been tasked to recover ([a-zA-Z '-]+) that an unfortunate citizen lost after being attacked by (a|an|some) ([a-zA-Z '-]+) (in|on|around|near|by) ([a-zA-Z '-]+)./
8
+ @@re[:heirloom_found] = /^You have located the heirloom and should bring it back to/
9
+ @@re[:turn_in] = /You have succeeded in your task and can return to the Adventurer's Guild to receive your reward/
10
+ @@re[:guard_turn_in] = /^You succeeded in your task and should report back to/
11
+ @@re[:guard_bounty] = /Go report to ([a-zA-Z ]+) to find out more/
12
+ @@re[:cull] = /^You have been tasked to suppress (^((?!bandit).)*$) activity (?:in|on) (?:the )? (.*?)(?: near| between| under|\.) ([a-zA-Z' ]+). You need to kill (?<n>[0-9]+)/
13
+ @@re[:bandits] = /^You have been tasked to suppress bandit activity (?:in |on )(?:the )(.*?)(?: near| between| under) ([a-zA-Z' ]+). You need to kill ([0-9]+)/
14
+ @@re[:dangerous] = /You have been tasked to hunt down and kill a particularly dangerous (.*) that has established a territory (?:in|on) (?:the )?(.*?)(?: near| between| under|\.)/
15
+ @@re[:get_skin_bounty] = /The local furrier/
16
+ @@re[:get_herb_bounty] = /local herbalist|local healer|local alchemist/
17
+ @@re[:get_gem_bounty] = /The local gem dealer, ([a-zA-Z ]+), has an order to fill and wants our help/
18
+ @@re[:creature_problem] = /It appears they have a creature problem they\'d like you to solve/
19
+ @@re[:rescue] = /A local divinist has had visions of the child fleeing from (?:a|an) (.*) (?:in|on) (?:the )?(.*?)(?: near| between| under|\.)/
20
+ @@re[:failed_bounty] = /You have failed in your task/
21
+ @@re[:get_bounty] = /You are not currently assigned a task/
22
+
23
+ # convenience list to get all types of bounties
24
+ def Bounty.types
25
+ @@re.keys
26
+ end
27
+
28
+ def Bounty.type
29
+ t = nil
30
+ @@re.each do |type, exp|
31
+ t= type if checkbounty =~ exp
32
+ end
33
+ return t
34
+ end
35
+
36
+ def Bounty.creature
37
+
38
+ end
39
+
40
+ def Bounty.gem
41
+
42
+ end
43
+
44
+ def Bounty.location
45
+ end
46
+
47
+ def Bounty.n
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,42 @@
1
+
2
+ module Olib
3
+ module Char
4
+ @@routines = {}
5
+
6
+ def Char.hide
7
+ while not hiding?
8
+ waitrt?
9
+ if @@routines[:hiding]
10
+ @@routines[:hiding].call
11
+ else
12
+ fput 'hide'
13
+ end
14
+ end
15
+ Char
16
+ end
17
+
18
+ def Char.visible?
19
+ hiding? || invisible?
20
+ end
21
+
22
+ def Char.hiding_routine(procedure)
23
+ @@routines[:hiding] = procedure
24
+ Char
25
+ end
26
+
27
+ def Char.left
28
+ GameObj.left_hand.nil? ? nil : Item.new(GameObj.left_hand)
29
+ end
30
+
31
+ def Char.right
32
+ GameObj.right_hand.nil? ? nil : Item.new(GameObj.right_hand)
33
+ end
34
+
35
+ end
36
+
37
+ # chainable
38
+ def Olib.Char
39
+ Olib::Char
40
+ end
41
+
42
+ end
@@ -5,11 +5,8 @@
5
5
  # - add quadrapedal types
6
6
  # - add known spells/cmans/manuevers and algorithm for danger level by profession and skills
7
7
 
8
- require 'Olib/extender'
9
- require 'Olib/dictionary'
10
-
11
8
  module Olib
12
- class Creature < Gameobj_Extender
9
+ class Creature < Olib::Gameobj_Extender
13
10
  def Creature.escortee(name)
14
11
  name =~ /^(?:traveller|magistrate|merchant|scribe|dignitary|official)$/
15
12
  end
@@ -1,4 +1,3 @@
1
- require 'Olib/creature'
2
1
  # a collection for managing all of the creatures in a room
3
2
  module Olib
4
3
  class Creatures
@@ -1,5 +1,7 @@
1
1
  # for defining containers ala lootsack and using them across scripts
2
2
 
3
+ require 'Olib/core/extender'
4
+
3
5
  class String
4
6
  def to_class
5
7
  Kernel.const_get self
File without changes
@@ -1,5 +1,4 @@
1
- require 'Olib/extender'
2
- require 'Olib/dictionary'
1
+ require 'Olib/core/extender'
3
2
 
4
3
  module Olib
5
4
  # special item wrapper class to wrap item types with custom, common interactions becoming syntactic sugar
@@ -1,5 +1,3 @@
1
- require "Olib"
2
-
3
1
  module Olib
4
2
  @@debug = false
5
3
  @@xml = false
@@ -0,0 +1,4 @@
1
+ module Olib
2
+ class Box < Gameobj_Extender
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Olib
2
+ class Clothing < Gameobj_Extender
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Olib
2
+ class Herb < Gameobj_Extender
3
+ end
4
+ end
@@ -0,0 +1,101 @@
1
+ module Olib
2
+ class Jar < Gameobj_Extender
3
+ attr_accessor :gem, :count, :full, :empty, :pullable, :initial_count, :stacked
4
+
5
+ def initialize(item)
6
+ super(item)
7
+ @count = 0 # for empty jars
8
+ @full = false
9
+ @empty = false
10
+ _extract
11
+ self
12
+ end
13
+
14
+ def _extract
15
+ jem = @after_name.gsub('containing', '').strip
16
+ if jem != ''
17
+ @gem = Gemstone_Regex.gems[:singularize].call(jem)
18
+ look_result = self.look
19
+ if look_result =~ /^Inside .*? you see ([0-9]+) portion/
20
+ @count = $1.to_i
21
+ @initial_count = @count
22
+ @full = look_result.include?('It is full') ? true : false
23
+ else
24
+ respond "[0lib] Oddity detected in extracting Jar data"
25
+ end
26
+ else
27
+ @empty = true
28
+ end
29
+ self
30
+ end
31
+
32
+ def shake
33
+ result = Library.do "shake ##{@id}", /^You give your #{@noun} a hard shake|before you realize that it is empty/
34
+ @empty = true if result =~ /realize that it is empty/
35
+ return Gem_O.new(GameObj.left_hand) if GameObj.right_hand.id == @id
36
+ return Gem_O.new(GameObj.right_hand) if GameObj.left_hand.id == @id
37
+ end
38
+
39
+ def full?
40
+ @full
41
+ end
42
+
43
+ def empty?
44
+ @empty
45
+ end
46
+
47
+ def stash
48
+ take unless GameObj.right_hand.id == @id or GameObj.left_hand == @id
49
+ Library.do "shop sell 1", /^You place your/
50
+ end
51
+
52
+ def acquire
53
+ if pullable?
54
+ result = Library.do "pull ##{@id}", /^You pull/
55
+ @stacked = true if result =~ /([0-9]+) left/
56
+ else
57
+ result = Library.do "buy ##{@id}", /You hand over/
58
+ unless result =~ /^You hand over/
59
+ Client.end "[FATAL] Logic flaw, not enough coins to acquire #{@name}"
60
+ end
61
+ end
62
+ self
63
+ end
64
+
65
+ def look
66
+ Library.do "look in ##{@id}", /^Inside .*? you see [0-9]+ portion|The .*? is empty./
67
+ end
68
+
69
+ def pullable?
70
+ unless @pullable
71
+ Library.do "get ##{@id}", /^Looking closely/
72
+ result = Library.timeoutfor "You can PULL", "You'll have to buy it if you want it"
73
+ if result =~ /^You can PULL/ then @pullable = true else @pullable = false end
74
+ end
75
+ @pullable
76
+ end
77
+
78
+ def inc
79
+ @count = @count+1
80
+ return self
81
+ end
82
+
83
+ def fill
84
+ @full = true
85
+ return self
86
+ end
87
+
88
+ def add(g)
89
+ 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/
90
+ 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/
91
+ case result
92
+ when /^You add .* filling it/ then inc.fill
93
+ when /^You add|^You put/ then inc
94
+ when /does not appear to be a suitable container for/ then return false
95
+ when /is full/ then fill; return false
96
+ else return false
97
+ end
98
+ return true
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,35 @@
1
+ # Class to interact with gems
2
+ # overwriting Gem is a bad idea
3
+ module Olib
4
+ class Jewel < Gameobj_Extender
5
+ attr_accessor :quality, :value
6
+
7
+ def appraise
8
+ result = dothistimeout "appraise ##{@id}", 3, /#{Gemstone_Regex.gems[:appraise].values.join('|')}/
9
+ case result
10
+ when Gemstone_Regex.gems[:appraise][:gemshop]
11
+ # handle gemshop appraisal
12
+ @value = $1
13
+ when Gemstone_Regex.gems[:appraise][:player]
14
+ @value = $3
15
+ @quality = $2
16
+ when Gemstone_Regex.gems[:appraise][:failure]
17
+ waitrt?
18
+ self.appraise
19
+ else
20
+ respond result
21
+ Client.notify "Error during gem appraisal"
22
+ end
23
+ end
24
+
25
+ def normalized_name
26
+ Gemstone_Regex.gems[:singularize].call(@name)
27
+ end
28
+
29
+ def sell
30
+ result = take
31
+ fput "sell ##{@id}" if result =~ Gemstone_Regex.get[:success]
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,10 @@
1
+ module Olib
2
+ class Jewelry < Gameobj_Extender
3
+ attr_accessor :heirloom
4
+ def heirloom?
5
+ result = Library.do "look ##{@id}", /^You see nothing unusual|#{Gemstone_Regex.item[:heirloom]}/
6
+ @heirloom = result =~ Gemstone_Regex.item[:heirloom] ? true : false
7
+ @heirloom
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,72 @@
1
+ module Olib
2
+ class Scroll < Gameobj_Extender
3
+ @@whitelist = [
4
+ 101, 102, 103, 107, 116, 120,
5
+ 202, 211, 215, 219,
6
+ 303, 307, 310, 313, 315,
7
+ 401, 406, 414, 425, 430,
8
+ 503, 507, 508, 509, 511, 513, 520,
9
+ 601, 602, 606, 613, 617, 618, 625, 640,
10
+ 712,
11
+ 905, 911, 913, 920,
12
+ 1109, 1119, 1125, 1130,
13
+ 1201, 1204,
14
+ 1601, 1603, 1606, 1610, 1611, 1612, 1616,
15
+ 1712, 1718
16
+ ]
17
+ attr_accessor :spells, :worthy, :whitelist
18
+
19
+ def Scroll.whitelist
20
+ @@whitelist
21
+ end
22
+
23
+ def Scroll.add_to_whitelist(*args)
24
+ @@whitelist + args
25
+ end
26
+
27
+ def Scroll.remove_from_whitelist(*args)
28
+ @@whitelist = @@whitelist - args
29
+ end
30
+
31
+ def initialize(item)
32
+ super item
33
+ @spells = []
34
+ return self
35
+ end
36
+
37
+ def worthy?
38
+ @worthy = false
39
+ read unless @spells.length > 0
40
+ @spells.each do |spell| @worthy = true if Scroll.whitelist.include? spell[:n] end
41
+ @worthy
42
+ end
43
+
44
+ def sell
45
+ unless self.worthy?
46
+ result = dothistimeout "get ##{@id}", 1, /^You remove/
47
+ fput "sell ##{@id}" if result
48
+ end
49
+ end
50
+
51
+ def read
52
+ dothistimeout "read ##{@id}", 5, /It takes you a moment to focus/
53
+ result = matchtimeout(5, 'On the')
54
+ if result
55
+ begin
56
+ Timeout::timeout(0.1) do
57
+ while(get =~ /\(([0-9]+)\) ([a-zA-Z'\s]+)/)
58
+ spell = {}
59
+ spell[:n] = $1.to_i
60
+ spell[:name] = $2.to_s
61
+ @spells.push spell
62
+ end
63
+ end
64
+ rescue Timeout::Error
65
+ # Silent
66
+ end
67
+ end
68
+ self
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,4 @@
1
+ module Olib
2
+ class Uncommon < Gameobj_Extender
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Olib
2
+ class Unknown < Gameobj_Extender
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Olib
2
+ class Wand < Gameobj_Extender
3
+ end
4
+ end
@@ -0,0 +1,74 @@
1
+ class ScriptVars
2
+ attr_accessor :opts
3
+ def initialize
4
+ opts = {}
5
+ opts[:flags] = {}
6
+ return opts if Script.current.vars.empty?
7
+ list = Script.current.vars.map(&:downcase).last(Script.current.vars.length-1)
8
+ unless list.first.start_with?('--')
9
+ opts[:cmd] = list.shift
10
+ end
11
+ # iterate over list for flag values
12
+
13
+ list.each.with_index {|ele, i|
14
+ if ele.start_with?('--')
15
+ opts[:flags][ symbolize(ele) ] = ''
16
+ else
17
+ # cast to Number if is number
18
+ ele = ele.to_i if ele =~ /^([\d\.]+$)/
19
+ # look back to previous flag and set it to it's value
20
+ opts[:flags][ symbolize(list[i-1]) ] = ele
21
+ end
22
+ }
23
+
24
+ @opts = opts
25
+ self
26
+ end
27
+
28
+ def cmd
29
+ @opts[:cmd]
30
+ end
31
+
32
+ def empty?(flag)
33
+ opts[:flags][flag].class == TrueClass || opts[:flags][flag].class == NilClass
34
+ end
35
+
36
+ def cmd?(action)
37
+ cmd == action
38
+ end
39
+
40
+ def symbolize(flag)
41
+ flag.gsub('--', '').gsub('-', '_').to_sym
42
+ end
43
+
44
+ def help?
45
+ cmd =~ /help/
46
+ end
47
+
48
+ def flags
49
+ opts[:flags].keys
50
+ end
51
+
52
+ def to_s
53
+ @opts.to_s
54
+ end
55
+
56
+ def flag
57
+ self
58
+ end
59
+
60
+ def flag?(f)
61
+ opts[:flags][ symbolize(f) ]
62
+ end
63
+
64
+ def method_missing(arg1, arg2=nil)
65
+ @opts[:flags][arg1]
66
+ end
67
+
68
+ end
69
+
70
+ module Olib
71
+ def Olib.CLI
72
+ ScriptVars.new
73
+ end
74
+ end
@@ -99,12 +99,12 @@ module Olib
99
99
  m = []
100
100
  m.push bar
101
101
  m.push n
102
- m.push " #{@title}".rjust(40)
102
+ m.push "#{@title}:"
103
103
  m.push n
104
104
  m.push n
105
105
  m.push bar
106
106
  unless @flags.keys.empty?
107
- m.push offset 2, *["| flag", "| info"].map(&:upcase)
107
+ m.push *["global flags:", "", "", ""].map(&:upcase)
108
108
  m.push bar
109
109
  @flags.each { |flag, info|
110
110
  if info.length > @max_column_width
@@ -0,0 +1,148 @@
1
+ module Olib
2
+ @@debug = false
3
+ @@xml = false
4
+
5
+
6
+ def Olib.toggle_debug
7
+ @@debug = @@debug ? false : true
8
+ end
9
+
10
+ def Olib.debug(msg)
11
+ return unless @@debug
12
+ echo "Olib.debug> #{msg}"
13
+ end
14
+
15
+ def Olib.timeout(sec) #:yield: +sec+
16
+ return yield(sec) if sec == nil or sec.zero?
17
+
18
+ begin
19
+ current_thread = Thread.current
20
+ x = Thread.start{
21
+ begin
22
+ yield(sec)
23
+ rescue => e
24
+ current_thread.raise e
25
+ end
26
+ }
27
+ y = Thread.start {
28
+ begin
29
+ sleep sec
30
+ rescue => e
31
+ x.raise e
32
+ else
33
+ x.kill
34
+ current_thread.raise Olib::Errors::TimedOut
35
+ end
36
+ }
37
+ x.value
38
+ ensure
39
+ if y
40
+ y.kill
41
+ y.join # make sure y is dead.
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ def Olib.script
48
+ Script.current
49
+ end
50
+
51
+ def Olib.turn_on_xml
52
+ if not @@xml
53
+ @@xml = true
54
+ Script.current.want_downstream_xml = @@xml
55
+ end
56
+ self
57
+ end
58
+
59
+ def Olib.turn_off_xml
60
+ if @@xml
61
+ @@xml = false
62
+ Script.current.want_downstream_xml = @@xml
63
+ end
64
+ self
65
+ end
66
+
67
+ def Olib.xml?
68
+ @@xml
69
+ end
70
+
71
+ def Olib.wrap(action)
72
+
73
+ begin
74
+ Olib.timeout(3) {
75
+ put action
76
+ while (line=get)
77
+ next if Dictionary.ignorable?(line)
78
+ # attempt at removing PC action that turned out to be more harmful than good
79
+ # next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
80
+ yield line
81
+ end
82
+ }
83
+
84
+ rescue Olib::Errors::TimedOut
85
+ Olib.debug "timeout... "
86
+ # Silent
87
+ rescue Olib::Errors::Mundane => e
88
+
89
+ rescue Olib::Errors::Prempt => e
90
+
91
+ end
92
+
93
+ end
94
+
95
+ def Olib.wrap_greedy(action)
96
+
97
+ begin
98
+ Olib.timeout(3) {
99
+ put action
100
+ while (line=get)
101
+ #next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
102
+ yield line
103
+ end
104
+ }
105
+
106
+ rescue Olib::Errors::TimedOut
107
+ Olib.debug "timeout... "
108
+ # Silent
109
+ rescue Olib::Errors::Mundane => e
110
+
111
+ rescue Olib::Errors::Prempt => e
112
+
113
+ end
114
+
115
+ end
116
+
117
+ def Olib.exit
118
+ raise Olib::Errors::Mundane
119
+ end
120
+
121
+ def Olib.wrap_stream(action, seconds=3)
122
+ begin
123
+ Olib.turn_on_xml
124
+
125
+ Olib.timeout(seconds) {
126
+ put action
127
+ while (line=get)
128
+ next if Olib::Dictionary.ignorable?(line)
129
+ # next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
130
+ yield line
131
+ end
132
+ }
133
+
134
+ rescue Olib::Errors::TimedOut
135
+ Olib.debug "timeout... "
136
+ # Silent
137
+
138
+ rescue Olib::Errors::Mundane => e
139
+ Olib.debug "mundane..."
140
+
141
+ rescue Olib::Errors::Prempt => e
142
+ Olib.debug "waiting prempted..."
143
+
144
+ ensure
145
+ Olib.turn_off_xml
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,101 @@
1
+ class VBulletin
2
+ attr_accessor :post
3
+ def initialize
4
+ @post = String.new
5
+ self
6
+ end
7
+ def open_bold
8
+ @post.concat "[B]"
9
+ self
10
+ end
11
+ def open_underline
12
+ @post.concat '[U]'
13
+ self
14
+ end
15
+ def close_underline
16
+ @post.concat '[/U]'
17
+ self
18
+ end
19
+ def close_bold
20
+ @post.concat '[/B]'
21
+ self
22
+ end
23
+ def open_color(hexcode)
24
+ @post.concat "[COLOR=\"#{hexcode}\"]"
25
+ self
26
+ end
27
+ def open_table(width=500)
28
+ @post.contat "[TABLE=\"width: #{width}\""
29
+ self
30
+ end
31
+ def close_table
32
+ @post.concat "[/TABLE]"
33
+ self
34
+ end
35
+ def open_tr
36
+ @post.contact "[TR]"
37
+ self
38
+ end
39
+ def close_tr
40
+ @post.contact "[/TR]"
41
+ self
42
+ end
43
+ def open_cell
44
+ @post.concat "[TD]"
45
+ self
46
+ end
47
+ def close_cell
48
+ @post.concat '[/TD]'
49
+ self
50
+ end
51
+ def close_color
52
+ @post.concat '[/COLOR]'
53
+ self
54
+ end
55
+ def add(str)
56
+ @post.concat str
57
+ self
58
+ end
59
+ def add_line(str)
60
+ @post.concat "#{str}\n"
61
+ self
62
+ end
63
+ def open_size(sz)
64
+ @post.concat "[SIZE=#{sz}]"
65
+ self
66
+ end
67
+ def close_size
68
+ @post.concat "[/SIZE]"
69
+ self
70
+ end
71
+ def open_italics
72
+ @post.concat"[I]"
73
+ self
74
+ end
75
+ def close_italics
76
+ @post.concat "[/I]"
77
+ self
78
+ end
79
+ def open_indent
80
+ @post.concat "[INDENT]"
81
+ self
82
+ end
83
+ def close_indent
84
+ @post.concat "[/INDENT]"
85
+ self
86
+ end
87
+ def tab
88
+ @post.concat "\t"
89
+ self
90
+ end
91
+ def enter
92
+ @post.concat "\n"
93
+ self
94
+ end
95
+ def VBulletin.commafy(n)
96
+ n.to_s.chars.to_a.reverse.each_slice(3).map(&:join).join(",").reverse
97
+ end
98
+ def to_s
99
+ @post
100
+ end
101
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Olib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondreian Shamsiel
@@ -17,20 +17,38 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - lib/Olib.rb
21
- - lib/Olib/group.rb
22
- - lib/Olib/creature.rb
23
- - lib/Olib/creatures.rb
24
- - lib/Olib/errors.rb
25
- - lib/Olib/utils.rb
26
- - lib/Olib/extender.rb
27
- - lib/Olib/container.rb
28
- - lib/Olib/dictionary.rb
29
- - lib/Olib/item.rb
20
+ - Olib.gemspec
21
+ - README.md
22
+ - TODOS.md
23
+ - lib/Olib/bounty.rb
24
+ - lib/Olib/character/char.rb
25
+ - lib/Olib/character/group.rb
26
+ - lib/Olib/character/inventory.rb
27
+ - lib/Olib/combat/creature.rb
28
+ - lib/Olib/combat/creatures.rb
29
+ - lib/Olib/core/container.rb
30
+ - lib/Olib/core/errors.rb
31
+ - lib/Olib/core/extender.rb
32
+ - lib/Olib/core/item.rb
33
+ - lib/Olib/core/utils.rb
34
+ - lib/Olib/dictionary/dictionary.rb
35
+ - lib/Olib/objects/box.rb
36
+ - lib/Olib/objects/clothing.rb
37
+ - lib/Olib/objects/herb.rb
38
+ - lib/Olib/objects/jar.rb
39
+ - lib/Olib/objects/jewel.rb
40
+ - lib/Olib/objects/jewelry.rb
41
+ - lib/Olib/objects/scroll.rb
42
+ - lib/Olib/objects/uncommon.rb
43
+ - lib/Olib/objects/unknown.rb
44
+ - lib/Olib/objects/wand.rb
30
45
  - lib/Olib/shops.rb
31
46
  - lib/Olib/transport.rb
32
- - lib/Olib/inventory.rb
33
- - lib/Olib/help_menu.rb
47
+ - lib/Olib/utils/cli.rb
48
+ - lib/Olib/utils/help_menu.rb
49
+ - lib/Olib/utils/utils.rb
50
+ - lib/Olib/utils/vbulletin.rb
51
+ - lib/Olib.rb
34
52
  homepage: https://github.com/ondreian/Olib
35
53
  licenses:
36
54
  - MIT