Finish work on battlepasstimer

Now auto claims when cooked :)
This commit is contained in:
2024-04-09 11:01:29 +02:00
parent 0ca35636f2
commit d7796a1eac
3 changed files with 21 additions and 11 deletions

View File

@@ -1,3 +1,15 @@
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
if not WeakAurasSaved.Cyka.LoginInfo then WeakAurasSaved.Cyka.LoginInfo = {} end
Today = date("%Y-%m-%d")
if not WeakAurasSaved.Cyka.LoginInfo[Today] then WeakAurasSaved.Cyka.LoginInfo[Today] = {} end
if not WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")] then
WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")] = {
onlineTimeInMinutes = 0,
claimed = 0,
}
end
---@param input string
---@param deliminer string
---@return table<string>
@@ -33,10 +45,16 @@ BattlepassInfo = {
BattlepassInfo.cost = tonumber(packets[7])
BattlepassInfo.currentDayOnlineTimeMinutes = math.ceil(BattlepassInfo.currentDayOnlineTimeMilliseconds / 60000)
WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")].onlineTimeInMinutes = BattlepassInfo.currentDayOnlineTimeMinutes
WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")].claimed = BattlepassInfo.dayRewardComplete
if BattlepassInfo.currentDayOnlineTimeMinutes >= 120 then
print(BattlepassInfo)
BattlepassInfo.DoClaim()
end
end,
DoClaim = function()
SendAddonMessage('UIMSG_TO_SERVER', "UIMSG_WEEKLY_REW_GET" .. "\t", 'WHISPER', UnitName('player'))
end
}
setmetatable(BattlepassInfo, {
__call = BattlepassInfo.PingApi,
@@ -56,11 +74,3 @@ for k, v in pairs(BattlepassInfo) do
end
end
BattlepassInfo()
-- TODO: Make DINGDINGDING when cooked
-- TODO: Make hide when reward complete
-- dayRewardComplete = 1 for cooked (or complete?)
-- delta < 0 for day complete
-- in this case BattlepassInfo.currentDayOnlineTimeMinutes >= 120
-- TODO: To auto claim reward do:
-- UENR:SendPacket('UIMSG_WEEKLY_REW_GET')