-
Notifications
You must be signed in to change notification settings - Fork 0
/
powertype.lua
76 lines (64 loc) · 1.95 KB
/
powertype.lua
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
local addon, dark_addon = ...
local powerType = { }
function powerType:actual()
local actual = UnitPower(self.unitID, self.type)
return actual or 0
end
function powerType:max()
local max = UnitPowerMax(self.unitID, self.type)
return max or 0
end
function powerType:deficit()
local deficit = self.max - self.actual
return deficit or 0
end
function powerType:deficitpercent()
local deficitpercent = (self.deficit / self.max) * 100
return deficitpercent or 0
end
function powerType:percent()
local percent = (self.actual / self.max) * 100
return percent or 0
end
function powerType:regen()
local regen = select(2, GetPowerRegen())
return regen or 0
end
function powerType:predict()
local ina, act = GetPowerRegen()
local predict = (self.actual + (act))
return predict or 0
end
function powerType:predictpercent()
local ina, act = GetPowerRegen()
local predictpercent = ((self.actual + (act)) / self.max) * 100
return predictpercent or 0
end
function powerType:regenpercent()
local regenpercent = (self.regen / self.max) * 100
return regenpercent or 0
end
function powerType:tomax()
local tomax = self.deficit / GetPowerRegen()
return tomax or 0
end
function dark_addon.environment.conditions.powerType(unit, power_type, power_type_name)
return setmetatable({
unitID = unit.unitID,
type = power_type,
type_name = power_type_name
}, {
__index = function(t, k)
if powerType[k] then
local result = powerType[k](t)
dark_addon.console.debug(4, 'power', 'blue', t.unitID .. '.power.' .. t.type .. '.' .. k .. ' = ' .. dark_addon.format(result))
return result
end
end,
__unm = function(t)
local result = powerType['actual'](t)
dark_addon.console.debug(4, 'power', 'blue', t.unitID .. '.power.' .. t.type_name .. '.actual' .. ' = ' .. dark_addon.format(result))
return result
end
})
end