Quantcast

Simplify using common Lua idiom to set default values.

Johnny C. Lam [11-15-13 - 19:56]
Simplify using common Lua idiom to set default values.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1170 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCondition.lua
conditions/BuffSnapshot.lua
conditions/LastSnapshot.lua
conditions/PaperDoll.lua
conditions/TickTime.lua
diff --git a/OvaleCondition.lua b/OvaleCondition.lua
index c5b12ed..daea14a 100644
--- a/OvaleCondition.lua
+++ b/OvaleCondition.lua
@@ -107,7 +107,7 @@ end

 OvaleCondition.ParseCondition = function(condition, defaultTarget)
 	defaultTarget = defaultTarget or "player"
-	local target = condition.target and condition.target or defaultTarget
+	local target = condition.target or defaultTarget
 	if target == "target" then
 		target = OvaleCondition.defaultTarget
 	end
@@ -161,8 +161,8 @@ OvaleCondition.TestValue = function(start, ending, value, origin, rate, comparat
 		return nil
 	end

-	start = start and start or 0
-	ending = (start and ending) and ending or math.huge
+	start = start or 0
+	ending = ending or math.huge

 	if not comparator then
 		if start < ending then
diff --git a/conditions/BuffSnapshot.lua b/conditions/BuffSnapshot.lua
index a09b1ce..ec86406 100644
--- a/conditions/BuffSnapshot.lua
+++ b/conditions/BuffSnapshot.lua
@@ -26,7 +26,7 @@ do
 		auraFound[statName] = nil
 		local start, ending = state:GetAura(target, auraId, filter, mine, auraFound)
 		local value = auraFound[statName]
-		value = value and value or defaultValue
+		value = value or defaultValue
 		return TestValue(start, ending, value, start, 0, comparator, limit)
 	end

@@ -38,7 +38,7 @@ do
 		auraFound[statName] = nil
 		local start, ending = state:GetAura(target, auraId, filter, mine, auraFound)
 		local value = auraFound[statName]
-		value = value and value or defaultValue
+		value = value or defaultValue
 		if condition.unlimited ~= 1 and value > 100 then
 			value = 100
 		end
diff --git a/conditions/LastSnapshot.lua b/conditions/LastSnapshot.lua
index 7582ac1..de68eae 100644
--- a/conditions/LastSnapshot.lua
+++ b/conditions/LastSnapshot.lua
@@ -23,7 +23,7 @@ do
 		local target = ParseCondition(condition, "target")
 		local guid = OvaleGUID:GetGUID(target)
 		local value = OvaleFuture:GetLastSpellInfo(guid, spellId, statName)
-		value = value and value or defaultValue
+		value = value or defaultValue
 		return Compare(value, comparator, limit)
 	end

@@ -33,7 +33,7 @@ do
 		local target = ParseCondition(condition)
 		local guid = OvaleGUID:GetGUID(target)
 		local value = OvaleFuture:GetLastSpellInfo(guid, spellId, statName)
-		value = value and value or defaultValue
+		value = value or defaultValue
 		if condition.unlimited ~= 1 and value > 100 then
 			value = 100
 		end
diff --git a/conditions/PaperDoll.lua b/conditions/PaperDoll.lua
index 724ab71..9db4f3d 100644
--- a/conditions/PaperDoll.lua
+++ b/conditions/PaperDoll.lua
@@ -19,7 +19,7 @@ do
 	local function PaperDoll(statName, defaultValue, condition)
 		local comparator, limit = condition[1], condition[2]
 		local value = OvalePaperDoll.stat[statName]
-		value = value and value or defaultValue
+		value = value or defaultValue
 		return Compare(value, comparator, limit)
 	end

@@ -27,7 +27,7 @@ do
 	local function PaperDollCritChance(statName, defaultValue, condition)
 		local comparator, limit = condition[1], condition[2]
 		local value = OvalePaperDoll.stat[statName]
-		value = value and value or defaultValue
+		value = value or defaultValue
 		if condition.unlimited ~= 1 and value > 100 then
 			value = 100
 		end
diff --git a/conditions/TickTime.lua b/conditions/TickTime.lua
index 93d539d..4df956a 100644
--- a/conditions/TickTime.lua
+++ b/conditions/TickTime.lua
@@ -43,7 +43,7 @@ do
 		auraFound.tick = nil
 		local start, ending = state:GetAura(target, auraId, filter, mine, auraFound)
 		local value = auraFound.tick
-		value = value and value or OvaleAura:GetTickLength(auraId)
+		value = value or OvaleAura:GetTickLength(auraId)
 		if value then
 			return Compare(value, comparator, limit)
 		end