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.
- checksums.yaml +4 -4
- data/Olib.gemspec +17 -16
- data/README.md +23 -21
- data/TODOS.md +3 -3
- data/lib/Olib.rb +88 -50
- data/lib/Olib/area.rb +51 -0
- data/lib/Olib/bounty.rb +171 -128
- data/lib/Olib/character/char.rb +113 -118
- data/lib/Olib/character/group.rb +68 -67
- data/lib/Olib/character/inventory.rb +79 -79
- data/lib/Olib/character/mind.rb +70 -0
- data/lib/Olib/combat/creature.rb +255 -249
- data/lib/Olib/combat/creatures.rb +61 -56
- data/lib/Olib/core/container.rb +200 -148
- data/lib/Olib/core/errors.rb +91 -91
- data/lib/Olib/core/extender.rb +27 -19
- data/lib/Olib/core/item.rb +549 -549
- data/lib/Olib/core/utils.rb +220 -220
- data/lib/Olib/dictionary/dictionary.rb +165 -157
- data/lib/Olib/events/emitter.rb +7 -0
- data/lib/Olib/go2.rb +151 -0
- data/lib/Olib/npcs.rb +5 -0
- data/lib/Olib/objects/box.rb +3 -3
- data/lib/Olib/objects/clothing.rb +3 -3
- data/lib/Olib/objects/herb.rb +3 -3
- data/lib/Olib/objects/jar.rb +100 -100
- data/lib/Olib/objects/jewel.rb +34 -34
- data/lib/Olib/objects/jewelry.rb +9 -9
- data/lib/Olib/objects/scroll.rb +71 -71
- data/lib/Olib/objects/uncommon.rb +3 -3
- data/lib/Olib/objects/unknown.rb +3 -3
- data/lib/Olib/objects/wand.rb +3 -3
- data/lib/Olib/shops.rb +176 -176
- data/lib/Olib/utils/cli.rb +80 -80
- data/lib/Olib/utils/help_menu.rb +166 -166
- data/lib/Olib/utils/monsterbold.rb +4 -4
- data/lib/Olib/utils/vbulletin.rb +100 -100
- data/lib/Olib/version.rb +3 -0
- metadata +11 -7
- data/lib/Olib/transport.rb +0 -117
- data/lib/Olib/utils/utils.rb +0 -148
data/lib/Olib/core/utils.rb
CHANGED
@@ -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
|
195
|
-
begin
|
196
|
-
Olib.turn_on_xml
|
197
|
-
|
198
|
-
Olib.timeout(
|
199
|
-
|
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]
|
7
|
-
re[:give]
|
8
|
-
re
|
9
|
-
end
|
10
|
-
|
11
|
-
def Dictionary.
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def Dictionary.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
re
|
25
|
-
re[:
|
26
|
-
re[:
|
27
|
-
re
|
28
|
-
|
29
|
-
|
30
|
-
re
|
31
|
-
re[:
|
32
|
-
re[:
|
33
|
-
re[:
|
34
|
-
re[:
|
35
|
-
re[:
|
36
|
-
re[:
|
37
|
-
re[:
|
38
|
-
re[:
|
39
|
-
|
40
|
-
re[:
|
41
|
-
re[:
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
re =
|
46
|
-
re[:
|
47
|
-
|
48
|
-
re[:
|
49
|
-
re[:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
re
|
54
|
-
re[:
|
55
|
-
re[:
|
56
|
-
re[:
|
57
|
-
re
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
re
|
83
|
-
re[:
|
84
|
-
|
85
|
-
re[:
|
86
|
-
re
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
re
|
91
|
-
re[:
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
re
|
97
|
-
re[:failure]
|
98
|
-
re[:failure][:
|
99
|
-
re[:
|
100
|
-
re
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
def Dictionary.
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
armors
|
122
|
-
armors['
|
123
|
-
armors['
|
124
|
-
armors['
|
125
|
-
armors['
|
126
|
-
armors['
|
127
|
-
armors['
|
128
|
-
armors['
|
129
|
-
armors['
|
130
|
-
armors['
|
131
|
-
armors['
|
132
|
-
armors
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
/
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
|
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
|