-
Notifications
You must be signed in to change notification settings - Fork 178
/
edityaml.lic
342 lines (309 loc) · 10.9 KB
/
edityaml.lic
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#edityaml
=end
custom_require.call('common')
class SetupConfig
def initialize
@line_length = 80
@skills_list = ['Athletics', 'Outdoorsmanship', 'Augmentation', 'Warding', 'Utility', 'Debilitation', 'First Aid', 'Scholarship', 'Astrology', 'Mechanical Lore', 'Instinct', 'Attunement', 'Stealth', 'Thievery', 'Forging', 'Appraisal', 'Theurgy', 'Perception', 'Empathy', 'Locksmithing', 'Summoning', 'Performance', 'Sorcery', 'Trading', 'Outfitting', 'Engineering', 'Primary Magic']
@skill_warnings = {
'First Aid' => 'Requires a compendium and at least 40 scholarship',
'Scholarship' => 'Requires a blacksmithing book, see the forging society book store',
'Mechanical Lore' => 'Your safe room must have grass and vines for braiding',
'Outdoorsmanship' => 'Your safe room must have rocks and vines for collecting',
'Perception' => 'Your safe room must have rocks and vines for collecting',
'Performance' => 'You will need to be wearing zills',
'Forging' => 'Requires blacksmithing book, hammer, tongs, and shovel. See forging set up'
}
@user_settings = get_character_setting
print_solid_line
print_solid_line ' Setup Configuration '
print_solid_line
print_solid_line ' Use ;send # to interact with the menu '
print_solid_line ' To update a text field ;send # value'
print_solid_line ' Use ;send save to save and exit at any time '
print_solid_line ' Use ;send quit to exit at any time DOES NOT SAVE '
print_solid_line
display_main_menu
end
def print_solid_line(msg = nil)
line = '*' * @line_length
line[line.size / 2 - msg.size / 2..line.size / 2 + msg.size / 2] = msg if msg
line += '*' if line.size < @line_length
respond(line)
end
def yn(val)
val ? 'Yes' : 'No'
end
def wait_for_response
response = get.strip until response =~ /^\d+$|^save$|^quit$|^\d+ .+/
case response
when /save/
save_config
'EXIT'
when /quit/
'EXIT'
when /^\d+$/
response.to_i
when /(\d+) (.+)/
echo([Regexp.last_match(1).to_i, Regexp.last_match(2).strip].to_s)
[Regexp.last_match(1).to_i, Regexp.last_match(2).strip]
else
response
end
end
def display_skill_selection_menu
skills = @user_settings.crossing_training || []
respond
print_solid_line ' Choose skills to train '
respond "Currently Training: #{skills.join(', ')}"
respond
@skills_list.each_with_index do |item, index|
respond "#{index + 1}. #{skills.include?(item) ? 'Stop' : 'Start'} training #{item}#{@skill_warnings[item] ? ' (' + @skill_warnings[item] + ')' : ''}"
end
respond "#{@skills_list.size + 1}. Return to previous menu"
case result = wait_for_response
when @skills_list.size + 1
display_edit_training_menu
when *(1..@skills_list.size).to_a
skill = @skills_list[result - 1]
skills.include?(skill) ? skills.delete(skill) : skills << skill
@user_settings.crossing_training = skills
display_skill_selection_menu
else
respond('Invalid Selection')
display_skill_selection_menu
end
end
def display_spell_data_editor(key, data_all)
data = data_all[key]
respond
print_solid_line ' Editing Spell Data '
print_solid_line ' to update a field, ;send # value'
respond "1. Abbrev: #{data['abbrev']}"
respond "2. Symbiosis? #{yn data['symbiosis']}"
respond "3. Custom cast message: #{data['cast']}"
respond('6. Remove spell')
respond('9. Return to previous menu')
case response = wait_for_response
when 2
data['symbiosis'] = !data['symbiosis']
display_spell_data_editor(key, data_all)
when 3
data.delete('cast')
display_spell_data_editor(key, data_all)
when 6
data_all.delete(key)
display_edit_spell_menu
when 9
display_edit_spell_menu
else
if response.is_a?(Array)
case response.first
when 1
data['abbrev'] = response.last
display_spell_data_editor(key, data_all)
when 3
data['cast'] = response.last
display_spell_data_editor(key, data_all)
end
else
respond('Invalid Selection')
display_spell_data_editor(key, data_all)
end
end
end
def display_edit_spell_menu
@user_settings.training_spells = {} unless @user_settings.training_spells
training_data = @user_settings.training_spells
warding = training_data['Warding'] || {}
aug = training_data['Augmentation'] || {}
utility = training_data['Utility'] || {}
respond
print_solid_line ' Spell Settings '
respond("1. Warding: #{warding}")
respond("2. Augmentation: #{aug}")
respond("3. Utility: #{utility}")
respond('9. Return to previous menu')
respond
case wait_for_response
when 1
display_spell_data_editor('Warding', training_data)
display_edit_spell_menu
when 2
display_spell_data_editor('Augmentation', training_data)
display_edit_spell_menu
when 3
display_spell_data_editor('Utility', training_data)
display_edit_spell_menu
when 9
display_spell_training_menu
else
respond('Invalid Selection')
display_edit_spell_menu
end
end
def display_spell_training_menu
respond
print_solid_line ' Magic Training Settings '
respond("1. Do you use spells to train?: #{yn @user_settings.train_with_spells}")
respond('2. Edit Spells')
respond('9. Return to previous menu')
respond
case wait_for_response
when 1
@user_settings.train_with_spells = !@user_settings.train_with_spells
display_spell_training_menu
when 2
display_edit_spell_menu
when 9
display_edit_training_menu
else
respond('Invalid Selection')
display_spell_training_menu
end
end
def display_edit_training_menu
respond
print_solid_line ' Character Settings for Crossing Training '
respond('1. Choose skills to train')
respond('2. Setup Magic Training')
respond('9. Return to main menu')
respond
case wait_for_response
when 1
display_skill_selection_menu
when 2
display_spell_training_menu
when 9
display_main_menu
else
respond('Invalid Selection')
display_edit_training_menu
end
end
def display_item_creation_menu(item = nil)
item ||= {}
respond
print_solid_line ' Edit Item, hold the item in your right hand then pick an option '
if item[:name]
respond "Editing: #{item[:adjective]} #{item[:name]} #{item[:is_leather] ? 'Leather' : 'Metallic'} #{item[:swappable] ? 'Swappable' : ''} #{item[:is_worn] ? 'Wearable' : ''} #{item[:hinders_lockpicking] ? 'Hinders locks' : ''} #{item[:tie_to] ? 'Tied to ' + item[:tie_to] : ''}".gsub(/\s+/, ' ')
else
respond 'New Item'
end
respond('1. Set Adjective/Name')
respond('2. Toggle Leather/Metallic for repair')
respond('3. Toggle Worn')
respond('4. Toggle Hinders Locksmithing')
respond('5. Set tie_to (hold tie item in left hand, or empty to clear)')
respond('6. Toggle Swappable weapon')
respond('7. Save item')
respond('8. Discard changes')
respond('9. Remove item')
case wait_for_response
when 1
item[:name] = nil
item[:adjective] = nil
/You glance down to see (a|some|an)(.*) in your right hand/ =~ DRC.bput('glance right', 'You glance down to see nothing', 'You glance down to see .* in your right hand')
long_item = Regexp.last_match(2)
parts = long_item.gsub(/\bwith\b/, '').split(' ').compact
if parts.size == 1
item[:name] = parts.last
elsif parts.size >= 2
parts.combination(2).to_a
.select { |adj, noun| /You tap/ =~ DRC.bput("tap my #{adj}.#{noun}", 'I could not find', 'You tap .* that you are holding') }
.each do |adj, noun|
item[:name] = noun
item[:adjective] = adj
end
unless item[:name]
item[:name] = parts.find { |name| /You tap/ =~ DRC.bput("tap my #{name}", 'I could not find', 'You tap .* that you are holding') }
end
end
display_item_creation_menu(item)
when 2
item[:is_leather] = !item[:is_leather]
display_item_creation_menu(item)
when 3
item[:is_worn] = !item[:is_worn]
display_item_creation_menu(item)
when 4
item[:hinders_lockpicking] = !item[:hinders_lockpicking]
display_item_creation_menu(item)
when 5
result = DRC.bput('glance left', 'You glance down to see nothing', 'You glance down to see .* in your left hand')
if result =~ /to see nothing/
item[:tie_to] = nil
else
/You glance down to see (.*) in your left hand/ =~ result
parts = left_hand.split(' ').compact
item[:tie_to] = parts.last
end
display_item_creation_menu(item)
when 6
item[:swappable] = !item[:swappable]
display_item_creation_menu(item)
when 7
@gearlist.reject! { |gear| gear[:name] == item[:name] && gear[:adjective] == item[:adjective] }
@gearlist << item
@user_settings.gear = @gearlist
display_gear_setup_menu
when 8
display_gear_setup_menu
when 9
@gearlist.reject! { |gear| gear[:name] == item[:name] && gear[:adjective] == item[:adjective] }
display_gear_setup_menu
else
respond('Invalid Selection')
display_item_creation_menu(item)
end
end
def display_gear_setup_menu
@gearlist = @user_settings.gear
respond
print_solid_line ' Edit gear '
respond('1. Add new item')
@gearlist.each_with_index do |item, index|
respond "#{index + 2}. Edit: #{item[:adjective]} #{item[:name]} #{item[:is_leather] ? 'leather' : 'metallic'} #{item[:swappable] ? 'swappable' : ''} #{item[:is_worn] ? 'wearable' : ''} #{item[:hinders_lockpicking] ? 'hinders locks' : ''} #{item[:tie_to] ? 'tied to ' + item[:tie_to] : ''}".gsub(/\s+/, ' ')
end
respond "#{@gearlist.size + 2}. Return to previous menu"
respond
case result = wait_for_response
when 1
display_item_creation_menu
when @gearlist.size + 2
display_main_menu
when *([email protected] + 1).to_a
display_item_creation_menu(@gearlist[result - 2].dup)
else
respond('Invalid Selection')
display_gear_setup_menu
end
end
def display_main_menu
respond
print_solid_line ' Main Menu '
respond('1. Edit character training settings')
respond('2. Edit character combat settings (not added yet)')
respond('3. Edit Gear')
respond('9. Save and exit')
respond
case wait_for_response
when 1
display_edit_training_menu
when 2
display_main_menu
when 3
display_gear_setup_menu
when 9
save_config
else
respond('Invalid Selection')
display_main_menu
end
end
def save_config(save = true)
save_character_profile(@user_settings.to_h) if save
end
end
SetupConfig.new