From 2f9690f275148c7a32dfea1994825e54a7c42bd2 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Mon, 5 May 2014 18:03:08 +0000 Subject: [PATCH] Add BuffRemainsOnAny() condition. BuffRemainsOnAny() returns the number of seconds before the given aura expires across all targets. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1378 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- conditions/BuffRemainsOnAny.lua | 51 +++++++++++++++++++++++++++++++++++++++ conditions/files.xml | 1 + 2 files changed, 52 insertions(+) create mode 100644 conditions/BuffRemainsOnAny.lua diff --git a/conditions/BuffRemainsOnAny.lua b/conditions/BuffRemainsOnAny.lua new file mode 100644 index 0000000..01830f2 --- /dev/null +++ b/conditions/BuffRemainsOnAny.lua @@ -0,0 +1,51 @@ +--[[-------------------------------------------------------------------- + Ovale Spell Priority + Copyright (C) 2013, 2014 Johnny C. Lam + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License in the LICENSE + file accompanying this program. +--]]-------------------------------------------------------------------- + +local _, Ovale = ... + +do + local OvaleCondition = Ovale.OvaleCondition + local OvaleState = Ovale.OvaleState + + local Compare = OvaleCondition.Compare + local ParseCondition = OvaleCondition.ParseCondition + local TestValue = OvaleCondition.TestValue + local state = OvaleState.state + + --- Get the remaining time in seconds before the aura expires across all targets. + -- @name BuffRemainsOnAny + -- @paramsig number or boolean + -- @param id The spell ID of the aura or the name of a spell list. + -- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more. + -- @param number Optional. The number to compare against. + -- @param stacks Optional. The minimum number of stacks of the aura required. + -- Defaults to stacks=1. + -- Valid values: any number greater than zero. + -- @param any Optional. Sets by whom the aura was applied. If the aura can be applied by anyone, then set any=1. + -- Defaults to any=0. + -- Valid values: 0, 1. + -- @return The number of seconds. + -- @return A boolean value for the result of the comparison. + -- @see DebuffRemainsOnAny + + local function BuffRemainsOnAny(condition) + local auraId, comparator, limit = condition[1], condition[2], condition[3] + local _, filter, mine = ParseCondition(condition) + + local count, startChangeCount, endingChangeCount, startFirst, endingLast = state:AuraCount(auraId, filter, mine, condition.stacks) + if count > 0 then + local start, ending = startFirst, endingLast + return TestValue(start, math.huge, ending - start, start, -1, comparator, limit) + end + return Compare(0, comparator, limit) + end + + OvaleCondition:RegisterCondition("buffremainsonany", false, BuffRemainsOnAny) + OvaleCondition:RegisterCondition("debuffremainsonany", false, BuffRemainsOnAny) +end diff --git a/conditions/files.xml b/conditions/files.xml index 707c545..4f2b019 100644 --- a/conditions/files.xml +++ b/conditions/files.xml @@ -10,6 +10,7 @@