Olib 2.0.0.pre.rc.6 → 2.0.0.pre.rc.7

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
  SHA256:
3
- metadata.gz: f7d8e8dfe837282ceb421c8919c9b14385299f9f718493dc74efef8c9863cb4a
4
- data.tar.gz: dffc7436f4fc2da600ed00104ca8ca53e9880226d846c12c67987fe36ca9845d
3
+ metadata.gz: 6b6389e96091c8dc8e79ea4bb25b9c30805c91d47f09addab1a1e2075976a9dc
4
+ data.tar.gz: 6008e2a6431503d0c72b17c7ec5e27a940ae7a2a4d4af807f6c11670f346794f
5
5
  SHA512:
6
- metadata.gz: bde4171be06ed24d979ffbc9a49b68a7159af161006607194485502d4e9f8a43d6c9b10b8417b2e915f8e30475670a4c87965ac0d63609302f804ea4c6e15990
7
- data.tar.gz: 97ebab201d826e5e483777535ee91d93a9d80110eea2f329c142d3893a0985409957e95f2d4f74e28bedd1832cdf17636c160e14dd580003013a940fa2c4de83
6
+ metadata.gz: b19fd1ecffec4ddd4a0e8a587b8db4ccb9089c28ffc1d74c4bab90626a2e43e52efcdec7c2abbb8ae943331d7b5c3deac78e1a2674cfdd47dd6f6410294a0fdf
7
+ data.tar.gz: bf7d1ddb8a5d621f5a9c98656127a051c93842942c0079d061d415fbefd937450e57866ece27d978652af98881ba620b599575b65735aab76f5daf732d0a0b00
@@ -1,15 +1,15 @@
1
1
  require "ostruct"
2
2
 
3
3
  class Bounty
4
- NPCS = /guard|sergeant|Felinium|clerk|purser|taskmaster|gemcutter|jeweler|akrash|kris|Ghaerdish|Furryback|healer|dealer|Ragnoz|Maraene|Kelph|Areacne|Jhiseth|Gaedrein/i
4
+ NPCS = /guard|sergeant|Luthrek|Felinium|clerk|purser|taskmaster|gemcutter|jeweler|akrash|kris|Ghaerdish|Furryback|healer|dealer|Ragnoz|Maraene|Kelph|Areacne|Jhiseth|Gaedrein/i
5
5
  HERBALIST_AREAS = /illistim|vaalor|legendary rest|solhaven/i
6
- @@listeners = {}
6
+
7
7
  # this should be refactored to use CONST
8
8
  REGEX = OpenStruct.new(
9
9
  creature_problem: /"Hmm, I've got a task here from (?<town>.*?)\. It appears they have a creature problem they\'d like you to solve/,
10
10
  report_to_guard: /^You succeeded in your task and should report back to/,
11
11
  get_skin_bounty: /The local furrier/,
12
- heirloom_found: /^You have located the heirloom and should bring it back to/,
12
+ heirloom_found: /^You have located (?:a|an|some) (?<heirloom>.*?) and should bring it back to one of the (?<town>.*?) gate guards\./,
13
13
  cooldown: /^You are not currently assigned a task. You will be eligible for new task assignment in about (?<minutes>.*?) minute(s)./,
14
14
 
15
15
  dangerous: /You have been tasked to hunt down and kill a particularly dangerous (?<creature>.*) that has established a territory (?:in|on) (?:the )?(?<area>.*?)(?: near| between| under|\.)/,
@@ -27,14 +27,14 @@ class Bounty
27
27
  escort: /Go to the (.*?) and WAIT for (?:him|her|them) to meet you there. You must guarantee (?:his|her|their) safety to (?<destination>.*?) as soon as/,
28
28
  gem: /The gem dealer in (?<town>.*?), (?<npc>.*?), has received orders from multiple customers requesting (?:a|an|some) (?<gem>[a-zA-Z '-]+). You have been tasked to retrieve (?<number>[0-9]+)/,
29
29
  cull: /^You have been tasked to suppress (?<creature>(?!bandit).*) activity (?:in|on|around) (?<area>.*?)(| (near|between) (?<realm>.*?)). You need to kill (?<number>[0-9]+)/,
30
- bandits: /^You have been tasked to suppress bandit activity (?:in|on|around) (?<area>.*?) (?:near|between|under) (?<realm>.*?). You need to kill (?<number>[0-9]+)/,
30
+ bandits: /^You have been tasked to suppress bandit activity (?:in|on|around|near) (?<area>.*?) (?:near|between|under) (?<realm>.*?). You need to kill (?<number>[0-9]+)/,
31
31
 
32
32
  rescue: /A local divinist has had visions of the child fleeing from (?:a|an) (?<creature>.*) (?:in|on) (?:the )?(?<area>.*?)(?: near| between| under|\.)/,
33
33
  failed: /You have failed in your task/,
34
34
  none: /You are not currently assigned a task/,
35
35
  skin: /^You have been tasked to retrieve (?<number>\d+) (?<skin>.*?) of at least (?<quality>.*?) quality for (?<buyer>.*?) in (?<realm>.*?)\.\s+You can SKIN them off the corpse of (a|an|some) (?<creature>.*?) or/,
36
36
 
37
- help_bandits: /You have been tasked to help (?<partner>.*?) suppress bandit activity (?:in|on|around) (?<area>.*?) (?:near|between|under) (?<realm>.*?). You need to kill (?<number>[0-9]+)/,
37
+ help_bandits: /You have been tasked to help (?<partner>.*?) suppress bandit activity (?:in|on|around|near) (?<area>.*?) (?:near|between|under) (?<realm>.*?). You need to kill (?<number>[0-9]+)/,
38
38
  help_creatures: /You have been tasked to help (?<partner>.*?) kill a dangerous creature by suppressing (?<creature>.*) activity (?:in|on|around|near) (?<area>.*?) (?:near|between|under) (?<realm>.*?) during the hunt. You need to kill (?<number>[0-9]+)/,
39
39
  help_cull: /You have been tasked to help (?<partner>.*?) suppress (?<creature>.*) activity (?:in|on|around|near) (?<area>.*?) (?:near|between|under) (?<realm>.*?). You need to kill (?<number>[0-9]+)/,
40
40
  )
@@ -142,15 +142,6 @@ class Bounty
142
142
  Bounty
143
143
  end
144
144
 
145
- def Bounty.on(namespace, &block)
146
- @@listeners[namespace] = block
147
- Bounty
148
- end
149
-
150
- def Bounty.listeners
151
- @@listeners
152
- end
153
-
154
145
  def Bounty.cooldown?
155
146
  not XMLData.active_spells["Next Bounty"].nil?
156
147
  end
@@ -163,38 +154,6 @@ class Bounty
163
154
  Bounty
164
155
  end
165
156
 
166
- def Bounty.throw_missing_listener
167
- msg = "\n"
168
- msg.concat "\nBounty.dispatch called for `:#{Bounty.type}` without a defined listener\n\n"
169
- msg.concat "define a listener with:\n"
170
- msg.concat " \n"
171
- msg.concat " Bounty.on(:#{Bounty.type}) {\n"
172
- msg.concat " # do something\n"
173
- msg.concat " }\n"
174
- msg.concat " \n"
175
- msg.concat "or rescue this error (Errors::Fatal) gracefully\n"
176
- msg.concat " \n"
177
- raise Errors::Fatal.new msg
178
- end
179
-
180
- def Bounty.dispatch(listener=nil)
181
- if listener
182
- if @@listeners[listener]
183
- @@listeners[listener].call
184
- return Bounty
185
- else
186
- Bounty.throw_missing_listener
187
- end
188
- end
189
-
190
- if @@listeners[Bounty.type]
191
- @@listeners[Bounty.type].call
192
- return Bounty
193
- else
194
- Bounty.throw_missing_listener
195
- end
196
- end
197
-
198
157
  def Bounty.find_guard
199
158
  Go2.advguard
200
159
  if Bounty.npc.nil? then Go2.advguard2 end
@@ -9,5 +9,9 @@ class Creatures
9
9
  def self.get(name)
10
10
  @repo.fetch(name.downcase) do {name: name, level: Char.level, tags: []} end
11
11
  end
12
+
13
+ def self.repo()
14
+ @repo.values.map {|creature| OpenStruct.new(creature)}
15
+ end
12
16
  end
13
17
  end
@@ -6,14 +6,14 @@ class Transaction < Exist
6
6
  close: Regexp.union(
7
7
  %r[I already appraised that],
8
8
  %r[Sorry, #{Char.name}, I'm not buying anything this valuable today\.],
9
- %r[(I'll give you|How's|I'll offer you|worth at least) (?<value>\d+)],
10
- %r[(?<value>\d+) silvers])
9
+ %r[(I'll give you|How's|I'll offer you|worth at least) (?<value>[,\d]+)],
10
+ %r[(?<value>[,\d]+) silvers])
11
11
  )
12
12
 
13
13
  Sell = Rill.new(
14
14
  start: %[You offer|You ask (?<merchant>.*?) if (he|she) would like to buy (?:a |an |)<a exist="{{id}}"],
15
15
  close: Regexp.union(
16
- %r[(hands you|for) (?<value>\d+)],
16
+ %r[(hands you|for) (?<value>[,\d]+)],
17
17
  %r[No #{Char.name}, I won't buy that],
18
18
  %r[I'm sorry, #{Char.name}, but I have no use for that\.],
19
19
  %r[He hands it back to you],
@@ -39,10 +39,11 @@ class Transaction < Exist
39
39
  take
40
40
  (_, match, lines) = Appraise.capture(self.to_h,
41
41
  "appraise \#{{id}}")
42
- if lines.any? {|line| line.include?(%[Sorry, Pixelia, I'm not buying anything this valuable today.])}
42
+ if lines.any? {|line| line.include?(%[Sorry, #{Char.name}, I'm not buying anything this valuable today.])}
43
43
  @value = Float::INFINITY
44
44
  else
45
- @value = match[:value].to_i
45
+ Log.out(match[:value])
46
+ @value = match[:value].delete(",").to_i
46
47
  end
47
48
  self
48
49
  end
@@ -58,7 +59,10 @@ class Transaction < Exist
58
59
  (_, match, _lines) = Sell.capture(self.to_h,
59
60
  "sell \#{{id}}")
60
61
 
61
-
62
+ if match[:value].is_a?(String) && match[:value] =~ /[\d,]+/
63
+ match[:value] = match[:value].delete(",").to_i
64
+ end
65
+
62
66
  match[:value] = 0 unless match[:value].is_a?(Integer)
63
67
  Ok[**match]
64
68
  end
@@ -8,7 +8,7 @@ class MatchData
8
8
 
9
9
  def to_h
10
10
  Hash[self.names.map(&:to_sym).zip(self.captures.map(&:strip).map do |capture|
11
- if capture.is_i? then capture.to_i else capture end
11
+ if capture.is_i? then capture.delete(",").to_i else capture end
12
12
  end)]
13
13
  end
14
14
  end
@@ -1,6 +1,6 @@
1
1
  class String
2
2
  def is_i?
3
- !!(self =~ /\A[-+]?[0-9]+\z/)
3
+ !!(self.delete(",") =~ /\A[-+]?[0-9]+\z/)
4
4
  end
5
5
 
6
6
  def methodize
@@ -29,23 +29,32 @@ class Go2
29
29
  Go2.define_singleton_method(tag.methodize) do Go2.room(tag) end
30
30
  end
31
31
 
32
- def Go2.room(roomid)
33
- unless Room.current.id == roomid || Room.current.tags.include?(roomid)
32
+ def Go2.run(target)
33
+ Script.run "go2", ("%s _disable_confirm_" % target)
34
+ end
35
+
36
+ def Go2.room(target)
37
+ starting_room = Room.current.id
38
+ unless Room.current.id == target || Room.current.tags.include?(target)
34
39
  Char.unhide if hidden
35
- Script.run("go2", "#{roomid} _disable_confirm_")
40
+ Go2.run(target)
41
+ if block_given?
42
+ yield
43
+ starting_room
44
+ end
36
45
  end
37
46
  Go2
38
47
  end
39
48
 
40
49
  def Go2.origin
41
- Go2.room @@origin[:roomid]
50
+ Go2.room @@origin[:target]
42
51
  Char.hide if @@origin[:hidden]
43
52
  Go2
44
53
  end
45
54
 
46
55
  def Go2.rebase
47
56
  @@origin = {}
48
- @@origin[:roomid] = Room.current.id
57
+ @@origin[:target] = Room.current.id
49
58
  @@origin[:hidden] = hiding?
50
59
  @@origin[:location] = Room.current.location
51
60
  Go2
@@ -1,3 +1,3 @@
1
1
  module Olib
2
- VERSION = "2.0.0-rc.6"
2
+ VERSION = "2.0.0-rc.7"
3
3
  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: 2.0.0.pre.rc.6
4
+ version: 2.0.0.pre.rc.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondreian Shamsiel