-
Notifications
You must be signed in to change notification settings - Fork 177
/
avtalia.lic
70 lines (58 loc) · 1.97 KB
/
avtalia.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#avtalia
=end
custom_require.call(%w[events])
no_kill_all
no_pause_all
### Avtalia defines an UserVars listing items in your avtalia_array.
### Each cambrinth has a value representing how much mana is available
### as well as how fresh the reading is. It can be used by other scripts as-needed
class Avtalia
def initialize
@settings = get_settings
@avtalia_array = @settings.avtalia_array
exit if @avtalia_array.empty?
add_avtalia_flags
execute
end
def execute
loop do
pause 10
process_avtalia
end
end
def add_avtalia_flags
UserVars.avtalia = {}
@settings.avtalia_array.each do |camb|
first = camb['name'].split.first
second = camb['name'].split.last
short_reg = first == second ? /\b#{first}/i : /#{first}.*\b#{second}/i
Flags.add("avtalia-full-#{camb['name']}", /^Your.* #{short_reg} pulses brightly with Lunar energy/)
Flags.add("avtalia-focus-#{camb['name']}", /A.* #{short_reg}.* pulses? .+ (?<mana>\d+)/)
UserVars.avtalia[camb['name']] = { 'mana' => 0, 'cap' => camb['cap'], 'time_seen' => Time.now }
end
end
def process_avtalia
return if @avtalia_array.empty?
@avtalia_array.each do |camb|
if Flags["avtalia-focus-#{camb['name']}"]
UserVars.avtalia[camb['name']]['mana'] = Flags["avtalia-focus-#{camb['name']}"][:mana].to_i
UserVars.avtalia[camb['name']]['time_seen'] = Time.now
end
if Flags["avtalia-full-#{camb['name']}"]
UserVars.avtalia[camb['name']]['mana'] = camb['cap']
UserVars.avtalia[camb['name']]['time_seen'] = Time.now
end
Flags.reset("avtalia-full-#{camb['name']}")
Flags.reset("avtalia-focus-#{camb['name']}")
end
end
end
before_dying do
UserVars.avtalia = {}
get_settings.avtalia_array.each do |camb|
Flags.delete("avtalia-full-#{camb['name']}")
Flags.delete("avtalia-focus-#{camb['name']}")
end
end
Avtalia.new