forked from beerman212/BuffTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrackedMob.lua
More file actions
54 lines (44 loc) · 1.15 KB
/
TrackedMob.lua
File metadata and controls
54 lines (44 loc) · 1.15 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
TrackedMob = {}
function TrackedMob.new(target)
local self = {}
self.target = target or {}
self.buffs = T{}
setmetatable(self, {__index = TrackedMob})
return self
end
function TrackedMob:death()
self = nil
end
function TrackedMob:get_mob_id()
return target.id or -1
end
function TrackedMob:get_mob_name()
return target.name or "Unknown"
end
function TrackedMob:has_buffs()
return not self.buffs:empty()
end
function TrackedMob:add_buff(buff)
if self:has_buffs() then
if self.buffs:containskey(buff.buff_id) then
local current_buff = self.buffs[buff.buff_id]
if buff.spell_info.overrides and buff.spell_info.overrides:contains(current_buff:get_spell_id()) then
self.buffs[buff.buff_id] = buff
end
else
self.buff[buff.buff_id] = buff
end
else
self.buffs[buff.buff_id] = buff
end
end
function TrackedMob:remove_buff(buff)
if self:has_buffs() then
if self.buffs:containskey(buff.buff_id) then
self.buffs[buff.buff_id] = nil
end
end
end
function TrackedMob:clear_buffs()
self.buffs:clear()
end