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
@@ -10,23 +10,30 @@ Amibis/
|
|||||||
├── Amibis.lua # Core: DB init, item scanning, stat aggregation, gear comparison, slash commands
|
├── Amibis.lua # Core: DB init, item scanning, stat aggregation, gear comparison, slash commands
|
||||||
├── Data/
|
├── Data/
|
||||||
│ └── BISLists.lua # BIS data store (class → spec → phase → slot)
|
│ └── BISLists.lua # BIS data store (class → spec → phase → slot)
|
||||||
└── UI/
|
├── UI/
|
||||||
└── ComparisonFrame.lua # Main UI frame, slot rows, stats panel
|
│ └── ComparisonFrame.lua # Main UI frame, slot rows, stats panel, phase selector bar
|
||||||
|
└── Tests/ # Offline test suite (NOT in .toc — dev machine only)
|
||||||
|
├── run.lua # Entry point: lua5.4 Amibis/Tests/run.lua
|
||||||
|
├── harness.lua # describe/it/expect micro-framework
|
||||||
|
├── wow_mocks.lua # WoW API stubs + scriptable item fixtures
|
||||||
|
├── test_*.lua # Suites: data integrity, stat scanning, gear comparison
|
||||||
|
└── README.md # Coverage, layout, how to add tests
|
||||||
```
|
```
|
||||||
|
|
||||||
## Key facts
|
## Key facts
|
||||||
- **Load order** is defined in `Amibis.toc`: `Amibis.lua` → `Data/BISLists.lua` → `UI/ComparisonFrame.lua`
|
- **Load order** is defined in `Amibis.toc`: `Amibis.lua` → `Data/BISLists.lua` → `UI/ComparisonFrame.lua`
|
||||||
- **Slash command**: `/amibis` toggles the UI; `/amibis spec <SpecName>` overrides auto-detected spec; `/amibis spec clear` resets override
|
- **Slash command**: `/amibis` toggles the UI; `/amibis spec <SpecName>` overrides auto-detected spec; `/amibis spec clear` resets override. Phase is selected by clicking phase segments in the phase bar (T4 | T5 | T6).
|
||||||
- **SavedVariables**: `AmibisDB` (account-wide, stores selected phase), `AmibisCharDB` (per-character, stores frame position + spec override)
|
- **SavedVariables**: `AmibisDB` (account-wide, stores selected phase), `AmibisCharDB` (per-character, stores frame position + spec override)
|
||||||
- **Namespace pattern**: `local addonName, ns = ...` — all modules attach to `ns`
|
- **Namespace pattern**: `local addonName, ns = ...` — all modules attach to `ns`
|
||||||
- **No build/test/lint tooling** — tested in-game via WoW client
|
- **Tests**: offline suite in `Tests/` (mocked WoW API, no client needed) — run `lua5.4 Amibis/Tests/run.lua` from the repo root; see `Tests/README.md`. UI still verified in-game.
|
||||||
- **Currently**: Only T5 data populated
|
- **Currently**: T4 (Phase 1) and T6 (Phase 3) populated for all 9 classes; T5 (Phase 2) populated for the original specs (Druid Feral Combat + Paladin Protection/Retribution have T4/T6 only). Default phase is T6. Phase-progress bar measures completion against the **latest** available phase regardless of which phase is selected.
|
||||||
|
|
||||||
## Adding new BIS data
|
## Adding new BIS data
|
||||||
1. Add a `local CLASS_T5 = { ... }` table in `Data/BISLists.lua` following the existing `PRIEST_T5` structure
|
1. Add a `local CLASS_T4 = { ... }` table in `Data/BISLists.lua` following the existing `PRIEST_T4` structure
|
||||||
2. Register it in `BIS_DATA` under the appropriate class/spec/phase key
|
2. Register it in `BIS_DATA` under the appropriate class/spec/phase key
|
||||||
3. Each slot entry: `{ itemID, name, source, enchant? }`
|
3. Each slot entry: `{ itemID, name, source, enchant? }`
|
||||||
4. Ensure class name matches WoW's English class constant (e.g. `"WARRIOR"`, not `"Warrior"`)
|
4. Ensure class name matches WoW's English class constant (e.g. `"WARRIOR"`, not `"Warrior"`)
|
||||||
|
5. Phases are ordered via `PHASE_ORDER = { "T4", "T5", "T6" }` — T4 = Phase 1 (Karazhan/Gruul/Magtheridon), T5 = Phase 2 (SSC/TK), T6 = Phase 3 (Black Temple/Hyjal). T4/T6 data is sourced from wowtbc.gg `page-data` JSON (the per-phase `bis` variants, group/raid-flagged).
|
||||||
|
|
||||||
## UI conventions
|
## UI conventions
|
||||||
- ElvUI-style dark backdrop (`{0.07, 0.07, 0.07}`, alpha 0.95)
|
- ElvUI-style dark backdrop (`{0.07, 0.07, 0.07}`, alpha 0.95)
|
||||||
|
|||||||
+66
-4
@@ -5,7 +5,7 @@ ns.Amibis = Amibis
|
|||||||
Amibis.version = "1.0.0"
|
Amibis.version = "1.0.0"
|
||||||
|
|
||||||
local DEFAULT_AMIBIS_DB = {
|
local DEFAULT_AMIBIS_DB = {
|
||||||
selectedPhase = "T5",
|
selectedPhase = "T6",
|
||||||
}
|
}
|
||||||
|
|
||||||
local DEFAULT_AMIBIS_CHAR_DB = {
|
local DEFAULT_AMIBIS_CHAR_DB = {
|
||||||
@@ -60,6 +60,34 @@ function Amibis:GetStatKeysForSpec(class, spec)
|
|||||||
return GetUpgradeStatKeys(class, spec)
|
return GetUpgradeStatKeys(class, spec)
|
||||||
end
|
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()
|
local function InitializeDB()
|
||||||
if not AmibisDB then
|
if not AmibisDB then
|
||||||
AmibisDB = CopyTable(DEFAULT_AMIBIS_DB)
|
AmibisDB = CopyTable(DEFAULT_AMIBIS_DB)
|
||||||
@@ -183,9 +211,14 @@ local STAT_MAP = {
|
|||||||
["ITEM_MOD_HEALING_SHORT"] = "healing",
|
["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,
|
healing = true,
|
||||||
spellDamage = true,
|
spellDamage = true,
|
||||||
|
mp5 = true,
|
||||||
|
haste = true,
|
||||||
|
crit = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
function Amibis:ScanItemStats(itemID)
|
function Amibis:ScanItemStats(itemID)
|
||||||
@@ -203,7 +236,7 @@ function Amibis:ScanItemStats(itemID)
|
|||||||
for wowKey, ourKey in pairs(STAT_MAP) do
|
for wowKey, ourKey in pairs(STAT_MAP) do
|
||||||
local value = stats[wowKey]
|
local value = stats[wowKey]
|
||||||
if value then
|
if value then
|
||||||
if MAX_AGGREGATE_STATS[ourKey] then
|
if ALIAS_STATS[ourKey] then
|
||||||
local current = result[ourKey]
|
local current = result[ourKey]
|
||||||
if not current or value > current then
|
if not current or value > current then
|
||||||
result[ourKey] = value
|
result[ourKey] = value
|
||||||
@@ -247,7 +280,7 @@ end
|
|||||||
function Amibis:CompareGear()
|
function Amibis:CompareGear()
|
||||||
local class = self:GetPlayerClass()
|
local class = self:GetPlayerClass()
|
||||||
local spec = AmibisCharDB.overrideSpec or self:GetPlayerSpec()
|
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)
|
local bisList = ns.Data.BISLists:GetBISList(class, spec, phase)
|
||||||
if not bisList then
|
if not bisList then
|
||||||
@@ -357,6 +390,33 @@ function Amibis:CompareGear()
|
|||||||
end
|
end
|
||||||
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 {
|
return {
|
||||||
class = class,
|
class = class,
|
||||||
spec = spec,
|
spec = spec,
|
||||||
@@ -369,6 +429,8 @@ function Amibis:CompareGear()
|
|||||||
equippedStats = equippedStats,
|
equippedStats = equippedStats,
|
||||||
bisStats = bisStats,
|
bisStats = bisStats,
|
||||||
statsComplete = statsComplete,
|
statsComplete = statsComplete,
|
||||||
|
latestPhase = latestPhase,
|
||||||
|
latestCompletionRatio = latestCompletionRatio,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+956
-26
File diff suppressed because it is too large.
Load diff
@@ -238,6 +238,10 @@ local StatsPanelTitle = nil
|
|||||||
local StatLabels = {}
|
local StatLabels = {}
|
||||||
local StatValues = {}
|
local StatValues = {}
|
||||||
local UpgradeLabels = {}
|
local UpgradeLabels = {}
|
||||||
|
local PhaseBar = nil
|
||||||
|
local PhaseProgressFill = nil
|
||||||
|
local PhaseProgressText = nil
|
||||||
|
local PhaseButtons = {}
|
||||||
|
|
||||||
local STAT_LABELS = {
|
local STAT_LABELS = {
|
||||||
healing = "+Healing",
|
healing = "+Healing",
|
||||||
@@ -424,6 +428,85 @@ local function StatKeysEqual(a, b)
|
|||||||
return true
|
return true
|
||||||
end
|
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()
|
local function InitializeUI()
|
||||||
if MainFrame then return end
|
if MainFrame then return end
|
||||||
|
|
||||||
@@ -431,7 +514,9 @@ local function InitializeUI()
|
|||||||
local titleBar, title = CreateTitleBar(MainFrame)
|
local titleBar, title = CreateTitleBar(MainFrame)
|
||||||
TitleText = title
|
TitleText = title
|
||||||
|
|
||||||
local summaryBar, summary = CreateSummaryBar(MainFrame, titleBar)
|
local phaseBar = CreatePhaseBar(MainFrame, titleBar)
|
||||||
|
|
||||||
|
local summaryBar, summary = CreateSummaryBar(MainFrame, phaseBar)
|
||||||
SummaryText = summary
|
SummaryText = summary
|
||||||
|
|
||||||
local header = CreateColumnHeaders(MainFrame, summaryBar)
|
local header = CreateColumnHeaders(MainFrame, summaryBar)
|
||||||
@@ -483,6 +568,13 @@ function ns.UI.RefreshUI()
|
|||||||
UpgradeLabels[i]:SetText("")
|
UpgradeLabels[i]:SetText("")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
ClearPhaseButtons()
|
||||||
|
if PhaseProgressFill then
|
||||||
|
PhaseProgressFill:SetWidth(1)
|
||||||
|
end
|
||||||
|
if PhaseProgressText then
|
||||||
|
PhaseProgressText:SetText("")
|
||||||
|
end
|
||||||
for i = 1, MAX_VISIBLE_ROWS do
|
for i = 1, MAX_VISIBLE_ROWS do
|
||||||
SlotRows[i].slotText:SetText("")
|
SlotRows[i].slotText:SetText("")
|
||||||
SlotRows[i].equippedText: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))
|
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
|
for i = 1, MAX_VISIBLE_ROWS do
|
||||||
local row = SlotRows[i]
|
local row = SlotRows[i]
|
||||||
local slotData = data.slots[i]
|
local slotData = data.slots[i]
|
||||||
|
|||||||
Reference in new issue
Block a user