Add T4/T6 phase data, phase selector bar, and latest-phase progress
Data: T4 (Karazhan/Gruul/Magtheridon) and T6 (Black Temple/Hyjal) BiS lists for all 9 classes x 3 specs, sourced from wowtbc.gg page-data JSON. Phase registry gains PHASE_ORDER-driven ordering, GetLatestPhase and ResolvePhase fallback. Stat scanning takes MAX across all alias-key stats (spell damage schools, healing, haste/crit/mp5 ratings). UI: horizontal phase selector bar between title and summary with a progress fill that measures completion against the latest available phase regardless of the selected phase. CompareGear returns latestPhase and latestCompletionRatio; GetCompletionRatio delegates to a new StatRatio helper. Default phase switched to T6.
This commit is contained in:
1 parent
5ff421bd09
commit
c59a705d05
4 files changed
+1140
-37
No files matched your search
+66
-4
@@ -5,7 +5,7 @@ ns.Amibis = Amibis
|
||||
Amibis.version = "1.0.0"
|
||||
|
||||
local DEFAULT_AMIBIS_DB = {
|
||||
selectedPhase = "T5",
|
||||
selectedPhase = "T6",
|
||||
}
|
||||
|
||||
local DEFAULT_AMIBIS_CHAR_DB = {
|
||||
@@ -60,6 +60,34 @@ function Amibis:GetStatKeysForSpec(class, spec)
|
||||
return GetUpgradeStatKeys(class, spec)
|
||||
end
|
||||
|
||||
function Amibis:StatRatio(equippedStats, bisStats, class, spec)
|
||||
if not equippedStats or not bisStats then return 0 end
|
||||
|
||||
local statKeys = GetUpgradeStatKeys(class, spec)
|
||||
local count, sum = 0, 0
|
||||
for _, statKey in ipairs(statKeys) do
|
||||
local bis = bisStats[statKey] or 0
|
||||
if bis > 0 then
|
||||
local current = equippedStats[statKey] or 0
|
||||
local ratio = current / bis
|
||||
if ratio > 1 then ratio = 1 end
|
||||
sum = sum + ratio
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
if count == 0 then return 0 end
|
||||
return sum / count
|
||||
end
|
||||
|
||||
function Amibis:GetCompletionRatio(data)
|
||||
if not data then return 0 end
|
||||
if data.statsComplete and data.bisStats then
|
||||
return self:StatRatio(data.equippedStats, data.bisStats, data.class, data.spec)
|
||||
end
|
||||
return (data.bisCount or 0) / math.max(1, data.totalSlots or 1)
|
||||
end
|
||||
|
||||
local function InitializeDB()
|
||||
if not AmibisDB then
|
||||
AmibisDB = CopyTable(DEFAULT_AMIBIS_DB)
|
||||
@@ -183,9 +211,14 @@ local STAT_MAP = {
|
||||
["ITEM_MOD_HEALING_SHORT"] = "healing",
|
||||
}
|
||||
|
||||
local MAX_AGGREGATE_STATS = {
|
||||
-- Stats that multiple WoW API keys map to (school-specific spell damage, haste
|
||||
-- rating, etc.): only one alias is ever active, so take MAX instead of SUM.
|
||||
local ALIAS_STATS = {
|
||||
healing = true,
|
||||
spellDamage = true,
|
||||
mp5 = true,
|
||||
haste = true,
|
||||
crit = true,
|
||||
}
|
||||
|
||||
function Amibis:ScanItemStats(itemID)
|
||||
@@ -203,7 +236,7 @@ function Amibis:ScanItemStats(itemID)
|
||||
for wowKey, ourKey in pairs(STAT_MAP) do
|
||||
local value = stats[wowKey]
|
||||
if value then
|
||||
if MAX_AGGREGATE_STATS[ourKey] then
|
||||
if ALIAS_STATS[ourKey] then
|
||||
local current = result[ourKey]
|
||||
if not current or value > current then
|
||||
result[ourKey] = value
|
||||
@@ -247,7 +280,7 @@ end
|
||||
function Amibis:CompareGear()
|
||||
local class = self:GetPlayerClass()
|
||||
local spec = AmibisCharDB.overrideSpec or self:GetPlayerSpec()
|
||||
local phase = AmibisDB.selectedPhase or "T5"
|
||||
local phase = ns.Data.BISLists:ResolvePhase(class, spec, AmibisDB.selectedPhase or "T5")
|
||||
|
||||
local bisList = ns.Data.BISLists:GetBISList(class, spec, phase)
|
||||
if not bisList then
|
||||
@@ -357,6 +390,33 @@ function Amibis:CompareGear()
|
||||
end
|
||||
end
|
||||
|
||||
local latestPhase = ns.Data.BISLists:GetLatestPhase(class, spec)
|
||||
local latestCompletionRatio = nil
|
||||
if latestPhase and statsComplete then
|
||||
local latestList = ns.Data.BISLists:GetBISList(class, spec, latestPhase)
|
||||
if latestList then
|
||||
local latestStatsComplete = true
|
||||
for slotName, bisItem in pairs(latestList) do
|
||||
if not GetItemInfo(bisItem.itemID) then
|
||||
latestStatsComplete = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if latestStatsComplete then
|
||||
if latestPhase == phase then
|
||||
latestCompletionRatio = self:StatRatio(equippedStats, bisStats, class, spec)
|
||||
else
|
||||
local latestItems = {}
|
||||
for slotName, bisItem in pairs(latestList) do
|
||||
latestItems[slotName] = { itemID = bisItem.itemID }
|
||||
end
|
||||
local latestStats = self:AggregateStats(latestItems)
|
||||
latestCompletionRatio = self:StatRatio(equippedStats, latestStats, class, spec)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
class = class,
|
||||
spec = spec,
|
||||
@@ -369,6 +429,8 @@ function Amibis:CompareGear()
|
||||
equippedStats = equippedStats,
|
||||
bisStats = bisStats,
|
||||
statsComplete = statsComplete,
|
||||
latestPhase = latestPhase,
|
||||
latestCompletionRatio = latestCompletionRatio,
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
+956
-26
File diff suppressed because it is too large.
Load diff
@@ -238,6 +238,10 @@ local StatsPanelTitle = nil
|
||||
local StatLabels = {}
|
||||
local StatValues = {}
|
||||
local UpgradeLabels = {}
|
||||
local PhaseBar = nil
|
||||
local PhaseProgressFill = nil
|
||||
local PhaseProgressText = nil
|
||||
local PhaseButtons = {}
|
||||
|
||||
local STAT_LABELS = {
|
||||
healing = "+Healing",
|
||||
@@ -424,6 +428,85 @@ local function StatKeysEqual(a, b)
|
||||
return true
|
||||
end
|
||||
|
||||
local function CreatePhaseBar(parent, anchor)
|
||||
local bar = CreateFrame("Frame", nil, parent, "BackdropTemplate")
|
||||
bar:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, -4)
|
||||
bar:SetPoint("TOPRIGHT", anchor, "BOTTOMRIGHT", 0, -4)
|
||||
bar:SetHeight(24)
|
||||
|
||||
bar:SetBackdrop({
|
||||
bgFile = "Interface\\Buttons\\WHITE8x8",
|
||||
edgeFile = "Interface\\Buttons\\WHITE8x8",
|
||||
tile = false,
|
||||
tileSize = 0,
|
||||
edgeSize = 1,
|
||||
insets = { left = 0, right = 0, top = 0, bottom = 0 }
|
||||
})
|
||||
bar:SetBackdropColor(ELVUI_TITLE_BG[1], ELVUI_TITLE_BG[2], ELVUI_TITLE_BG[3], 0.9)
|
||||
bar:SetBackdropBorderColor(ELVUI_BORDER_COLOR[1], ELVUI_BORDER_COLOR[2], ELVUI_BORDER_COLOR[3], ELVUI_BORDER_ALPHA)
|
||||
|
||||
local fill = bar:CreateTexture(nil, "BACKGROUND")
|
||||
fill:SetTexture("Interface\\Buttons\\WHITE8x8")
|
||||
fill:SetVertexColor(0, 0.68, 0.3, 0.28)
|
||||
fill:SetPoint("TOPLEFT", bar, "TOPLEFT", 1, -1)
|
||||
fill:SetPoint("BOTTOMLEFT", bar, "BOTTOMLEFT", 1, 1)
|
||||
fill:SetWidth(1)
|
||||
|
||||
local progressText = bar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||
progressText:SetPoint("RIGHT", bar, "RIGHT", -6, 0)
|
||||
progressText:SetText("")
|
||||
progressText:SetTextColor(0.75, 0.95, 0.75, 1)
|
||||
|
||||
PhaseBar = bar
|
||||
PhaseProgressFill = fill
|
||||
PhaseProgressText = progressText
|
||||
return bar
|
||||
end
|
||||
|
||||
local function ClearPhaseButtons()
|
||||
for _, btn in ipairs(PhaseButtons) do
|
||||
btn:Hide()
|
||||
btn:SetParent(nil)
|
||||
end
|
||||
PhaseButtons = {}
|
||||
end
|
||||
|
||||
local function RebuildPhaseButtons(class, spec, activePhase)
|
||||
ClearPhaseButtons()
|
||||
local phases = ns.Data.BISLists:GetAvailablePhases(class, spec)
|
||||
local barWidth = PhaseBar:GetWidth()
|
||||
local count = #phases
|
||||
if count == 0 or barWidth <= 0 then return end
|
||||
local segWidth = barWidth / count
|
||||
|
||||
for i, phase in ipairs(phases) do
|
||||
local btn = CreateFrame("Button", nil, PhaseBar)
|
||||
btn:SetPoint("TOPLEFT", PhaseBar, "TOPLEFT", (i - 1) * segWidth, 0)
|
||||
btn:SetSize(segWidth, 24)
|
||||
|
||||
local text = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
|
||||
text:SetPoint("CENTER", btn, "CENTER", 0, 0)
|
||||
text:SetText(phase)
|
||||
if phase == activePhase then
|
||||
text:SetTextColor(1, 0.82, 0, 1)
|
||||
else
|
||||
text:SetTextColor(0.45, 0.45, 0.45, 1)
|
||||
end
|
||||
|
||||
if phase ~= activePhase then
|
||||
btn:SetScript("OnClick", function()
|
||||
AmibisDB.selectedPhase = phase
|
||||
ns.UI.RefreshUI()
|
||||
end)
|
||||
btn:EnableMouse(true)
|
||||
else
|
||||
btn:EnableMouse(false)
|
||||
end
|
||||
|
||||
PhaseButtons[i] = btn
|
||||
end
|
||||
end
|
||||
|
||||
local function InitializeUI()
|
||||
if MainFrame then return end
|
||||
|
||||
@@ -431,7 +514,9 @@ local function InitializeUI()
|
||||
local titleBar, title = CreateTitleBar(MainFrame)
|
||||
TitleText = title
|
||||
|
||||
local summaryBar, summary = CreateSummaryBar(MainFrame, titleBar)
|
||||
local phaseBar = CreatePhaseBar(MainFrame, titleBar)
|
||||
|
||||
local summaryBar, summary = CreateSummaryBar(MainFrame, phaseBar)
|
||||
SummaryText = summary
|
||||
|
||||
local header = CreateColumnHeaders(MainFrame, summaryBar)
|
||||
@@ -483,6 +568,13 @@ function ns.UI.RefreshUI()
|
||||
UpgradeLabels[i]:SetText("")
|
||||
end
|
||||
end
|
||||
ClearPhaseButtons()
|
||||
if PhaseProgressFill then
|
||||
PhaseProgressFill:SetWidth(1)
|
||||
end
|
||||
if PhaseProgressText then
|
||||
PhaseProgressText:SetText("")
|
||||
end
|
||||
for i = 1, MAX_VISIBLE_ROWS do
|
||||
SlotRows[i].slotText:SetText("")
|
||||
SlotRows[i].equippedText:SetText("")
|
||||
@@ -496,6 +588,18 @@ function ns.UI.RefreshUI()
|
||||
|
||||
SummaryText:SetText(string.format("BIS: %d/%d slots", data.bisCount, data.totalSlots))
|
||||
|
||||
if PhaseBar then
|
||||
RebuildPhaseButtons(data.class, data.spec, data.phase)
|
||||
local ratio = data.latestCompletionRatio or Amibis:GetCompletionRatio(data)
|
||||
local targetPhase = data.latestPhase or data.phase
|
||||
if PhaseProgressFill then
|
||||
PhaseProgressFill:SetWidth(math.max(1, PhaseBar:GetWidth() * ratio))
|
||||
end
|
||||
if PhaseProgressText then
|
||||
PhaseProgressText:SetText(string.format("%d%% to %s", math.floor(ratio * 100 + 0.5), targetPhase))
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, MAX_VISIBLE_ROWS do
|
||||
local row = SlotRows[i]
|
||||
local slotData = data.slots[i]
|
||||
|
||||
Reference in new issue
Block a user