2011-08-20 07:41:29 -04:00
|
|
|
ChoreTracker = LibStub('AceAddon-3.0'):NewAddon('ChoreTracker','AceConsole-3.0','AceEvent-3.0')
|
|
|
|
local core = ChoreTracker
|
|
|
|
|
2011-08-21 10:59:28 -04:00
|
|
|
local trackedInstances = {
|
|
|
|
['Baradin Hold'] = true,
|
|
|
|
['Firelands'] = true,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-20 07:41:29 -04:00
|
|
|
local defaults = {
|
|
|
|
profile = {
|
|
|
|
valorPoints = {},
|
|
|
|
lockouts = {},
|
2011-08-21 12:23:18 -04:00
|
|
|
updated = {},
|
2011-08-20 07:41:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function core:OnInitialize()
|
|
|
|
self.db = LibStub('AceDB-3.0'):New('ChoreTrackerDB',defaults,'Default')
|
|
|
|
end
|
|
|
|
|
|
|
|
function core:OnEnable()
|
2011-08-21 12:23:18 -04:00
|
|
|
local name = UnitName('player')
|
|
|
|
|
|
|
|
if self.db.profile.lockouts[name] == nil then
|
|
|
|
self.db.profile.lockouts[name] = {}
|
|
|
|
end
|
|
|
|
|
2011-08-21 14:10:05 -04:00
|
|
|
self:RegisterEvent('UPDATE_INSTANCE_INFO','UpdateChores')
|
2011-08-20 07:41:29 -04:00
|
|
|
end
|
|
|
|
|
2011-08-21 14:10:05 -04:00
|
|
|
function core:UpdateChores()
|
2011-08-21 00:03:50 -04:00
|
|
|
local level = UnitLevel('player')
|
2011-08-20 07:41:29 -04:00
|
|
|
|
2011-08-21 00:03:50 -04:00
|
|
|
if(level == 85) then
|
2011-08-21 14:10:05 -04:00
|
|
|
local _,_,_,earnedThisWeek = GetCurrencyInfo(396)
|
|
|
|
local name = UnitName('player')
|
|
|
|
|
|
|
|
--reset data if necessary
|
|
|
|
for k,v in pairs(self.db.profile.lockouts) do
|
|
|
|
for x,y in pairs(self.db.profile.lockouts[k]) do
|
|
|
|
if y.resetTime > time() then
|
|
|
|
self.db.profile.lockouts[k][x] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-08-21 12:48:18 -04:00
|
|
|
--store Valor Points
|
2011-08-21 00:03:50 -04:00
|
|
|
self.db.profile.valorPoints[name] = earnedThisWeek
|
2011-08-21 11:01:32 -04:00
|
|
|
|
2011-08-21 12:48:18 -04:00
|
|
|
--store Saved Instances
|
2011-08-21 11:01:32 -04:00
|
|
|
local savedInstances = GetNumSavedInstances()
|
2011-08-21 14:10:05 -04:00
|
|
|
for i = 1, savedInstances do
|
2011-08-21 10:59:28 -04:00
|
|
|
local instanceName,_,instanceReset,_,_,_,_,_,_,_,_,defeatedBosses = GetSavedInstanceInfo(i)
|
|
|
|
|
2011-08-21 12:23:18 -04:00
|
|
|
if trackedInstances[instanceName] == true then
|
2011-08-21 10:59:28 -04:00
|
|
|
if instanceReset > 0 then
|
2011-08-21 12:48:18 -04:00
|
|
|
self.db.profile.lockouts[name][instanceName] = {}
|
|
|
|
self.db.profile.lockouts[name][instanceName].defeatedBosses = defeatedBosses
|
|
|
|
self.db.profile.lockouts[name][instanceName].resetTime = time() + instanceReset
|
2011-08-21 10:59:28 -04:00
|
|
|
else
|
|
|
|
self.db.profile.lockouts[name][instanceName] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-08-21 00:03:50 -04:00
|
|
|
end
|
2011-08-20 07:41:29 -04:00
|
|
|
end
|