---@param input string ---@param deliminer string ---@return table aura_env.Split = function(input, deliminer) local ret = {} for str in string.gmatch(input, "([^" .. deliminer .. "]+)") do table.insert(ret, str) end return ret end ---@class BattlepassInfo ---@field week number ---@field getRew number ---@field dayRewardComplete number ---@field lostDay number ---@field cost number ---@field currentDayOnlineTimeMinutes number ---@field currentDayOnlineTimeMilliseconds number BattlepassInfo = { PingApi = function() SendAddonMessage('UIMSG_TO_SERVER', "UIMSG_GET_ONLINETIME_DAY" .. "\t", 'WHISPER', UnitName('player')) end, ParseApi = function(msg) local packets = aura_env.Split(msg, ":") if packets[1] ~= "UISMSG_EVT_WEEK_TIME" then return end BattlepassInfo.currentDayOnlineTimeMilliseconds = tonumber(packets[2]) BattlepassInfo.week = tonumber(packets[3]) + 1 BattlepassInfo.getRew = tonumber(packets[4]) BattlepassInfo.dayRewardComplete = tonumber(packets[5]) BattlepassInfo.lostDay = tonumber(packets[6]) BattlepassInfo.cost = tonumber(packets[7]) BattlepassInfo.currentDayOnlineTimeMinutes = math.ceil(BattlepassInfo.currentDayOnlineTimeMilliseconds / 60000) if BattlepassInfo.currentDayOnlineTimeMinutes >= 120 then print(BattlepassInfo) end end, } setmetatable(BattlepassInfo, { __call = BattlepassInfo.PingApi, __index = BattlepassInfo, __tostring = function() local ret = {} for k, v in pairs(BattlepassInfo) do table.insert(ret, k .. ": " .. tostring(v)) end return table.concat(ret, "\n") end }) for k, v in pairs(BattlepassInfo) do if type(v) == "number" then BattlepassInfo[k] = 0 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')