View Single Post
04-28-24, 10:27 AM   #3
Sharpedge
A Theradrim Guardian
 
Sharpedge's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2022
Posts: 68
I tried this and it shows as 0 earned for the week.....I even added debug print and it shows o. I'll have to keep at it. But thank you for the reference.

Code:
local function UpdatePvPStatsFrame()
    if not IsAddOnLoaded("Blizzard_PVPUI") then
        LoadAddOn("Blizzard_PVPUI")
    end

    C_Timer.After(2, function()  -- Delay for 2 seconds to ensure the AddOn is fully loaded and ready
        local conquestInfo = C_CurrencyInfo.GetCurrencyInfo(Constants.CurrencyConsts.CONQUEST_CURRENCY_ID)
        local weeklyProgress = C_WeeklyRewards.GetConquestWeeklyProgress()
        local honorInfo = C_CurrencyInfo.GetCurrencyInfo(HONOR_CURRENCY_ID)
        local lifetimeHonorableKills, _ = GetPVPLifetimeStats()
        local honorLevel = UnitHonorLevel("player")
        local currentConquestPoints = conquestInfo.quantity
        local conquestCap = conquestInfo.maxQuantity;  -- Dynamically fetch the current conquest cap
        local earnedThisWeek = conquestInfo.quantityEarnedThisWeek  -- Total conquest points earned this week
		
		print("Current Conquest Points: ", conquestInfo.quantity)
        print("Earned This Week: ", conquestInfo.quantityEarnedThisWeek)
        print("Weekly Cap: ", conquestInfo.maxQuantity)

        if not conquestCap or conquestCap == 0 then
            conquestCap = 1350  
        end

        local rating = GetPersonalRatedInfo(SOLO_SHUFFLE_INDEX)
        local soloShuffleRating = rating or "N/A"

        -- Display data
        pvpStatsFrame.honorableKillsValue:SetText(lifetimeHonorableKills)
        pvpStatsFrame.conquestValue:SetText(currentConquestPoints)
        pvpStatsFrame.conquestCapValue:SetText(earnedThisWeek .. " / " .. conquestCap)
        pvpStatsFrame.honorValue:SetText(honorInfo.quantity)
        pvpStatsFrame.honorLevelValue:SetText(honorLevel)
        pvpStatsFrame.soloShuffleRatingValue:SetText(soloShuffleRating)

        -- Adjust buttons based on PvP availability
        local canUseRated = C_PvP.CanPlayerUseRatedPVPUI()
        local canUsePremade = C_LFGInfo.CanPlayerUsePremadeGroup()

        if canUseRated then
            PVPQueueFrame_SetCategoryButtonState(PVPQueueFrame.CategoryButton2, true)
            PVPQueueFrame.CategoryButton2.tooltip = nil
        end

        if canUsePremade then
            PVPQueueFrame_SetCategoryButtonState(PVPQueueFrame.CategoryButton3, true)
            PVPQueueFrame.CategoryButton3.tooltip = nil
        end
    end)
end

-- Registering events to update PvP stats when relevant data changes
pvpStatsFrame:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
pvpStatsFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
pvpStatsFrame:RegisterEvent("WEEKLY_REWARDS_UPDATE")
pvpStatsFrame:SetScript("OnEvent", UpdatePvPStatsFrame)
pvpStatsFrame:SetScript("OnShow", UpdatePvPStatsFrame)
EDIT:
I forgot to add this
Code:
local progress = math.min(currencyInfo.totalEarned, maxProgress);
....so it's all good now.

Last edited by Sharpedge : 04-28-24 at 01:53 PM.
  Reply With Quote