-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathappraisal.lic
More file actions
283 lines (247 loc) · 10.4 KB
/
Copy pathappraisal.lic
File metadata and controls
283 lines (247 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#appraisal
=end
class Appraisal
def initialize
arg_definitions = [
[
{ name: 'focus', regex: /focus/i, description: 'Perform appraise focus on an item.' },
{ name: 'item', regex: /\w+/i, description: 'Item to use appraise focus with.' },
{ name: 'script_summary', optional: true, description: 'Trains the Appraisal skill by appraising your gear, zills, bundles, gem pouches, and studying the art in the Crossing art gallery.' }
],
[
{ name: 'nonspecific', regex: /nonspecific/i, optional: true, description: 'Toggle off specific gem_pouch_adjective' },
{ name: 'count', regex: /count/i, optional: true, description: 'Count gem pouches as they are appraised' }
]
]
args = parse_args(arg_definitions)
@equipment_manager = EquipmentManager.new
settings = get_settings
train_list = settings.appraisal_training
if args.nonspecific
pouch_adjective = nil
else
pouch_adjective = settings.gem_pouch_adjective
end
if args.count
if settings.low_value_gem_pouch_container.to_s.empty?
echo '"count" passed as an argument, but no low_value_gem_pouch_container defined. Skipping counting.'
@count = false
else
@count = true
end
end
pouch_low_value = (settings.gem_pouch_low_value || 1).to_i
if args.focus
if DRSkill.getrank('Appraisal') < 200
echo 'You need at least 200 Appraisal to use Appraise Focus.'
exit
end
appraise_focus(args.item)
else
train_list.each do |task|
break if DRSkill.getxp('Appraisal') >= 30
case task
when 'zills'
assess_zills
when 'pouches'
train_appraisal_with_pouches(settings.full_pouch_container, settings.spare_gem_pouch_container, settings.low_value_gem_pouch_container, pouch_low_value, pouch_adjective, settings.gem_pouch_noun)
when 'kit_pouches'
train_appraisal_with_kit_pouches(settings.gem_kit_name, settings.spare_gem_pouch_container, settings.low_value_gem_pouch_container, pouch_low_value, pouch_adjective, settings.gem_pouch_noun)
when 'gear'
train_appraisal_with_gear
when 'bundle'
train_appraisal_with_bundle
when 'art'
train_appraisal_with_art
else
echo "#{task} is not a valid appraisal_training setting"
end
end
end
end
def train_appraisal_with_art
DRC.wait_for_script_to_complete('study-art', ['appraisal'])
end
def train_appraisal_with_gear
@equipment_manager.wear_equipment_set?('standard')
@equipment_manager.items.each { |item| break unless appraise_item?(item) }
end
def train_appraisal_with_bundle
DRC.bput('appraise my bundle quick', 'Roundtime', 'Appraise what', 'You cannot appraise')
waitrt?
end
def pouch_name(gem_pouch_adjective, gem_pouch_noun)
[gem_pouch_adjective, gem_pouch_noun].compact.reject { |s| s.to_s.empty? }.join(' ')
end
def classify_pouch(name, low_value, low_value_gem_pouch_container, spare_gem_pouch_container)
opened_here = false
result = DRC.bput("appraise my #{name} quick", 'Roundtime', /You.ll need to open the .* to examine its contents./, /There doesn.t appear to be anything in/, /worth a total of about \d+/)
if result =~ /You.ll need to open the .* to examine its contents./
DRC.bput("open my #{name}", /You open your .* ./, /That is already open/)
opened_here = true
result = DRC.bput("appraise my #{name} quick", 'Roundtime', /There doesn.t appear to be anything in/, /worth a total of about \d+/)
end
chosen_container = nil
case result
when /worth a total of about (\d+)/
pouch_value = Regexp.last_match(1).to_i
if pouch_value < low_value
DRC.message("Low value pouch found, putting it into low_value_gem_pouch_container")
chosen_container = low_value_gem_pouch_container
end
if @count
/(\d+)/ =~ DRC.bput("count my #{name}", /You sort through the contents .* and find \d+ gems in it/)
pouch_count = Regexp.last_match(1).to_i
if pouch_count < 500
DRC.message("Pouch not full, putting it into #{low_value_gem_pouch_container}")
chosen_container = low_value_gem_pouch_container
end
end
when /There doesn.t appear to be anything in/
if spare_gem_pouch_container.to_s.empty?
DRC.message("Empty pouch found, but no spare_gem_pouch_container defined. Leaving in default container.")
else
DRC.message("Empty pouch found, putting it into spare_gem_pouch_container")
chosen_container = spare_gem_pouch_container
end
else
DRC.message("Unrecognized appraise result for #{name}: #{result.inspect}. Pouch not classified by value; routing to default container.")
end
DRC.bput("close my #{name}", /You close your/, /That is already closed/) if opened_here
waitrt?
chosen_container
end
def train_appraisal_with_pouches(full_pouch_container, spare_gem_pouch_container, low_value_gem_pouch_container, low_value, gem_pouch_adjective, gem_pouch_noun)
name = pouch_name(gem_pouch_adjective, gem_pouch_noun)
if gem_pouch_adjective
case DRC.bput("appraise my #{name} quick", 'Roundtime', 'You can.t appraise the', 'Appraise what', /You.ll need to open the .* to examine its contents./, /There doesn.t appear to be anything in/)
when /You.ll need to open the .* to examine its contents./
DRC.bput("open my #{name}", /You open your .*./, /That is already open/)
DRC.bput("appraise my #{name} quick", 'Roundtime', 'You can.t appraise the', 'Appraise what')
DRC.bput("close my #{name}", /You close your/, /That is already closed/)
end
waitrt?
end
pause 1
$ORDINALS.each do |ordinal|
break unless DRCI.get_item?("#{ordinal} #{name}", full_pouch_container)
target = classify_pouch(name, low_value, low_value_gem_pouch_container, spare_gem_pouch_container) || full_pouch_container
DRCI.put_away_item?(name, target)
pause 1
break if DRSkill.getxp('Appraisal') >= 30
end
end
def count_kit_pouches(gem_kit_name)
count = 0
in_listing = false
clear
put "rummage my #{gem_kit_name}"
timer = Time.now
while Time.now - timer < 20
line = get?
if line.nil?
pause 0.1
next
end
in_listing = true if line =~ /^Rummaging through .* you find it contains:/i
if in_listing && (m = line.match(/^\s*(\d+)\.\s+/))
n = m[1].to_i
count = n if n > count
end
break if line =~ /^Roundtime:/ || line =~ /^\[You can TURN/ || line =~ /What were you/ || line =~ /isn.t a container/i
end
waitrt?
count
end
def train_appraisal_with_kit_pouches(gem_kit_name, spare_gem_pouch_container, low_value_gem_pouch_container, low_value, gem_pouch_adjective, gem_pouch_noun)
if gem_kit_name.to_s.empty?
DRC.message("No gem_kit_name defined. Skipping kit_pouches task.")
return
end
total = count_kit_pouches(gem_kit_name)
if total <= 0
DRC.message("No pouches found in #{gem_kit_name}.")
return
end
name = pouch_name(gem_pouch_adjective, gem_pouch_noun)
kit_pattern = Regexp.escape(gem_kit_name)
total.downto(1) do |slot|
break if DRSkill.getxp('Appraisal') >= 30
case DRC.bput("turn my #{gem_kit_name} to #{slot}", /You turn/, /already (set )?to/, /Turn what/, /does not have that many/)
when /does not have that many/
next
end
pull_result = DRC.bput("pull my #{gem_kit_name}", /You get .* from your .*#{kit_pattern}/, /empty/, /nothing/, /no .* in that/, /Pull what/, /You need to TURN/)
next unless pull_result =~ /You get .* from your .*#{kit_pattern}/
target = classify_pouch(name, low_value, low_value_gem_pouch_container, spare_gem_pouch_container) || gem_kit_name
DRCI.put_away_item?(name, target)
pause 1
end
end
def appraise_item?(item)
if @equipment_manager.get_item?(item)
DRC.bput("appraise #{item.short_name} quick", 'Roundtime')
waitrt?
pause 1
@equipment_manager.empty_hands
end
DRSkill.getxp('Appraisal') < 30
end
def assess_zills
if DRSkill.getrank('Appraisal') >= 250
echo "Your appraisal skill is above 250. You can remove 'zills' from appraisal_training"
return
end
case DRC.bput('remove my zill', 'You slide', 'Remove what')
when 'Remove what'
return
end
DRC.bput('assess my zill', 'you carefully look them over')
waitrt?
DRC.bput('wear my zill', 'You slide')
pause 1
end
def appraise_focus(item)
focus_concepts = ["defense", "arcane", "recall", "logic", "offense", "magic", "khri", "inner fire"]
if focus_concepts.include?(item)
focus_concept(item)
else
case DRC.bput("get my #{item}", "^You get.*#{item}", '^What were you referring', 'But that is already', 'You are already')
when 'But that is already', '^What were you referring'
echo "Cannot get the #{item} you are trying to focus upon. Exiting..."
exit
end
focus(item)
end
waitrt?
case DRC.bput('appraise focus check', 'You are currently', 'You have completed')
when 'You are currently'
waitfor('Breakthrough')
echo "You have completed focusing on your #{item} and now have increased learning!"
when 'You have completed'
echo 'You already have an active appraise focus boost. Wait a while before trying again.'
end
exit
end
def focus_concept(item)
waitrt?
case DRC.bput("appraise focus #{item}", 'You carefully', 'You are already', 'You currently feel', 'You can\'t seem', 'You cant seem', 'You will lose your progress')
when 'You carefully', 'You are already', 'You currently feel', 'You can\'t seem', 'You cant seem'
return
else
focus_concept(item)
end
end
def focus(item)
waitrt?
case DRC.bput("appraise focus my #{item}", 'You carefully', 'You are already', 'You currently feel', 'You can\'t seem', 'You cant seem', 'You will lose your progress')
when 'You carefully', 'You are already', 'You currently feel', 'You can\'t seem', 'You cant seem'
DRC.bput("stow my #{item}", "You put .*#{item}", 'You easily strap', "You don't seem to be able to move", 'You secure', 'is too small to hold that', 'You hang')
else
focus(item)
end
end
end
# Call this last
Appraisal.new