Olib 0.0.8 → 0.0.9

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.
@@ -1,221 +1,221 @@
1
- module Olib
2
- @@debug = false
3
- @@xml = false
4
-
5
- class ScriptVars
6
- attr_accessor :opts
7
- def initialize
8
- opts = {}
9
- opts[:flags] = {}
10
- return opts if Script.current.vars.empty?
11
- list = Script.current.vars.map(&:downcase).last(Script.current.vars.length-1)
12
- unless list.first.start_with?('--')
13
- opts[:cmd] = list.shift
14
- end
15
- # iterate over list for flag values
16
-
17
- list.each.with_index {|ele, i|
18
- if ele.start_with?('--')
19
- opts[:flags][ symbolize(ele) ] = ''
20
- else
21
- # cast to Number if is number
22
- ele = ele.to_i if ele =~ /^([\d\.]+$)/
23
- # look back to previous flag and set it to it's value
24
- opts[:flags][ symbolize(list[i-1]) ] = ele
25
- end
26
- }
27
-
28
- @opts = opts
29
- self
30
- end
31
-
32
- def cmd
33
- @opts[:cmd]
34
- end
35
-
36
- def empty?(flag)
37
- opts[:flags][flag].class == TrueClass || opts[:flags][flag].class == NilClass
38
- end
39
-
40
- def cmd?(action)
41
- cmd == action
42
- end
43
-
44
- def symbolize(flag)
45
- flag.gsub('--', '').gsub('-', '_').to_sym
46
- end
47
-
48
- def help?
49
- cmd =~ /help/
50
- end
51
-
52
- def flags
53
- opts[:flags].keys
54
- end
55
-
56
- def to_s
57
- @opts.to_s
58
- end
59
-
60
- def flag
61
- self
62
- end
63
-
64
- def flag?(f)
65
- opts[:flags][ symbolize(f) ]
66
- end
67
-
68
- def method_missing(arg1, arg2=nil)
69
- @opts[:flags][arg1]
70
- end
71
-
72
- end
73
-
74
- def Olib.vars
75
- ScriptVars.new
76
- end
77
-
78
-
79
- def Olib.toggle_debug
80
- @@debug = @@debug ? false : true
81
- end
82
-
83
- def Olib.debug(msg)
84
- return unless @@debug
85
- echo "Olib.debug> #{msg}"
86
- end
87
-
88
- def Olib.timeout(sec) #:yield: +sec+
89
- return yield(sec) if sec == nil or sec.zero?
90
-
91
- begin
92
- current_thread = Thread.current
93
- x = Thread.start{
94
- begin
95
- yield(sec)
96
- rescue => e
97
- current_thread.raise e
98
- end
99
- }
100
- y = Thread.start {
101
- begin
102
- sleep sec
103
- rescue => e
104
- x.raise e
105
- else
106
- x.kill
107
- current_thread.raise Olib::Errors::TimedOut
108
- end
109
- }
110
- x.value
111
- ensure
112
- if y
113
- y.kill
114
- y.join # make sure y is dead.
115
- end
116
- end
117
-
118
- end
119
-
120
- def Olib.script
121
- Script.current
122
- end
123
-
124
- def Olib.turn_on_xml
125
- if not @@xml
126
- @@xml = true
127
- Script.current.want_downstream_xml = @@xml
128
- end
129
- self
130
- end
131
-
132
- def Olib.turn_off_xml
133
- if @@xml
134
- @@xml = false
135
- Script.current.want_downstream_xml = @@xml
136
- end
137
- self
138
- end
139
-
140
- def Olib.xml?
141
- @@xml
142
- end
143
-
144
- def Olib.wrap(action)
145
-
146
- begin
147
- Olib.timeout(3) {
148
- put action
149
- while (line=get)
150
- next if Dictionary.ignorable?(line)
151
- # attempt at removing PC action that turned out to be more harmful than good
152
- # next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
153
- yield line
154
- end
155
- }
156
-
157
- rescue Olib::Errors::TimedOut
158
- Olib.debug "timeout... "
159
- # Silent
160
- rescue Olib::Errors::Mundane => e
161
-
162
- rescue Olib::Errors::Prempt => e
163
-
164
- end
165
-
166
- end
167
-
168
- def Olib.wrap_greedy(action)
169
-
170
- begin
171
- Olib.timeout(3) {
172
- put action
173
- while (line=get)
174
- #next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
175
- yield line
176
- end
177
- }
178
-
179
- rescue Olib::Errors::TimedOut
180
- Olib.debug "timeout... "
181
- # Silent
182
- rescue Olib::Errors::Mundane => e
183
-
184
- rescue Olib::Errors::Prempt => e
185
-
186
- end
187
-
188
- end
189
-
190
- def Olib.exit
191
- raise Olib::Errors::Mundane
192
- end
193
-
194
- def Olib.wrap_stream(action, seconds=3)
195
- begin
196
- Olib.turn_on_xml
197
-
198
- Olib.timeout(seconds) {
199
- put action
200
- while (line=get)
201
- next if Olib::Dictionary.ignorable?(line)
202
- # next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
203
- yield line
204
- end
205
- }
206
-
207
- rescue Olib::Errors::TimedOut
208
- Olib.debug "timeout... "
209
- # Silent
210
-
211
- rescue Olib::Errors::Mundane => e
212
- Olib.debug "mundane..."
213
-
214
- rescue Olib::Errors::Prempt => e
215
- Olib.debug "waiting prempted..."
216
-
217
- ensure
218
- Olib.turn_off_xml
219
- end
220
- end
1
+ module Olib
2
+ @@debug = false
3
+ @@xml = false
4
+
5
+ class ScriptVars
6
+ attr_accessor :opts
7
+ def initialize
8
+ opts = {}
9
+ opts[:flags] = {}
10
+ return opts if Script.current.vars.empty?
11
+ list = Script.current.vars.map(&:downcase).last(Script.current.vars.length-1)
12
+ unless list.first.start_with?('--')
13
+ opts[:cmd] = list.shift
14
+ end
15
+ # iterate over list for flag values
16
+
17
+ list.each.with_index {|ele, i|
18
+ if ele.start_with?('--')
19
+ opts[:flags][ symbolize(ele) ] = ''
20
+ else
21
+ # cast to Number if is number
22
+ ele = ele.to_i if ele =~ /^([\d\.]+$)/
23
+ # look back to previous flag and set it to it's value
24
+ opts[:flags][ symbolize(list[i-1]) ] = ele
25
+ end
26
+ }
27
+
28
+ @opts = opts
29
+ self
30
+ end
31
+
32
+ def cmd
33
+ @opts[:cmd]
34
+ end
35
+
36
+ def empty?(flag)
37
+ opts[:flags][flag].class == TrueClass || opts[:flags][flag].class == NilClass
38
+ end
39
+
40
+ def cmd?(action)
41
+ cmd == action
42
+ end
43
+
44
+ def symbolize(flag)
45
+ flag.gsub('--', '').gsub('-', '_').to_sym
46
+ end
47
+
48
+ def help?
49
+ cmd =~ /help/
50
+ end
51
+
52
+ def flags
53
+ opts[:flags].keys
54
+ end
55
+
56
+ def to_s
57
+ @opts.to_s
58
+ end
59
+
60
+ def flag
61
+ self
62
+ end
63
+
64
+ def flag?(f)
65
+ opts[:flags][ symbolize(f) ]
66
+ end
67
+
68
+ def method_missing(arg1, arg2=nil)
69
+ @opts[:flags][arg1]
70
+ end
71
+
72
+ end
73
+
74
+ def Olib.vars
75
+ ScriptVars.new
76
+ end
77
+
78
+
79
+ def Olib.toggle_debug
80
+ @@debug = @@debug ? false : true
81
+ end
82
+
83
+ def Olib.debug(msg)
84
+ return unless @@debug
85
+ echo "Olib.debug> #{msg}"
86
+ end
87
+
88
+ def Olib.timeout(sec) #:yield: +sec+
89
+ return yield(sec) if sec == nil or sec.zero?
90
+
91
+ begin
92
+ current_thread = Thread.current
93
+ x = Thread.start{
94
+ begin
95
+ yield(sec)
96
+ rescue => e
97
+ current_thread.raise e
98
+ end
99
+ }
100
+ y = Thread.start {
101
+ begin
102
+ sleep sec
103
+ rescue => e
104
+ x.raise e
105
+ else
106
+ x.kill
107
+ current_thread.raise Olib::Errors::TimedOut
108
+ end
109
+ }
110
+ x.value
111
+ ensure
112
+ if y
113
+ y.kill
114
+ y.join # make sure y is dead.
115
+ end
116
+ end
117
+
118
+ end
119
+
120
+ def Olib.script
121
+ Script.current
122
+ end
123
+
124
+ def Olib.turn_on_xml
125
+ if not @@xml
126
+ @@xml = true
127
+ Script.current.want_downstream_xml = @@xml
128
+ end
129
+ self
130
+ end
131
+
132
+ def Olib.turn_off_xml
133
+ if @@xml
134
+ @@xml = false
135
+ Script.current.want_downstream_xml = @@xml
136
+ end
137
+ self
138
+ end
139
+
140
+ def Olib.xml?
141
+ @@xml
142
+ end
143
+
144
+ def Olib.wrap(action = nil)
145
+
146
+ begin
147
+ Olib.timeout(3) {
148
+ put action if action
149
+ while (line=get)
150
+ next if Dictionary.ignorable?(line)
151
+ # attempt at removing PC action that turned out to be more harmful than good
152
+ # next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
153
+ yield line
154
+ end
155
+ }
156
+
157
+ rescue Olib::Errors::TimedOut
158
+ Olib.debug "timeout... "
159
+ # Silent
160
+ rescue Olib::Errors::Mundane => e
161
+
162
+ rescue Olib::Errors::Prempt => e
163
+
164
+ end
165
+
166
+ end
167
+
168
+ def Olib.wrap_greedy(action)
169
+
170
+ begin
171
+ Olib.timeout(3) {
172
+ put action
173
+ while (line=get)
174
+ #next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
175
+ yield line
176
+ end
177
+ }
178
+
179
+ rescue Olib::Errors::TimedOut
180
+ Olib.debug "timeout... "
181
+ # Silent
182
+ rescue Olib::Errors::Mundane => e
183
+
184
+ rescue Olib::Errors::Prempt => e
185
+
186
+ end
187
+
188
+ end
189
+
190
+ def Olib.exit
191
+ raise Olib::Errors::Mundane
192
+ end
193
+
194
+ def Olib.wrap_stream(action = nil)
195
+ begin
196
+ Olib.turn_on_xml
197
+
198
+ Olib.timeout(3) {
199
+ if action then fput action end
200
+ while (line=get)
201
+ next if Olib::Dictionary.ignorable?(line)
202
+ # next if not GameObj.pcs.nil? and line =~ /#{GameObj.pcs.join('|')}/
203
+ yield line
204
+ end
205
+ }
206
+
207
+ rescue Olib::Errors::TimedOut
208
+ Olib.debug "timeout... "
209
+ # Silent
210
+
211
+ rescue Olib::Errors::Mundane => e
212
+ Olib.debug "mundane..."
213
+
214
+ rescue Olib::Errors::Prempt => e
215
+ Olib.debug "waiting prempted..."
216
+
217
+ ensure
218
+ Olib.turn_off_xml
219
+ end
220
+ end
221
221
  end
@@ -1,158 +1,166 @@
1
- module Olib
2
-
3
- class Dictionary
4
- def Dictionary.heirloom
5
- re = {}
6
- re[:is] = /are the initials ([A-Z]{2})./
7
- re[:give] = /Excellent. I'm sure the person who lost this will be quite happy/
8
- re
9
- end
10
-
11
- def Dictionary.ignorable?(line)
12
- line =~ /You feel less drained|You feel at full magical power again|\[LNet\]|GSIV|moving stealthily into the room|glides into view|soars out of sight|You notice (.*?) moving stealthily out|[A-Z][a-z]+ says, "|(removes|put) a (.*?) from in (his|her)|just opened (a|an)|just went|You gesture|Your spell is ready|just bit the dust|joins the adventure|just arrived|returns home from a hard day of adventuring|no longer effective|You sense that your attunement|You do not feel drained anymore|You feel the magic of your spell depart/
13
- end
14
-
15
- def Dictionary.targetable
16
- re = {}
17
- re[:yes] = /^You are now targeting/
18
- re[:no] = /^You can't target/
19
- re
20
- end
21
- def Dictionary.bounty
22
- re = {}
23
- 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]+)/
24
- 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/
25
- re[:gem] = /has received orders from multiple customers requesting (?:a|an|some) ([a-zA-Z '-]+). You have been tasked to retrieve ([0-9]+)/
26
- 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 '-]+)./
27
- re[:heirloom_found] = /^You have located the heirloom and should bring it back to/
28
- re[:turn_in] = /You have succeeded in your task and can return to the Adventurer's Guild to receive your reward/
29
- re[:guard_turn_in] = /^You succeeded in your task and should report back to/
30
- re[:guard_bounty] = /Go report to ([a-zA-Z ]+) to find out more/
31
- re[:cull] = /^You have been tasked to suppress (^((?!bandit).)*$) activity (?:in|on) (?:the )? (.*?)(?: near| between| under|\.) ([a-zA-Z' ]+). You need to kill ([0-9]+)/
32
- 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]+)/
33
- 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|\.)/
34
- re[:get_skin_bounty] = /The local furrier/
35
- re[:get_herb_bounty] = /local herbalist|local healer|local alchemist/
36
- re[:get_gem_bounty] = /The local gem dealer, ([a-zA-Z ]+), has an order to fill and wants our help/
37
- re[:creature_problem] = /It appears they have a creature problem they\'d like you to solve/
38
- re[:rescue] = /A local divinist has had visions of the child fleeing from (?:a|an) (.*) (?:in|on) (?:the )?(.*?)(?: near| between| under|\.)/
39
-
40
- re[:failed_bounty] = /You have failed in your task/
41
- re[:get_bounty] = /You are not currently assigned a task/
42
-
43
- end
44
- def Dictionary.bandit_traps
45
- re = {}
46
- re[:net] = /Suddenly, a carefully concealed net springs up from the ground, completely entangling you/
47
- re[:jaws] = /large pair of carefully concealed metal jaws slam shut on your/
48
- re[:wire] = /stumbled right into a length of nearly invisible razor wire/
49
- re[:pouch] = /of air as you realize you've just stepped on a carefully concealed inflated pouch/
50
- re[:rope] = /wrapping around your ankle and tossing you up into the air/
51
- re[:spikes] = /from under you as you fall into a shallow pit filled with tiny spikes/
52
- re[:net] = /completely entangling you/
53
- re[:net_end] = /The net entangling you rips and falls apart/
54
- re[:hidden] = /You hear a voice shout|leaps|flies from the shadows toward you/
55
- re[:fail] = /You spy/
56
- re[:statue] = /A faint silvery light flickers from the shadows/
57
- re
58
- end
59
-
60
- def Dictionary.shop
61
- db = {}
62
- db[:success] = /^You hand over|You place your/
63
- db[:failure] = {}
64
- db[:failure][:missing] = /^There is nobody here to buy anything from/
65
- db[:failure][:silvers] = /^The merchant frowns and says/
66
- db[:failure][:full] = /^There's no more room for anything else/
67
- db[:failure][:own] = /^Buy your own merchandise?/
68
- db
69
- end
70
- def Dictionary.gems
71
- re = {}
72
- # Expressions to match interaction with gems
73
- re[:appraise] = {}
74
- re[:appraise][:gemshop] = /inspects it carefully before saying, "I'll give you ([0-9]+) for it if you want to sell/
75
- re[:appraise][:player] = /You estimate that the ([a-zA-Z '-]+) is of ([a-zA-Z '-]+) quality and worth approximately ([0-9]+) silvers/
76
- re[:appraise][:failure] = /As best you can tell, the ([a-zA-Z '-]+) is of average quality/
77
- re[:singularize] = proc{ |str| str.gsub(/ies$/, 'y').gsub(/zes$/,'z').gsub(/s$/,'').gsub(/large |medium |containing |small |tiny |some /, '').strip }
78
- re
79
- end
80
-
81
- def Dictionary.get
82
- re = {}
83
- re[:failure] = {}
84
- # Expressions to match `get` verb results
85
- re[:failure][:weight] = /You are unable to handle the additional load/
86
- re[:failure][:hands_full] = /^You need a free hand to pick that up/
87
- re[:failure][:ne] = /^Get what/
88
- re[:failure][:buy] = /is (?<cost>[0-9]+) (silvers|coins)/
89
- re[:failure][:race] = /be (?<cost>[0-9]+) (silvers|coins) for someone like you/
90
- re[:failure][:pshop] = /^Looking closely/
91
- re[:success] = /^You pick up|^You remove|^You rummage|^You draw|^You grab|^You reach|^You already/
92
- re
93
- end
94
-
95
- def Dictionary.put
96
- re = {}
97
- re[:failure] = {}
98
- re[:failure][:full] = /^won't fit in the|is full!|filling it./
99
- re[:failure][:ne] = /^I could not find what you were referring to/
100
- re[:success] = /^You put|^You tuck|^You sheathe|^You slip|^You roll up|^You tuck|^You add|^You place/
101
- re
102
- end
103
-
104
- def Dictionary.jar(name=nil)
105
- if name
106
- return name.gsub(/large |medium |containing |small |tiny |some /, '').sub 'rubies', 'ruby'
107
- else
108
- return false
109
- end
110
- end
111
-
112
- def Dictionary.armors
113
- armors = Hash.new
114
- armors['robes'] = /cloth armor/i
115
- armors['light leather'] = /soft leather armor that covers the torso only./i
116
- armors['full leather'] = /soft leather armor that covers the torso and arms./i
117
- armors['reinforced leather'] = /soft leather armor that covers the torso, arms, and legs./i
118
- armors['double leather'] = /soft leather armor that covers the torso, arms, legs, neck, and head./i
119
- armors['leather breastplate'] = /rigid leather armor that covers the torso only./i
120
- armors['cuirbouilli leather'] = /rigid leather armor that covers the torso and arms./i
121
- armors['studded leather'] = /rigid leather armor that covers the torso, arms, and legs./i
122
- armors['brigadine armor'] = /rigid leather armor that covers the torso, arms, legs, neck, and head./i
123
- armors['chain mail'] = /chain armor that covers the torso only./i
124
- armors['double chain'] = /chain armor that covers the torso and arms./i
125
- armors['augmented chain'] = /chain armor that covers the torso, arms, and legs./i
126
- armors['chain hauberk'] = /chain armor that covers the torso, arms, legs, neck, and head./i
127
- armors['metal breastplate'] = /plate armor that covers the torso only./i
128
- armors['augmented plate'] = /plate armor that covers the torso and arms./i
129
- armors['half plate'] = /plate armor that covers the torso, arms, and legs./i
130
- armors['full plate'] = /plate armor that covers the torso, arms, legs, neck, and head./i
131
- armors['DB'] = /miscellaneous armor that protects the wearer in general/
132
- armors
133
- end
134
-
135
- def Dictionary.size
136
- /that it is a (?<size>.*) shield that protects/
137
- end
138
-
139
- def Dictionary.numbers
140
- numbers = Hash.new
141
- numbers['one'] = 1
142
- numbers['two'] = 2
143
- numbers['three'] = 3
144
- numbers['four'] = 4
145
- numbers['five'] = 5
146
- numbers
147
- end
148
-
149
- def Dictionary.spiked
150
- /You also notice that it is spiked./i
151
- end
152
-
153
- def Dictionary.fusion
154
- /(?<orbs>.*?) spherical depressions adorn the (.*?), approximately the size and shape of a small gem/
155
- end
156
-
157
- end
1
+ module Olib
2
+
3
+ class Dictionary
4
+ def Dictionary.heirloom
5
+ re = {}
6
+ re[:is] = /are the initials ([A-Z]{2})./
7
+ re[:give] = /Excellent. I'm sure the person who lost this will be quite happy/
8
+ re
9
+ end
10
+
11
+ def Dictionary.tag
12
+ /<a exist="(?<id>.*?)" noun="(?<noun>.*?)">(?<name>.*?)<\/a>/
13
+ end
14
+
15
+ def Dictionary.contents
16
+ /(On|In) the (.*?) you see (?<items>.*)/
17
+ end
18
+
19
+ def Dictionary.ignorable?(line)
20
+ line =~ /You feel less drained|You feel at full magical power again|\[LNet\]|GSIV|moving stealthily into the room|glides into view|soars out of sight|You notice (.*?) moving stealthily out|[A-Z][a-z]+ says, "|(removes|put) a (.*?) from in (his|her)|just opened (a|an)|just went|You gesture|Your spell is ready|just bit the dust|joins the adventure|just arrived|returns home from a hard day of adventuring|no longer effective|You sense that your attunement|You do not feel drained anymore|You feel the magic of your spell depart/
21
+ end
22
+
23
+ def Dictionary.targetable
24
+ re = {}
25
+ re[:yes] = /^You are now targeting/
26
+ re[:no] = /^You can't target/
27
+ re
28
+ end
29
+ def Dictionary.bounty
30
+ re = {}
31
+ 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]+)/
32
+ 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/
33
+ re[:gem] = /has received orders from multiple customers requesting (?:a|an|some) ([a-zA-Z '-]+). You have been tasked to retrieve ([0-9]+)/
34
+ 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 '-]+)./
35
+ re[:heirloom_found] = /^You have located the heirloom and should bring it back to/
36
+ re[:turn_in] = /You have succeeded in your task and can return to the Adventurer's Guild to receive your reward/
37
+ re[:guard_turn_in] = /^You succeeded in your task and should report back to/
38
+ re[:guard_bounty] = /Go report to ([a-zA-Z ]+) to find out more/
39
+ re[:cull] = /^You have been tasked to suppress (^((?!bandit).)*$) activity (?:in|on) (?:the )? (.*?)(?: near| between| under|\.) ([a-zA-Z' ]+). You need to kill ([0-9]+)/
40
+ 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]+)/
41
+ 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|\.)/
42
+ re[:get_skin_bounty] = /The local furrier/
43
+ re[:get_herb_bounty] = /local herbalist|local healer|local alchemist/
44
+ re[:get_gem_bounty] = /The local gem dealer, ([a-zA-Z ]+), has an order to fill and wants our help/
45
+ re[:creature_problem] = /It appears they have a creature problem they\'d like you to solve/
46
+ re[:rescue] = /A local divinist has had visions of the child fleeing from (?:a|an) (.*) (?:in|on) (?:the )?(.*?)(?: near| between| under|\.)/
47
+
48
+ re[:failed_bounty] = /You have failed in your task/
49
+ re[:get_bounty] = /You are not currently assigned a task/
50
+
51
+ end
52
+ def Dictionary.bandit_traps
53
+ re = {}
54
+ re[:net] = /Suddenly, a carefully concealed net springs up from the ground, completely entangling you/
55
+ re[:jaws] = /large pair of carefully concealed metal jaws slam shut on your/
56
+ re[:wire] = /stumbled right into a length of nearly invisible razor wire/
57
+ re[:pouch] = /of air as you realize you've just stepped on a carefully concealed inflated pouch/
58
+ re[:rope] = /wrapping around your ankle and tossing you up into the air/
59
+ re[:spikes] = /from under you as you fall into a shallow pit filled with tiny spikes/
60
+ re[:net] = /completely entangling you/
61
+ re[:net_end] = /The net entangling you rips and falls apart/
62
+ re[:hidden] = /You hear a voice shout|leaps|flies from the shadows toward you/
63
+ re[:fail] = /You spy/
64
+ re[:statue] = /A faint silvery light flickers from the shadows/
65
+ re
66
+ end
67
+
68
+ def Dictionary.shop
69
+ db = {}
70
+ db[:success] = /^You hand over|You place your/
71
+ db[:failure] = {}
72
+ db[:failure][:missing] = /^There is nobody here to buy anything from/
73
+ db[:failure][:silvers] = /^The merchant frowns and says/
74
+ db[:failure][:full] = /^There's no more room for anything else/
75
+ db[:failure][:own] = /^Buy your own merchandise?/
76
+ db
77
+ end
78
+ def Dictionary.gems
79
+ re = {}
80
+ # Expressions to match interaction with gems
81
+ re[:appraise] = {}
82
+ re[:appraise][:gemshop] = /inspects it carefully before saying, "I'll give you ([0-9]+) for it if you want to sell/
83
+ re[:appraise][:player] = /You estimate that the ([a-zA-Z '-]+) is of ([a-zA-Z '-]+) quality and worth approximately ([0-9]+) silvers/
84
+ re[:appraise][:failure] = /As best you can tell, the ([a-zA-Z '-]+) is of average quality/
85
+ re[:singularize] = proc{ |str| str.gsub(/ies$/, 'y').gsub(/zes$/,'z').gsub(/s$/,'').gsub(/large |medium |containing |small |tiny |some /, '').strip }
86
+ re
87
+ end
88
+
89
+ def Dictionary.get
90
+ re = {}
91
+ re[:failure] = {}
92
+ # Expressions to match `get` verb results
93
+ re[:failure][:weight] = /You are unable to handle the additional load/
94
+ re[:failure][:hands_full] = /^You need a free hand to pick that up/
95
+ re[:failure][:ne] = /^Get what/
96
+ re[:failure][:buy] = /(is|for|be) (?<cost>[0-9]+) (silvers|coins)/
97
+ re[:failure][:race] = /be (?<cost>[0-9]+) (silvers|coins) for someone like you/
98
+ re[:failure][:pshop] = /^Looking closely/
99
+ re[:success] = /^You pick up|^You remove|^You rummage|^You draw|^You grab|^You reach|^You already/
100
+ re
101
+ end
102
+
103
+ def Dictionary.put
104
+ re = {}
105
+ re[:failure] = {}
106
+ re[:failure][:full] = /^won't fit in the|is full!|filling it./
107
+ re[:failure][:ne] = /^I could not find what you were referring to/
108
+ re[:success] = /^You put|^You tuck|^You sheathe|^You slip|^You roll up|^You tuck|^You add|^You place/
109
+ re
110
+ end
111
+
112
+ def Dictionary.jar(name=nil)
113
+ if name
114
+ return name.gsub(/large |medium |containing |small |tiny |some /, '').sub 'rubies', 'ruby'
115
+ else
116
+ return false
117
+ end
118
+ end
119
+
120
+ def Dictionary.armors
121
+ armors = Hash.new
122
+ armors['robes'] = /cloth armor/i
123
+ armors['light leather'] = /soft leather armor that covers the torso only./i
124
+ armors['full leather'] = /soft leather armor that covers the torso and arms./i
125
+ armors['reinforced leather'] = /soft leather armor that covers the torso, arms, and legs./i
126
+ armors['double leather'] = /soft leather armor that covers the torso, arms, legs, neck, and head./i
127
+ armors['leather breastplate'] = /rigid leather armor that covers the torso only./i
128
+ armors['cuirbouilli leather'] = /rigid leather armor that covers the torso and arms./i
129
+ armors['studded leather'] = /rigid leather armor that covers the torso, arms, and legs./i
130
+ armors['brigadine armor'] = /rigid leather armor that covers the torso, arms, legs, neck, and head./i
131
+ armors['chain mail'] = /chain armor that covers the torso only./i
132
+ armors['double chain'] = /chain armor that covers the torso and arms./i
133
+ armors['augmented chain'] = /chain armor that covers the torso, arms, and legs./i
134
+ armors['chain hauberk'] = /chain armor that covers the torso, arms, legs, neck, and head./i
135
+ armors['metal breastplate'] = /plate armor that covers the torso only./i
136
+ armors['augmented plate'] = /plate armor that covers the torso and arms./i
137
+ armors['half plate'] = /plate armor that covers the torso, arms, and legs./i
138
+ armors['full plate'] = /plate armor that covers the torso, arms, legs, neck, and head./i
139
+ armors['DB'] = /miscellaneous armor that protects the wearer in general/
140
+ armors
141
+ end
142
+
143
+ def Dictionary.size
144
+ /that it is a (?<size>.*) shield that protects/
145
+ end
146
+
147
+ def Dictionary.numbers
148
+ numbers = Hash.new
149
+ numbers['one'] = 1
150
+ numbers['two'] = 2
151
+ numbers['three'] = 3
152
+ numbers['four'] = 4
153
+ numbers['five'] = 5
154
+ numbers
155
+ end
156
+
157
+ def Dictionary.spiked
158
+ /You also notice that it is spiked./i
159
+ end
160
+
161
+ def Dictionary.fusion
162
+ /(?<orbs>.*?) spherical depressions adorn the (.*?), approximately the size and shape of a small gem/
163
+ end
164
+
165
+ end
158
166
  end