Documentation, minor cleanup

Scott Yeskie [06-04-14 - 11:00]
Documentation, minor cleanup
Filename
CyrHUD.lua
CyrHUD.txt
classes/Battle.lua
diff --git a/CyrHUD.lua b/CyrHUD.lua
index 0186531..5b413be 100644
--- a/CyrHUD.lua
+++ b/CyrHUD.lua
@@ -149,6 +149,7 @@ end
 ----------------------------------------------
 CyrHUD.battles = {}
 CyrHUD.add = function(keepID)
+    --TODO: Need to resume battle if ends before fade
     if CyrHUD.battles[keepID] == nil then
         d("Adding " .. GetKeepName(keepID))
         CyrHUD.battles[keepID] = CyrHUD.Battle(keepID)
@@ -171,6 +172,8 @@ CyrHUD.updateAll = function()
     end
 end

+--TODO: This should be called on init and alow rate (10-15s). Rest should be event based
+--TODO: Add outposts and resources
 CyrHUD.scanKeeps = function()
     for i=3,20 do
         CyrHUD.checkAdd(i)
@@ -180,6 +183,8 @@ end
 ------------------------------------------------------------------------
 -- Initialization
 ------------------------------------------------------------------------
+--TODO: Properly setup on Addon init or playerLoad
+--TODO: only show while in Cyrodiil
 local function init()
     d("Adding keep info")
     EVENT_MANAGER:RegisterForUpdate("CyrHUBKeepCheck", 5000, function()
@@ -198,12 +203,12 @@ SLASH_COMMANDS["/cyrhud"] = function()
         EVENT_MANAGER:UnregisterForUpdate("CyrHUBKeepCheck")
         EVENT_MANAGER:UnregisterForUpdate("CyrHUBUIUpdate")
         EVENT_MANAGER:UnregisterForUpdate("ZDBUpdateAPCount")
-        WYK_QuestTracker_MQT:SetAlpha(1)
+        if WYK_QuestTracker_MQT then WYK_QuestTracker_MQT:SetAlpha(1) end
         CyrHUD_UI:SetHidden(true)
         showCyrHUD = false
     else
         WYK_QuestTracker_MQT:SetAlpha(0)
-        CyrHUD_UI:SetHidden(false)
+        if WYK_QuestTracker_MQT then CyrHUD_UI:SetHidden(false) end
         init()
         showCyrHUD = true
     end
diff --git a/CyrHUD.txt b/CyrHUD.txt
index d75c621..e1af436 100644
--- a/CyrHUD.txt
+++ b/CyrHUD.txt
@@ -1,6 +1,6 @@
 ## APIVersion: 100004
 ## Title: CyrHUD
-## Version: 1.0
+## Version: 0.9.0
 ## Author: Sasky

 classes/Battle.lua
diff --git a/classes/Battle.lua b/classes/Battle.lua
index d5dc882..b8342f8 100644
--- a/classes/Battle.lua
+++ b/classes/Battle.lua
@@ -9,15 +9,18 @@ if CyrHUD == nil then
     CyrHUD = {}
 end

+-- Setup class
 CyrHUD.Battle = {}
 CyrHUD.Battle.__index = CyrHUD.Battle
-
 setmetatable(CyrHUD.Battle, {
     __call = function (cls, ...)
         return cls.new(...)
     end,
 })

+----------------------------------------------
+-- Creation
+----------------------------------------------
 CyrHUD.Battle.new = function(keepID)
     local self = setmetatable({}, CyrHUD.Battle)
     self.startBattle = GetTimeStamp()
@@ -50,6 +53,14 @@ function CyrHUD.Battle:update()
     end
 end

+----------------------------------------------
+-- Getters
+----------------------------------------------
+
+--[[
+    @return red, green, blue, alpha for background color
+        all in range [0,1]
+--]]
 function CyrHUD.Battle:getBGColor()
     if self.endBattle then
         if self.defender == GetUnitAlliance("player") then
@@ -65,6 +76,11 @@ function CyrHUD.Battle:getBGColor()
     return 0,0,0,.3
 end

+--[[
+    @return elapsed time of battle event
+        if an end is specified, will show total lenth
+        otherwise will show current length
+--]]
 function CyrHUD.Battle:getDuration()
     local time = self.endBattle or GetTimeStamp()
     local delta = GetDiffBetweenTimeStamps(time, self.startBattle)
@@ -72,6 +88,11 @@ function CyrHUD.Battle:getDuration()
     return out
 end

+--[[
+    @return numSiege, color
+        numSiege - number of defending siege equipment
+        color - color for the defending faction
+]]
 function CyrHUD.Battle:getDefSiege()
     local siege = self.siege[self.defender]
     --d(self.keepName .. ":" ..  siege .. " (" .. self.defender .. ")")
@@ -79,6 +100,12 @@ function CyrHUD.Battle:getDefSiege()
     return siege, CyrHUD.info[self.defender].color
 end

+--[[
+    @return numSiege, color
+        numSiege - number of defending siege equipment
+        color - color for the defending faction
+    @note If two attacking factions, will sum the siege and show white for color
+]]
 function CyrHUD.Battle:getAttSiege()
     local siege = self.siege
     siege[self.defender] = nil
@@ -101,12 +128,22 @@ function CyrHUD.Battle:getAttSiege()
     return count, color
 end

+--[[
+    @return true iff battle is active
+        a) keep is under attack status
+        b) there is siege setup at keep
+--]]
 function CyrHUD.Battle:isBattle()
     if self.keepUA then return true end
     local count = (self.siege[ALLIANCE_ALDMERI_DOMINION] + self.siege[ALLIANCE_DAGGERFALL_COVENANT] + self.siege[ALLIANCE_EBONHEART_PACT])
     return count > 0
 end

+--[[
+    @return icon for battle
+        icon is based on resource type, faction, and whether it is under attack
+    @see CyrHUD.info
+]]
 function CyrHUD.Battle:getIcon()
     if self.keepUA then
         return CyrHUD.info[self.defender][self.keepType].iconua