PageRenderTime 318ms CodeModel.GetById 184ms app.highlight 3ms RepoModel.GetById 129ms app.codeStats 0ms

/Tukui/modules/datatext/power.lua

http://github.com/Asphyxia/Tukui
Lua | 56 lines | 42 code | 11 blank | 3 comment | 5 complexity | 23ff8444654b1a537a179024aab9efd3 MD5 | raw file
 1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 2
 3--------------------------------------------------------------------
 4-- player power (attackpower or power depending on what you have more of)
 5--------------------------------------------------------------------
 6
 7if C["datatext"].power and C["datatext"].power > 0 then
 8	local Stat = CreateFrame("Frame")
 9	Stat:SetFrameStrata("HIGH")
10	Stat:SetFrameLevel(3)
11
12	local Text  = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
13	Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
14	T.PP(C["datatext"].power, Text)
15
16	local int = 1
17
18	local function Update(self, t)
19		int = int - t
20		local base, posBuff, negBuff = UnitAttackPower("player")
21		local effective = base + posBuff + negBuff
22		local Rbase, RposBuff, RnegBuff = UnitRangedAttackPower("player")
23		local Reffective = Rbase + RposBuff + RnegBuff
24
25
26		healpwr = GetSpellBonusHealing()
27
28		Rattackpwr = Reffective
29		spellpwr2 = GetSpellBonusDamage(7)
30		attackpwr = effective
31
32		if healpwr > spellpwr2 then
33			spellpwr = healpwr
34		else
35			spellpwr = spellpwr2
36		end
37
38		if attackpwr > spellpwr and select(2, UnitClass("Player")) ~= "HUNTER" then
39			pwr = attackpwr
40			tp_pwr = L.datatext_playerap
41		elseif select(2, UnitClass("Player")) == "HUNTER" then
42			pwr = Reffective
43			tp_pwr = L.datatext_playerap
44		else
45			pwr = spellpwr
46			tp_pwr = L.datatext_playersp
47		end
48		if int < 0 then
49			Text:SetText(tp_pwr.." "..T.datacolor.. pwr)      
50			int = 1
51		end
52	end
53
54	Stat:SetScript("OnUpdate", Update)
55	Update(Stat, 10)
56end