From 2e3f6d1ba106bb836c799d44ce0af8eb8b323db3 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Fri, 26 Oct 2012 05:24:23 +0000 Subject: [PATCH] Remove the use of some temporary tables. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@622 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleCondition.lua | 21 +++------------------ OvaleData.lua | 22 ++++++++-------------- OvaleState.lua | 4 +--- 3 files changed, 12 insertions(+), 35 deletions(-) diff --git a/OvaleCondition.lua b/OvaleCondition.lua index 5dd990a..189cfc9 100644 --- a/OvaleCondition.lua +++ b/OvaleCondition.lua @@ -977,12 +977,7 @@ OvaleCondition.conditions= damage = function(condition) local spellId = condition[1] - local ret = OvaleData:GetDamage(spellId, - { - combo = OvaleState.state.combo, - attackpower = UnitAttackPower("player"), - spellpower = GetSpellBonusDamage(2) - }) + local ret = OvaleData:GetDamage(spellId, UnitAttackPower("player"), GetSpellBonusDamage(2), OvaleState.state.combo) return 0, nil, ret * OvaleAura:GetDamageMultiplier(spellId), 0, 0 end, @@ -1567,12 +1562,7 @@ OvaleCondition.conditions= lastspellestimateddamage = function(condition) local spellId = condition[1] - local ret = OvaleData:GetDamage(spellId, - { - combo = OvaleFuture.lastSpellCombo[spellId], - attackpower = OvaleFuture.lastSpellAP[spellId], - spellpower = OvaleFuture.lastSpellSP[spellId] - }) + local ret = OvaleData:GetDamage(spellId, OvaleFuture.lastSpellAP[spellId], OvaleFuture.lastSpellSP[spellId], OvaleFuture.lastSpellCombo[spellId]) return 0, nil, ret * (OvaleFuture.lastSpellDM[spellId] or 0), 0, 0 end, @@ -2414,12 +2404,7 @@ OvaleCondition.conditions= ticks = function(condition) -- TODO: extend to allow checking an existing DoT (how to get DoT duration?) local spellId = condition[1] - local duration, tickLength = OvaleData:GetDuration(spellId, - { - combo = OvaleState.state.combo, - holy = OvaleState.state.holy, - spellHaste = OvaleAura.spellHaste, - }) + local duration, tickLength = OvaleData:GetDuration(spellId, OvaleAura.spellHaste, OvaleState.state.combo, OvaleState.state.holy) if tickLength then local numTicks = floor(duration / tickLength + 0.5) return compare(numTicks, condition[2], condition[3]) diff --git a/OvaleData.lua b/OvaleData.lua index 0a74e08..4a124fa 100644 --- a/OvaleData.lua +++ b/OvaleData.lua @@ -517,18 +517,15 @@ function OvaleData:GetComputedSpellCD(spellId) end --Compute the damage of the given spell. -function OvaleData:GetDamage(spellId, state) +function OvaleData:GetDamage(spellId, attackpower, spellpower, combo) local si = self.spellInfo[spellId] if not si then return nil end local damage = si.base or 0 - local combo, attackpower, spellpower = 0, 0, 0 - if state then - combo = state.combo or combo - attackpower = state.attackpower or attackpower - spellpower = state.spellpower or spellpower - end + combo = combo or 0 + attackpower = attackpower or 0 + spellpower = spellpower or 0 if si.bonuscp then damage = damage + si.bonuscp * combo end @@ -544,16 +541,13 @@ function OvaleData:GetDamage(spellId, state) return damage end -function OvaleData:GetDuration(spellId, state) +function OvaleData:GetDuration(spellId, spellHaste, combo, holy) local si = self.spellInfo[spellId] if si and si.duration then local duration = si.duration - local combo, holy, spellHaste = 0, 1, 1 - if state then - combo = state.combo or combo - holy = state.holy or holy - spellHaste = state.spellHaste or spellHaste - end + spellHaste = spellHaste or 1 + combo = combo or 0 + holy = holy or 1 if si.adddurationcp then duration = duration + si.adddurationcp * combo end diff --git a/OvaleState.lua b/OvaleState.lua index 8c4dffc..18db703 100644 --- a/OvaleState.lua +++ b/OvaleState.lua @@ -118,7 +118,6 @@ function OvaleState:AddSpellToStack(spellId, startCast, endCast, nextCast, nocd, end local newSpellInfo = OvaleData.spellInfo[spellId] - local oldState = { combo = self.state.combo, holy = self.state.holy } self.lastSpellId = spellId --On enregistre les infos sur le sort en cours @@ -310,8 +309,7 @@ function OvaleState:AddSpellToStack(spellId, startCast, endCast, nextCast, nocd, newAura.mine = true --Optionnellement, on va regarder la durée du buff if auraSpellInfo and auraSpellInfo.duration then - oldState.spellHaste = OvaleAura.spellHaste - duration = OvaleData:GetDuration(auraSpellId, oldState) + duration = OvaleData:GetDuration(auraSpellId, OvaleAura.spellHaste, self.state.combo, self.state.holy) elseif stacks ~= "refresh" and stacks > 0 then stacks = 1 end -- 1.7.9.5