forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
discern.lic
80 lines (63 loc) · 2.53 KB
/
discern.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#discern
=end
custom_require.call(%w[common-arcana])
class Discern
def initialize
arg_definitions = [
[
{ name: 'reset', regex: /^reset$/i, optional: true, description: 'Delete existing discern data and re-discern spells.' },
],
[
{ name: 'set', regex: /^set/i, description: 'update total mana for a spell discern for sorcery or symbiosis' },
{ name: 'spell', regex: /^[A-z\s\-\']+$/i, description: 'spell to update (name or abbreviation) - must be in your yaml spell lists' },
{ name: 'mana', regex: /\d+/, description: 'total mana to set' }
],
[
{ name: 'check', regex: /^check/i, description: 'Check current discern data for a spell' },
{ name: 'spell', regex: /^[A-z\s\-\']+$/i, description: 'spell to check' }
]
]
args = parse_args(arg_definitions)
UserVars.discerns = {} if args.reset
settings = get_settings
spells = []
spells << settings.offensive_spells
spells << settings.buff_spells.values
spells << settings.combat_spell_training.values
spells << settings.training_spells.values
spells << settings.crafting_training_spells.values
spells << settings.waggle_sets.values.map(&:values)
spells.flatten!
if args.check
spell_to_check = spells.find { |spell| spell['name'] =~ /#{args.spell}/i || spell['abbrev'] =~ /#{args.spell}/i }
echo spell_to_check
echo UserVars.discerns[spell_to_check['abbrev']]
exit
end
if args.set
spell_to_update = spells
.select { |spell| spell['use_auto_mana'] }
.find { |spell| spell['name'] =~ /#{args.spell}/i || spell['abbrev'] =~ /#{args.spell}/i }
if !spell_to_update
echo "Could not find spell #{args.spell}. It must be in one of the following spell lists: offensive_spells, buff_spells, combat_spell_training, training_spells, crafting_training_spells, waggle_sets."
exit
end
spell_mana = spell_to_update['mana'].to_i
mana = args.mana.to_i
if mana <= spell_mana
echo 'Specified mana must be more than the minimum to cast the spell'
exit
end
DRCA.check_discern(spell_to_update, settings, true, mana - spell_mana)
exit
end
discern_spells(spells, settings)
end
def discern_spells(spells, settings)
spells
.select { |spell| spell['use_auto_mana'] }
.each { |spell| DRCA.check_discern(spell, settings) }
end
end
Discern.new