WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Need some more help.... (https://www.wowinterface.com/forums/showthread.php?t=59861)

Sharpedge 04-28-24 09:41 AM

Need some more help....
 
I now have ran into a small issue. In my PvP Stats window it will display the Conquest Cap. What is showing is the "current" conquest and not the total towards the cap. Can anyone shed some light on this please?

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 currencyInfo = C_CurrencyInfo.GetCurrencyInfo(Constants.CurrencyConsts.CONQUEST_CURRENCY_ID);
        local conquestCap = currencyInfo.maxQuantity;  -- Dynamically fetch the current conquest cap

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

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

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

        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

pvpStatsFrame:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
pvpStatsFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
pvpStatsFrame:RegisterEvent("WEEKLY_REWARDS_UPDATE")
pvpStatsFrame:SetScript("OnEvent", UpdatePvPStatsFrame)
pvpStatsFrame:SetScript("OnShow", UpdatePvPStatsFrame)


Xrystal 04-28-24 10:13 AM

It looks like it could be the max for that stage - like maxXP per level etc.

Here's the block of code where they use the value and that's what makes me think that, but maybe your PvP knowledge will understand it more.

https://github.com/Gethe/wow-ui-sour...VPUI.lua#L1977

Sharpedge 04-28-24 10:27 AM

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.


All times are GMT -6. The time now is 07:31 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI