Compare commits

..
12 Commits
Author SHA1 Message Date
dfj e2abe972ad Make trinket slots interchangeable when matching BIS gear
Lua tests / test (push) Successful in 13s
2026-10-28 18:02:02 +01:00
dfj 9d809309ac Fetch the commit archive in CI instead of using git clone
Lua tests / test (push) Successful in 14s
The Gitea server currently corrupts clone/fetch pack responses with
"protocol error: bad pack header" (reproducible with a plain git clone),
which makes actions/checkout fail before any of our steps run. Download
the commit archive via the API instead (with a token, falling back to
anonymous for public repos) and extract it into the workspace.
2026-10-24 16:00:07 +02:00
dfj 1fda0d3817 Allow manual runs of the test workflow
Lua tests / test (push) Failing after 51s
2026-10-24 15:56:05 +02:00
dfj f46b039328 Run the test suite in Gitea Actions on every push
Lua tests / test (push) Failing after 56s
Add .gitea/workflows/tests.yaml per the Gitea Actions quick start:
check out the repo, install Lua 5.4, then run the offline suite
(lua5.4 Amibis/Tests/run.lua). A failed test fails the job.

Document the workflow in README, AGENTS.md, and the tests README.
2026-10-24 15:53:04 +02:00
dfj d8fefc947e Close the window when Escape is pressed
Register the main frame ("AmibisMainFrame") in UISpecialFrames so Escape
hides it and suppresses the game menu while it is open, matching the
default UI panels.

Move the stats-retry timer cleanup into the frame's OnHide script so the
close button, Escape, and /amibis all stop the timer.

Tests: the mock now registers named frames in _G and runs OnHide scripts.
The UI suite simulates FrameXML's CloseSpecialWindows() and asserts the
frame hides and the retry timer is cleared. 108 passing.
2026-10-24 13:57:09 +02:00
dfj cc3971fe93 Fix stat panel not rebuilding when switching specs
RebuildStatRows hid the previous rows through vals.label, but StatValues
never stored the label font string. The first spec change that altered
the stat keys raised "attempt to index a nil value (field 'label')",
aborting RefreshUI before the new rows were created. The previous spec's
panel stayed on screen, so a Holy priest kept seeing Shadow's
"+Spell Damage" row instead of "+Healing".

Store the label in StatValues so old rows hide correctly and the panel
rebuilds with the new spec's profile.

Add a UI smoke test using mocked frames (font strings now record
text/shown; frames track Show/Hide/IsShown). It switches Shadow -> Holy
and asserts the visible rows change; with the bug reverted it fails with
the same nil-label error.

Also print usage for a bare "/amibis spec" instead of toggling the
window, which was a surprising side effect and made tests order-dependent.

107 passing.
2026-10-24 13:42:08 +02:00
dfj 5fba4ac10c Keep latest-phase progress independent of the selected phase
The bar could change when switching phases: latestCompletionRatio was nil
until the selected phase's stats were complete AND the latest list was
cached, and the UI then fell back to the selected phase's own completion
ratio. Right after login the latest list's items are often not cached
yet, so switching phases visibly moved the bar.

Always compute a latest-phase ratio inside CompareGear: stats-based when
both the latest list and the equipped items are cached, otherwise slot
completion against the latest list. Return latestStatsComplete so the UI
can mark the estimate with "~" and keep retrying until stats load
(capped at 20 attempts). The UI now uses latestCompletionRatio directly
instead of falling back to the selected phase.

Also refresh on PLAYER_EQUIPMENT_CHANGED so gear swaps update the bar.

Tests: phase-independent ratio, slot-based fallback while the latest
list is uncached, and equal ratios across selected phases once cached.
106 passing.
2026-10-24 13:37:33 +02:00
dfj b66491c5be Tailor stat comparison and scoring to each spec
Replace the flat per-spec key list with SPEC_STAT_PROFILES: an ordered
{ stat, weight } table for every class/spec. The panel now shows what
matters to the selected spec instead of falling back to spell stats for
physical specs: casters get spell damage/hit/crit/haste, melee get
strength/AP/hit/expertise/armor pen, tanks get stamina/armor/defense/
dodge/parry/block, healers get healing/spirit/MP5.

The same weights drive upgrade ranking, the completion ratio, and which
two gains are shown in the top-upgrades line, so e.g. spell damage
outweighs spirit for Shadow while stamina outweighs expertise for a
Protection tank.

Add GetItemStats mappings for physical stats (attack power, ranged/feral
AP, strength, agility, hit, expertise, armor pen, defense, dodge, parry,
block, block value, armor). TBC per-school hit/crit/haste keys fold into
one stat. Drop the unused spellPower row from TBC profiles.

Tests: weighted scoring expectations, physical/tank mappings, profile
coverage and 8-row panel limit, weighted ratios. 104 passing.
2026-10-24 01:00:24 +02:00
dfj e08e288f73 Read TBC school-specific haste and crit item stats
TBC items report per-school ratings with a different key shape than the
WotLK-era names the addon mapped: "spell haste" is
ITEM_MOD_HASTE_SPELL_RATING(_SHORT), not ITEM_MOD_SPELL_HASTE_RATING,
and crit is ITEM_MOD_CRIT_SPELL_RATING/MELEE/RANGED rather than
ITEM_MOD_SPELL_CRIT_RATING. As a result spell haste (and spell/melee
crit) on TBC gear scanned as zero, so the stats panel showed no haste
and upgrade scoring ignored it.

Map the TBC haste/crit keys alongside the existing generic ones, plus
non-_SHORT variants for safety. The alias logic still takes MAX per
stat, so an item that reports both forms is not double counted.

Tests cover TBC spell haste + crit, melee/ranged haste keys, and
generic+school-specific de-duplication. 96 passing.
2026-10-24 00:50:02 +02:00
dfj 912ed8f255 Fix /amibis spec clear being stored as a spec override
The generic "spec <name>" branch matched before the "spec clear" check,
so clearing an override set overrideSpec to "Clear" and the UI then
looked for a spec called Clear instead of falling back to auto-detection.

Check the clear command first, collapse whitespace so "spec   clear"
parses, and refresh the frame immediately when the override changes.
Spec names are also title-cased per word now, so "/amibis spec beast
mastery" resolves to "Beast Mastery".

Add test_slash.lua covering set/clear, case/whitespace normalization,
and the clear-as-spec-name regression. 93 tests passing.
2026-10-24 00:45:28 +02:00
dfj 907d274b3a Add ZA (Phase 4) BiS lists for all specs
Populate Zul'Aman gear for all 9 classes x 3 specs from the wowtbc.gg
page-data JSON, using the same per-phase `bis` extraction (group/raid
variant preferred) as the earlier tiers. ZA becomes the fourth phase in
PHASE_ORDER and the new default, so the progress bar now measures
completion against ZA.

Shared lists mirror the existing phase conventions: Discipline = Holy,
BM = MM, Combat = Subtlety, and all three warlock specs share one ZA
list. Relic entries (idols/librams/totems) stay omitted like T4-T6.

Two source corrections are folded in: one site data bug where Holy
Paladin's ZA main hand pointed at Hammer of Sanctification (Sunwell
only) is replaced with the T6 pick, Crystal Spire of Karabor, and
canonical item names replace the site's case/typo variants.

Tests: 88 passing, including ZA coverage, shared-list invariants, and
latest-phase progress against ZA.
2026-10-24 00:42:37 +02:00
dfj 48040c3ae1 Refresh T5 BiS lists from wowtbc.gg and normalize source formatting
All 20 T5 tables regenerated from the current wowtbc.gg page-data
JSON (same group/raid-variant extraction as T4/T6): fixes 9 stale items
(Quagmirran's Eye trinket, Corruptor set, Shapeshifter's Signet,
Ranger-General's Chestguard, Band of Eternity v2, etc.) and aligns
slot sets with the site's default view. Warlock T5 now splits:
Affliction gets WARLOCK_AFFLICTION_T5 (Corruptor), Demonology and
Destruction keep Voidheart. Source strings normalized: quest rewards
and dungeon bosses dash-joined, professions space-joined, site typos
folded (Mother Sharaz, Karanthress, Blood Furnace HC). 81 tests.
2026-10-11 16:41:29 +02:00
14 changed files with 1868 additions and 562 deletions

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
name: Lua tests
# Runs the offline test suite (Amibis/Tests/run.lua) on every push.
# workflow_dispatch also allows a manual run from the Actions tab.
on:
push:
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
# The server currently corrupts git clone/fetch pack responses
# ("fatal: protocol error: bad pack header"), which breaks
# actions/checkout, so fetch the commit archive from the API instead.
- name: Fetch source archive
env:
TOKEN: ${{ secrets.GITEA_TOKEN }}
URL: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/archive/${{ gitea.sha }}.tar.gz
run: |
if ! curl -fsSL -H "Authorization: token $TOKEN" -o "$RUNNER_TEMP/source.tar.gz" "$URL"; then
curl -fsSL -o "$RUNNER_TEMP/source.tar.gz" "$URL"
fi
tar -xzf "$RUNNER_TEMP/source.tar.gz" -C "$GITHUB_WORKSPACE" --strip-components=1
- name: Install Lua 5.4
run: |
sudo apt-get update
sudo apt-get install -y lua5.4
- name: Run offline test suite
run: lua5.4 Amibis/Tests/run.lua
+8 -4
View File
@@ -25,18 +25,22 @@ Amibis/
- **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)
- **Namespace pattern**: `local addonName, ns = ...` — all modules attach to `ns`
- **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**: 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.
- **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. CI runs the same command on every push via `.gitea/workflows/tests.yaml` (Gitea Actions).
- **Currently**: T4 (Phase 1), T5 (Phase 2), T6 (Phase 3), and ZA (Phase 4, Zul'Aman) populated — all refreshed from wowtbc.gg `page-data` JSON. Discipline Priest + Beast Mastery/Marksmanship Hunter + all three warlocks share spec-partner lists in each phase (warlock T5 splits: Affliction = Corruptor, Demo/Destro = Voidheart). Druid Feral Combat + Paladin Protection/Retribution have no T5 list. Default phase is ZA. Phase-progress bar measures completion against the **latest** available phase regardless of which phase is selected.
- **ZA sourcing notes**: the site's `za` variant is used, preferring the group/raid-flagged variant when a slot has several. Relic-slot entries (idols/librams/totems) are omitted, matching T4–T6. One site data bug is corrected in the generator: the ZA list for Holy Paladin pointed at Hammer of Sanctification (Sunwell only), so the T6 main hand (Crystal Spire of Karabor) is used instead.
## Adding new BIS data
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
3. Each slot entry: `{ itemID, name, source, enchant? }`
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).
5. Phases are ordered via `PHASE_ORDER = { "T4", "T5", "T6", "ZA" }` — T4 = Phase 1 (Karazhan/Gruul/Magtheridon), T5 = Phase 2 (SSC/TK), T6 = Phase 3 (Black Temple/Hyjal), ZA = Phase 4 (Zul'Aman). All phase data is sourced from wowtbc.gg `page-data` JSON (the per-phase `bis` variants, group/raid-flagged). Affliction warlock has its own T5 list (Corruptor set); Demonology/Destruction share Voidheart.
## UI conventions
- ElvUI-style dark backdrop (`{0.07, 0.07, 0.07}`, alpha 0.95)
- Color coding: green = BIS, yellow = upgrade available, gray = empty slot
- Max 17 visible rows; rows are clickable (Shift+click = chat link, Ctrl+click = dress-up)
- Stats panel shows: Healing, Spell Power, Intellect, Spirit, MP5, Haste, Crit
- Stats panel is **per-spec**: `SPEC_STAT_PROFILES` in `Amibis.lua` defines an ordered `{ stat, weight }` list for every class/spec (casters see spell damage/hit/crit/haste, melee see strength/AP/hit/expertise/armor pen, tanks see stamina/defense/dodge/parry/block, healers see healing/spirit/mp5). The same weights rank top upgrades, score completion, and pick which two gains are shown in the upgrade line. Keep profiles to 8 rows so the panel fits the frame.
- The phase-progress bar always measures the **latest** phase, independent of the selected phase: stats-based once item data is cached, slot-based (prefixed `~`) until then. It refreshes on talent and equipment changes.
- The main frame is registered in `UISpecialFrames`, so Escape closes it (and suppresses the game menu while it is open). `MainFrame`'s `OnHide` clears the stats retry timer, so both the close button and Escape clean up.
- Stat values are read via `STAT_MAP` (WoW `GetItemStats` keys → internal stat names); TBC's per-school hit/crit/haste keys are all mapped to one internal stat.
+272 -56
View File
@@ -5,7 +5,7 @@ ns.Amibis = Amibis
Amibis.version = "1.0.0"
local DEFAULT_AMIBIS_DB = {
selectedPhase = "T6",
selectedPhase = "ZA",
}
local DEFAULT_AMIBIS_CHAR_DB = {
@@ -18,66 +18,101 @@ local DEFAULT_AMIBIS_CHAR_DB = {
local TOP_UPGRADES_COUNT = 3
local UPGRADE_STAT_KEYS = {
-- Per-spec stat priorities. Each entry is { statKey, weight } in display order:
-- the panel shows every listed stat, and the weight drives upgrade scoring and
-- the completion ratio, so each spec is measured by what actually matters to it.
local SPEC_STAT_PROFILES = {
["PRIEST"] = {
["Discipline"] = { "healing", "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Holy"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Shadow"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Discipline"] = { { "healing", 3 }, { "intellect", 2 }, { "mp5", 2 }, { "haste", 2 }, { "spirit", 1 }, { "crit", 1 } },
["Holy"] = { { "healing", 3 }, { "intellect", 2 }, { "mp5", 2 }, { "haste", 2 }, { "spirit", 1 }, { "crit", 1 } },
["Shadow"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 }, { "mp5", 1 } },
},
["DRUID"] = {
["Balance"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Restoration"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Balance"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 }, { "mp5", 1 } },
["Feral Combat"] = { { "attackPower", 3 }, { "strength", 2 }, { "agility", 2 }, { "feralAttackPower", 2 }, { "hit", 2 }, { "expertise", 2 }, { "crit", 2 }, { "armorPen", 1 } },
["Restoration"] = { { "healing", 3 }, { "intellect", 2 }, { "spirit", 2 }, { "mp5", 2 }, { "haste", 2 }, { "crit", 1 } },
},
["PALADIN"] = {
["Holy"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Holy"] = { { "healing", 3 }, { "intellect", 2 }, { "mp5", 2 }, { "haste", 2 }, { "spirit", 1 }, { "crit", 1 } },
["Protection"] = { { "stamina", 3 }, { "armor", 2 }, { "defense", 2 }, { "dodge", 2 }, { "parry", 2 }, { "spellDamage", 2 }, { "block", 1 }, { "hit", 1 } },
["Retribution"] = { { "strength", 3 }, { "attackPower", 2 }, { "crit", 2 }, { "hit", 2 }, { "expertise", 1 }, { "haste", 1 }, { "armorPen", 1 }, { "agility", 1 } },
},
["SHAMAN"] = {
["Elemental"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Restoration"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Elemental"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "mp5", 1 }, { "stamina", 1 } },
["Enhancement"] = { { "attackPower", 3 }, { "strength", 2 }, { "agility", 2 }, { "hit", 2 }, { "expertise", 2 }, { "crit", 2 }, { "haste", 1 }, { "armorPen", 1 } },
["Restoration"] = { { "healing", 3 }, { "intellect", 2 }, { "spirit", 2 }, { "mp5", 2 }, { "haste", 2 }, { "crit", 1 } },
},
["MAGE"] = {
["Arcane"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Fire"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Frost"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Arcane"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
["Fire"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
["Frost"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
},
["WARLOCK"] = {
["Affliction"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Demonology"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Destruction"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
["Affliction"] = { { "spellDamage", 3 }, { "hit", 2 }, { "haste", 2 }, { "crit", 1 }, { "intellect", 1 }, { "spirit", 1 }, { "stamina", 1 } },
["Demonology"] = { { "spellDamage", 3 }, { "hit", 2 }, { "haste", 2 }, { "crit", 1 }, { "intellect", 1 }, { "spirit", 1 }, { "stamina", 1 } },
["Destruction"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
},
["WARRIOR"] = {
["Arms"] = { { "strength", 3 }, { "attackPower", 2 }, { "crit", 2 }, { "hit", 2 }, { "expertise", 1 }, { "armorPen", 1 }, { "haste", 1 }, { "stamina", 1 } },
["Fury"] = { { "strength", 3 }, { "attackPower", 2 }, { "crit", 2 }, { "hit", 2 }, { "expertise", 1 }, { "armorPen", 1 }, { "haste", 1 }, { "stamina", 1 } },
["Protection"] = { { "stamina", 3 }, { "armor", 2 }, { "defense", 2 }, { "dodge", 2 }, { "parry", 2 }, { "expertise", 1 }, { "block", 1 }, { "hit", 1 } },
},
["ROGUE"] = {
["Assassination"] = { { "agility", 3 }, { "attackPower", 2 }, { "hit", 2 }, { "expertise", 2 }, { "crit", 2 }, { "haste", 1 }, { "armorPen", 1 }, { "stamina", 1 } },
["Combat"] = { { "agility", 3 }, { "attackPower", 2 }, { "armorPen", 2 }, { "hit", 2 }, { "expertise", 2 }, { "crit", 2 }, { "haste", 1 }, { "stamina", 1 } },
["Subtlety"] = { { "agility", 3 }, { "attackPower", 2 }, { "crit", 2 }, { "hit", 2 }, { "haste", 1 }, { "stamina", 1 } },
},
["HUNTER"] = {
["Beast Mastery"] = { { "agility", 3 }, { "attackPower", 2 }, { "rangedAttackPower", 2 }, { "hit", 2 }, { "crit", 2 }, { "haste", 1 }, { "armorPen", 1 }, { "stamina", 1 } },
["Marksmanship"] = { { "agility", 3 }, { "attackPower", 2 }, { "rangedAttackPower", 2 }, { "hit", 2 }, { "crit", 2 }, { "haste", 1 }, { "armorPen", 1 }, { "stamina", 1 } },
["Survival"] = { { "agility", 3 }, { "attackPower", 2 }, { "rangedAttackPower", 2 }, { "hit", 2 }, { "crit", 2 }, { "haste", 1 }, { "armorPen", 1 }, { "stamina", 1 } },
},
}
local DEFAULT_UPGRADE_STAT_KEYS = { "spellPower", "intellect", "spirit", "mp5", "haste", "crit" }
local DEFAULT_STAT_PROFILE = { { "spellDamage", 3 }, { "crit", 2 }, { "haste", 2 }, { "hit", 2 }, { "intellect", 1 } }
local function GetUpgradeStatKeys(class, spec)
if class and UPGRADE_STAT_KEYS[class] and UPGRADE_STAT_KEYS[class][spec] then
return UPGRADE_STAT_KEYS[class][spec]
local function GetStatProfile(class, spec)
local classProfiles = SPEC_STAT_PROFILES[class]
if classProfiles and classProfiles[spec] then
return classProfiles[spec]
end
return DEFAULT_UPGRADE_STAT_KEYS
return DEFAULT_STAT_PROFILE
end
function Amibis:GetStatKeysForSpec(class, spec)
return GetUpgradeStatKeys(class, spec)
local keys = {}
for _, entry in ipairs(GetStatProfile(class, spec)) do
table.insert(keys, entry[1])
end
return keys
end
function Amibis:GetStatWeightsForSpec(class, spec)
local weights = {}
for _, entry in ipairs(GetStatProfile(class, spec)) do
weights[entry[1]] = entry[2]
end
return weights
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 weightSum, sum = 0, 0
for _, entry in ipairs(GetStatProfile(class, spec)) do
local statKey, weight = entry[1], entry[2]
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
sum = sum + ratio * weight
weightSum = weightSum + weight
end
end
if count == 0 then return 0 end
return sum / count
if weightSum == 0 then return 0 end
return sum / weightSum
end
function Amibis:GetCompletionRatio(data)
@@ -188,6 +223,54 @@ function Amibis:GetEquippedItems()
return items
end
-- Trinket slots are interchangeable: match equipped trinkets to BIS trinkets
-- as a set instead of by slot index, so swapping Trinket0/Trinket1 still
-- counts as BIS. Returns a map of trinket slot name -> equipped item (or nil).
function Amibis:AssignTrinketEquipped(bisList, equipped)
local assigned = {}
local trinketBisSlots = {}
for _, s in ipairs({ "Trinket0", "Trinket1" }) do
if bisList and bisList[s] then
table.insert(trinketBisSlots, s)
end
end
local equippedTrinkets = {}
for _, s in ipairs({ "Trinket0", "Trinket1" }) do
if equipped and equipped[s] then
table.insert(equippedTrinkets, equipped[s])
end
end
local used = {}
-- Prefer exact itemID matches first.
for _, bisSlot in ipairs(trinketBisSlots) do
local bisItem = bisList[bisSlot]
for ei, eq in ipairs(equippedTrinkets) do
if not used[ei] and eq.itemID == bisItem.itemID then
assigned[bisSlot] = eq
used[ei] = true
break
end
end
end
-- Then fill remaining BIS slots with leftover equipped trinkets.
for _, bisSlot in ipairs(trinketBisSlots) do
if assigned[bisSlot] == nil then
for ei, eq in ipairs(equippedTrinkets) do
if not used[ei] then
assigned[bisSlot] = eq
used[ei] = true
break
end
end
end
end
return assigned
end
local STAT_MAP = {
["ITEM_MOD_HEALING_DONE_SHORT"] = "healing",
["ITEM_MOD_SPELL_HEALING_DONE_SHORT"] = "healing",
@@ -201,24 +284,82 @@ local STAT_MAP = {
["ITEM_MOD_SPIRIT_SHORT"] = "spirit",
["ITEM_MOD_STAMINA_SHORT"] = "stamina",
["ITEM_MOD_MANA_REGENERATION_SHORT"] = "mp5",
["ITEM_MOD_MANA_REGENERATION"] = "mp5",
["ITEM_MOD_POWER_REGEN0_SHORT"] = "mp5",
-- TBC uses school-specific ratings (haste/crit melee, ranged, spell) as well
-- as the generic WotLK-era keys; items report whichever applies.
["ITEM_MOD_HASTE_RATING_SHORT"] = "haste",
["ITEM_MOD_HASTE_RATING"] = "haste",
["ITEM_MOD_HASTE_MELEE_RATING_SHORT"] = "haste",
["ITEM_MOD_HASTE_MELEE_RATING"] = "haste",
["ITEM_MOD_HASTE_RANGED_RATING_SHORT"] = "haste",
["ITEM_MOD_HASTE_RANGED_RATING"] = "haste",
["ITEM_MOD_HASTE_SPELL_RATING_SHORT"] = "haste",
["ITEM_MOD_HASTE_SPELL_RATING"] = "haste",
["ITEM_MOD_SPELL_HASTE_RATING_SHORT"] = "haste",
["ITEM_MOD_SPELL_CRIT_RATING_SHORT"] = "crit",
["ITEM_MOD_SPELL_HASTE_RATING"] = "haste",
["ITEM_MOD_CRIT_RATING_SHORT"] = "crit",
["ITEM_MOD_CRIT_RATING"] = "crit",
["ITEM_MOD_CRIT_MELEE_RATING_SHORT"] = "crit",
["ITEM_MOD_CRIT_MELEE_RATING"] = "crit",
["ITEM_MOD_CRIT_RANGED_RATING_SHORT"] = "crit",
["ITEM_MOD_CRIT_RANGED_RATING"] = "crit",
["ITEM_MOD_CRIT_SPELL_RATING_SHORT"] = "crit",
["ITEM_MOD_CRIT_SPELL_RATING"] = "crit",
["ITEM_MOD_SPELL_CRIT_RATING_SHORT"] = "crit",
["ITEM_MOD_SPELL_CRIT_RATING"] = "crit",
["ITEM_MOD_SPELL_POWER_SHORT"] = "spellPower",
["ITEM_MOD_SPELL_DMG_SHORT"] = "spellDamage",
["ITEM_MOD_HEALING_SHORT"] = "healing",
-- Physical stats (TBC uses per-school hit ratings; take the applicable one).
["ITEM_MOD_ATTACK_POWER_SHORT"] = "attackPower",
["ITEM_MOD_ATTACK_POWER"] = "attackPower",
["ITEM_MOD_RANGED_ATTACK_POWER_SHORT"] = "rangedAttackPower",
["ITEM_MOD_RANGED_ATTACK_POWER"] = "rangedAttackPower",
["ITEM_MOD_FERAL_ATTACK_POWER_SHORT"] = "feralAttackPower",
["ITEM_MOD_FERAL_ATTACK_POWER"] = "feralAttackPower",
["ITEM_MOD_STRENGTH_SHORT"] = "strength",
["ITEM_MOD_STRENGTH"] = "strength",
["ITEM_MOD_AGILITY_SHORT"] = "agility",
["ITEM_MOD_AGILITY"] = "agility",
["ITEM_MOD_HIT_RATING_SHORT"] = "hit",
["ITEM_MOD_HIT_RATING"] = "hit",
["ITEM_MOD_HIT_MELEE_RATING_SHORT"] = "hit",
["ITEM_MOD_HIT_MELEE_RATING"] = "hit",
["ITEM_MOD_HIT_RANGED_RATING_SHORT"] = "hit",
["ITEM_MOD_HIT_RANGED_RATING"] = "hit",
["ITEM_MOD_HIT_SPELL_RATING_SHORT"] = "hit",
["ITEM_MOD_HIT_SPELL_RATING"] = "hit",
["ITEM_MOD_EXPERTISE_RATING_SHORT"] = "expertise",
["ITEM_MOD_EXPERTISE_RATING"] = "expertise",
["ITEM_MOD_ARMOR_PENETRATION_RATING_SHORT"] = "armorPen",
["ITEM_MOD_ARMOR_PENETRATION_RATING"] = "armorPen",
["ITEM_MOD_DEFENSE_SKILL_RATING_SHORT"] = "defense",
["ITEM_MOD_DEFENSE_SKILL_RATING"] = "defense",
["ITEM_MOD_DODGE_RATING_SHORT"] = "dodge",
["ITEM_MOD_DODGE_RATING"] = "dodge",
["ITEM_MOD_PARRY_RATING_SHORT"] = "parry",
["ITEM_MOD_PARRY_RATING"] = "parry",
["ITEM_MOD_BLOCK_RATING_SHORT"] = "block",
["ITEM_MOD_BLOCK_RATING"] = "block",
["ITEM_MOD_BLOCK_VALUE_SHORT"] = "blockValue",
["ITEM_MOD_BLOCK_VALUE"] = "blockValue",
["ITEM_MOD_RESILIENCE_RATING_SHORT"] = "resilience",
["ITEM_MOD_RESILIENCE_RATING"] = "resilience",
-- Classic reports armor under RESISTANCE0_NAME; later clients use ITEM_MOD_ARMOR.
["RESISTANCE0_NAME"] = "armor",
["ITEM_MOD_ARMOR"] = "armor",
}
-- 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.
-- Stats that multiple WoW API keys map to (school-specific spell damage, hit,
-- haste, crit, 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,
hit = true,
}
function Amibis:ScanItemStats(itemID)
@@ -254,13 +395,28 @@ function Amibis:AggregateStats(items)
local totals = {
healing = 0,
spellDamage = 0,
spellPower = 0,
intellect = 0,
spirit = 0,
stamina = 0,
mp5 = 0,
haste = 0,
crit = 0,
spellPower = 0,
hit = 0,
attackPower = 0,
rangedAttackPower = 0,
feralAttackPower = 0,
strength = 0,
agility = 0,
expertise = 0,
armorPen = 0,
defense = 0,
dodge = 0,
parry = 0,
block = 0,
blockValue = 0,
armor = 0,
resilience = 0,
}
for slotName, item in pairs(items) do
@@ -280,7 +436,7 @@ end
function Amibis:CompareGear()
local class = self:GetPlayerClass()
local spec = AmibisCharDB.overrideSpec or self:GetPlayerSpec()
local phase = ns.Data.BISLists:ResolvePhase(class, spec, AmibisDB.selectedPhase or "T5")
local phase = ns.Data.BISLists:ResolvePhase(class, spec, AmibisDB.selectedPhase or "ZA")
local bisList = ns.Data.BISLists:GetBISList(class, spec, phase)
if not bisList then
@@ -301,10 +457,22 @@ function Amibis:CompareGear()
local bisCount = 0
local totalSlots = 0
local allUpgrades = {}
local statProfile = GetStatProfile(class, spec)
local statWeights = self:GetStatWeightsForSpec(class, spec)
-- Trinket slots are interchangeable: a BIS trinket counts regardless of
-- whether it is equipped in Trinket0 or Trinket1.
local trinketAssigned = self:AssignTrinketEquipped(bisList, equipped)
for slotName, bisItem in pairs(bisList) do
totalSlots = totalSlots + 1
local equippedItem = equipped[slotName]
local isTrinket = (slotName == "Trinket0" or slotName == "Trinket1")
local equippedItem
if isTrinket then
equippedItem = trinketAssigned[slotName]
else
equippedItem = equipped[slotName]
end
local isBIS = false
if equippedItem and equippedItem.itemID == bisItem.itemID then
@@ -324,13 +492,13 @@ function Amibis:CompareGear()
local score = 0
local equippedStats = (equippedItem and self:ScanItemStats(equippedItem.itemID)) or {}
local bisStats = self:ScanItemStats(bisItem.itemID) or {}
local upgradeStatKeys = GetUpgradeStatKeys(class, spec)
for _, statKey in ipairs(upgradeStatKeys) do
for _, entry in ipairs(statProfile) do
local statKey = entry[1]
local diff = (bisStats[statKey] or 0) - (equippedStats[statKey] or 0)
if diff > 0 then
statDiffs[statKey] = diff
score = score + diff
score = score + diff * entry[2]
end
end
@@ -339,6 +507,7 @@ function Amibis:CompareGear()
equipped = equippedItem,
bis = bisItem,
statDiffs = statDiffs,
statWeights = statWeights,
score = score,
})
end
@@ -391,28 +560,55 @@ function Amibis:CompareGear()
end
local latestPhase = ns.Data.BISLists:GetLatestPhase(class, spec)
local latestCompletionRatio = nil
if latestPhase and statsComplete then
local latestCompletionRatio = 0
local latestStatsComplete = false
if latestPhase then
local latestList = ns.Data.BISLists:GetBISList(class, spec, latestPhase)
if latestList then
local latestStatsComplete = true
-- The bar always measures the latest phase, so it must not depend on
-- which phase is selected. Warm the cache for the latest list and the
-- equipped items, then use stats when available and fall back to slot
-- completion (still latest-phase based) while item data is loading.
local latestItems = {}
local latestItemsCached = true
for slotName, bisItem in pairs(latestList) do
latestItems[slotName] = { itemID = bisItem.itemID }
if not GetItemInfo(bisItem.itemID) then
latestStatsComplete = false
latestItemsCached = false
end
end
local equippedCached = true
for _, item in pairs(equipped) do
if item and item.itemID and not GetItemInfo(item.itemID) then
equippedCached = 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 }
if latestItemsCached and equippedCached then
local latestStats = bisStats
if latestPhase ~= phase then
latestStats = self:AggregateStats(latestItems)
end
local latestStats = self:AggregateStats(latestItems)
latestCompletionRatio = self:StatRatio(equippedStats, latestStats, class, spec)
latestStatsComplete = true
else
local trinketAssigned = self:AssignTrinketEquipped(latestList, equipped)
local matched, total = 0, 0
for slotName, bisItem in pairs(latestList) do
total = total + 1
local equippedItem
if slotName == "Trinket0" or slotName == "Trinket1" then
equippedItem = trinketAssigned[slotName]
else
equippedItem = equipped[slotName]
end
if equippedItem and equippedItem.itemID == bisItem.itemID then
matched = matched + 1
end
end
latestCompletionRatio = total > 0 and (matched / total) or 0
end
end
end
@@ -431,6 +627,7 @@ function Amibis:CompareGear()
statsComplete = statsComplete,
latestPhase = latestPhase,
latestCompletionRatio = latestCompletionRatio,
latestStatsComplete = latestStatsComplete,
}
end
@@ -472,6 +669,7 @@ local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("ADDON_LOADED")
eventFrame:RegisterEvent("PLAYER_LOGIN")
eventFrame:RegisterEvent("PLAYER_TALENT_UPDATE")
eventFrame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
eventFrame:SetScript("OnEvent", function(self, event, ...)
if event == "ADDON_LOADED" then
@@ -481,28 +679,46 @@ eventFrame:SetScript("OnEvent", function(self, event, ...)
end
elseif event == "PLAYER_LOGIN" then
Amibis:InitializeUI()
elseif event == "PLAYER_TALENT_UPDATE" then
elseif event == "PLAYER_TALENT_UPDATE" or event == "PLAYER_EQUIPMENT_CHANGED" then
if ns.UI and ns.UI.RefreshUI then
ns.UI.RefreshUI()
end
end
end)
local function RefreshUI()
if ns.UI and ns.UI.RefreshUI then
ns.UI.RefreshUI()
end
end
-- Title-case each word so "/amibis spec beast mastery" -> "Beast Mastery".
local function NormalizeSpecName(value)
return (value:gsub("(%a)([%w']*)", function(first, rest)
return first:upper() .. rest:lower()
end))
end
SLASH_AMIBIS1 = "/amibis"
SlashCmdList["AMIBIS"] = function(msg)
local cmd = msg:trim():lower()
-- Collapse whitespace so "spec clear" and "spec beast mastery" parse.
local cmd = (msg:trim():lower():gsub("%s+", " "))
if cmd == "" then
Amibis:ToggleFrame()
elseif cmd == "spec" then
print("Amibis: Usage: /amibis spec <SpecName> or /amibis spec clear")
elseif cmd == "spec clear" then
AmibisCharDB.overrideSpec = nil
print("Amibis: Spec override cleared. Using auto-detected spec.")
RefreshUI()
elseif cmd:find("^spec%s+") then
local spec = cmd:match("^spec%s+(.+)")
if spec and spec ~= "" then
spec = spec:gsub("^%l", string.upper)
spec = NormalizeSpecName(spec)
AmibisCharDB.overrideSpec = spec
print("Amibis: Spec override set to " .. spec .. ". Type /amibis spec clear to reset.")
RefreshUI()
end
elseif cmd == "spec clear" then
AmibisCharDB.overrideSpec = nil
print("Amibis: Spec override cleared.")
else
Amibis:ToggleFrame()
end
+891 -436
View File
File diff suppressed because it is too large. Load diff
+10 -5
View File
@@ -13,6 +13,9 @@ lua5.4 Amibis/Tests/run.lua
Exits 0 on success, 1 on any failure, so it works in CI or a git hook.
Gitea Actions runs the same command on every push; see
`.gitea/workflows/tests.yaml` at the repository root.
No Lua installed? On Debian/Ubuntu you can get one without root:
```bash
@@ -23,9 +26,11 @@ apt-get download lua5.4 && dpkg -x lua5.4_*.deb /tmp/lua && /tmp/lua/usr/bin/lua
| File | Covers |
|---|---|
| `test_data.lua` | `BIS_DATA` registry: 9 classes × 3 specs, well-formed slot entries (valid slots, positive item IDs, non-empty names/sources, optional enchant shape), canonical phase order, `ResolvePhase` fallback, shared-list invariants, T6 spot checks |
| `test_data.lua` | `BIS_DATA` registry: 9 classes × 3 specs, well-formed slot entries (valid slots, positive item IDs, non-empty names/sources, optional enchant shape), canonical phase order, `ResolvePhase` fallback, shared-list invariants, T4/T5/ZA spot checks |
| `test_stats.lua` | `ScanItemStats`: MAX aggregation across alias keys (spell damage schools, healing, haste/crit/mp5 ratings), single-mapping pass-through, unmapped key filtering, nil handling |
| `test_compare.lua` | `CompareGear`: BIS counting, upgrade ranking by stat gain, positive-diffs-only scoring, spec-specific stat keys (Shadow counts spell damage, Holy counts healing), phase resolution, `GetStatKeysForSpec`, `GetCompletionRatio` |
| `test_compare.lua` | `CompareGear`: BIS counting, weighted upgrade ranking, positive-diffs-only scoring, per-spec stat profiles (Shadow counts spell damage, Holy counts healing, Warrior counts strength/AP, tank mitigation stats), `GetStatKeysForSpec`, `GetCompletionRatio` |
| `test_slash.lua` | `/amibis spec <name>` parsing: override set/clear, case and multi-word normalization, `spec clear` not treated as a spec name |
| `test_ui.lua` | UI smoke tests with mocked frames: the stats panel rebuilds when switching Shadow → Holy (regression: old rows were hidden via a missing `label` field, which errored and left the Shadow rows on screen), and the main frame is registered in `UISpecialFrames` so Escape closes it |
## Layout
@@ -53,6 +58,6 @@ your dev machine, never in the game client.
## Not covered
`UI/ComparisonFrame.lua` — its helpers are file-locals and testing them would
require a full frame API mock. The logic worth testing (stat scanning, scoring,
phase data) lives in the two suites above.
Most of `UI/ComparisonFrame.lua` — layout/anchoring and event wiring still need in-game
verification. `test_ui.lua` covers the stats-panel rebuild path using mocked frames
(font strings record `text`/`shown`, frames track `Show`/`Hide`/`IsShown`).
+3
View File
@@ -18,10 +18,13 @@ _G.AmibisCharDB = {}
assert(loadfile("Amibis/Amibis.lua"))(ADDON_NAME, ns)
assert(loadfile("Amibis/Data/BISLists.lua"))(ADDON_NAME, ns)
assert(loadfile("Amibis/UI/ComparisonFrame.lua"))(ADDON_NAME, ns)
assert(loadfile("Amibis/Tests/test_data.lua"))(ADDON_NAME, ns)
assert(loadfile("Amibis/Tests/test_stats.lua"))(ADDON_NAME, ns)
assert(loadfile("Amibis/Tests/test_compare.lua"))(ADDON_NAME, ns)
assert(loadfile("Amibis/Tests/test_slash.lua"))(ADDON_NAME, ns)
assert(loadfile("Amibis/Tests/test_ui.lua"))(ADDON_NAME, ns)
local success = TestHarness_report()
os.exit(success and 0 or 1)
+152 -29
View File
@@ -25,7 +25,7 @@ describe("CompareGear: upgrade scoring", function()
MockItems = {
[21869] = {
name = "Old Weapon",
stats = { ["ITEM_MOD_SPELL_POWER_SHORT"] = 35 },
stats = { ["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 35 },
},
[31064] = {
name = "Hood of Absolution",
@@ -37,7 +37,7 @@ describe("CompareGear: upgrade scoring", function()
[31070] = {
name = "Shoulderpads of Absolution",
stats = {
["ITEM_MOD_SPELL_POWER_SHORT"] = 45,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 45,
["ITEM_MOD_INTELLECT_SHORT"] = 20,
},
},
@@ -47,7 +47,7 @@ describe("CompareGear: upgrade scoring", function()
},
[32374] = {
name = "Zhar'doom, Greatstaff of the Devourer",
stats = { ["ITEM_MOD_SPELL_POWER_SHORT"] = 60 },
stats = { ["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 60 },
},
}
MockEquipped = {}
@@ -64,18 +64,20 @@ describe("CompareGear: upgrade scoring", function()
expect(data.totalSlots).toEqual(16)
end)
it("ranks empty-slot upgrades by full BIS stat value", function()
it("ranks upgrades by weighted spec stats", function()
equip("MainHand", 21869)
local data = ns.Amibis:CompareGear()
expect(#data.topUpgrades).toEqual(3)
-- Shoulder: 45 spell damage (x3) + 20 intellect (x1) = 155
expect(data.topUpgrades[1].slot).toEqual("Shoulder")
expect(data.topUpgrades[1].score).toEqual(65)
expect(data.topUpgrades[1].statDiffs).toEqual({ spellPower = 45, intellect = 20 })
expect(data.topUpgrades[2].slot).toEqual("Head")
expect(data.topUpgrades[2].score).toEqual(45)
expect(data.topUpgrades[3].slot).toEqual("MainHand")
expect(data.topUpgrades[3].score).toEqual(25)
expect(data.topUpgrades[3].statDiffs.spellPower).toEqual(25)
expect(data.topUpgrades[1].score).toEqual(155)
expect(data.topUpgrades[1].statDiffs).toEqual({ spellDamage = 45, intellect = 20 })
-- MainHand: (60 - 35) spell damage (x3) = 75
expect(data.topUpgrades[2].slot).toEqual("MainHand")
expect(data.topUpgrades[2].score).toEqual(75)
-- Head: 20 intellect (x1) + 25 spirit (x1) = 45
expect(data.topUpgrades[3].slot).toEqual("Head")
expect(data.topUpgrades[3].score).toEqual(45)
end)
it("includes a partial stat gain when only one stat improves", function()
@@ -84,7 +86,7 @@ describe("CompareGear: upgrade scoring", function()
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 15,
["ITEM_MOD_SPIRIT_SHORT"] = 10,
["ITEM_MOD_SPELL_POWER_SHORT"] = 8,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 8,
},
}
equip("Head", 21891)
@@ -135,7 +137,7 @@ describe("CompareGear: spec-specific stat keys", function()
MockItems = {
[21869] = {
name = "Old Weapon",
stats = { ["ITEM_MOD_SPELL_POWER_SHORT"] = 20 },
stats = { ["ITEM_MOD_INTELLECT_SHORT"] = 20 },
},
[32374] = {
name = "Zhar'doom, Greatstaff of the Devourer",
@@ -161,7 +163,7 @@ describe("CompareGear: spec-specific stat keys", function()
local mh = find_upgrade(data, "MainHand")
expect(mh).toBeTruthy()
expect(mh.statDiffs.spellDamage).toEqual(40)
expect(mh.score).toEqual(40)
expect(mh.score).toEqual(120)
end)
it("ignores spell damage for Holy", function()
@@ -199,12 +201,61 @@ describe("GetStatKeysForSpec", function()
expect(found).toBeTruthy()
end)
it("falls back to default keys for unsupported specs", function()
it("uses physical stats for melee specs", function()
local keys = ns.Amibis:GetStatKeysForSpec("WARRIOR", "Arms")
expect(#keys).toEqual(6)
for _, key in ipairs(keys) do
expect(key ~= "healing" and key ~= "spellDamage").toBeTruthy()
local seen = {}
for _, key in ipairs(keys) do seen[key] = true end
expect(seen.strength).toBeTruthy()
expect(seen.attackPower).toBeTruthy()
expect(seen.hit).toBeTruthy()
expect(seen.crit).toBeTruthy()
expect(seen.healing).toBeFalsy()
expect(seen.spellDamage).toBeFalsy()
expect(seen.spirit).toBeFalsy()
expect(seen.mp5).toBeFalsy()
end)
it("uses mitigation stats for tanks", function()
local keys = ns.Amibis:GetStatKeysForSpec("PALADIN", "Protection")
local seen = {}
for _, key in ipairs(keys) do seen[key] = true end
expect(seen.stamina).toBeTruthy()
expect(seen.defense).toBeTruthy()
expect(seen.dodge).toBeTruthy()
expect(seen.parry).toBeTruthy()
end)
it("differs between specs of the same class", function()
local shadow = table.concat(ns.Amibis:GetStatKeysForSpec("PRIEST", "Shadow"), ",")
local holy = table.concat(ns.Amibis:GetStatKeysForSpec("PRIEST", "Holy"), ",")
expect(shadow ~= holy).toBeTruthy()
end)
it("falls back to a default profile for unsupported specs", function()
local keys = ns.Amibis:GetStatKeysForSpec("DEATHKNIGHT", "Frost")
expect(#keys > 0).toBeTruthy()
end)
it("keeps every spec profile within the 8-row panel limit", function()
for _, class in ipairs(ns.Data.BISLists:GetAvailableClasses()) do
for _, spec in ipairs(ns.Data.BISLists:GetAvailableSpecs(class)) do
local keys = ns.Amibis:GetStatKeysForSpec(class, spec)
expect(#keys > 0).toBeTruthy()
expect(#keys <= 8).toBeTruthy()
end
end
end)
end)
describe("StatRatio weighting", function()
it("weights primary stats above secondary ones", function()
local ratios = ns.Amibis
local bis = { spellDamage = 100, spirit = 100 }
local primary = ratios:StatRatio({ spellDamage = 100, spirit = 0 }, bis, "PRIEST", "Shadow")
local secondary = ratios:StatRatio({ spellDamage = 0, spirit = 100 }, bis, "PRIEST", "Shadow")
expect(primary > secondary).toBeTruthy()
expect(primary).toBeCloseTo(0.75)
expect(secondary).toBeCloseTo(0.25)
end)
end)
@@ -231,7 +282,7 @@ describe("GetCompletionRatio", function()
name = entry.name,
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 100,
["ITEM_MOD_SPELL_POWER_SHORT"] = 50,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 50,
},
}
equip(slot, entry.itemID)
@@ -252,21 +303,23 @@ describe("latest phase progress", function()
AmibisCharDB.overrideSpec = "Shadow"
end)
it("exposes the latest phase and nil ratio while stats load", function()
it("reports the latest phase and an estimate while stats load", function()
local data = ns.Amibis:CompareGear()
expect(data.latestPhase).toEqual("T6")
expect(data.latestCompletionRatio).toBeNil()
expect(data.latestPhase).toEqual("ZA")
expect(data.latestStatsComplete).toBeFalsy()
expect(type(data.latestCompletionRatio)).toEqual("number")
expect(data.latestCompletionRatio).toEqual(0)
end)
it("measures progress against the latest phase, not the selected one", function()
local latestList = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "T6")
local latestList = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "ZA")
local oldList = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "T4")
for slot, entry in pairs(oldList) do
MockItems[entry.itemID] = {
name = entry.name,
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 100,
["ITEM_MOD_SPELL_POWER_SHORT"] = 50,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 50,
},
}
equip(slot, entry.itemID)
@@ -276,23 +329,93 @@ describe("latest phase progress", function()
name = entry.name,
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 200,
["ITEM_MOD_SPELL_POWER_SHORT"] = 90,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 90,
},
}
end
AmibisDB.selectedPhase = "T4"
local data = ns.Amibis:CompareGear()
expect(data.phase).toEqual("T4")
expect(data.latestPhase).toEqual("T6")
expect(data.latestPhase).toEqual("ZA")
expect(ns.Amibis:GetCompletionRatio(data)).toBeCloseTo(1.0)
expect(data.latestCompletionRatio < 1.0).toBeTruthy()
expect(data.latestCompletionRatio > 0.3).toBeTruthy()
end)
it("ratio matches for T6-only lists (latest equals selected)", function()
local list = ns.Data.BISLists:GetBISList("PALADIN", "Protection", "T6")
it("ratio matches when the latest phase is also selected", function()
local list = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "ZA")
expect(list).toBeTruthy()
AmibisDB.selectedPhase = "ZA"
local data = ns.Amibis:CompareGear()
expect(data.latestPhase).toEqual("T6")
expect(data.phase).toEqual("ZA")
expect(data.latestPhase).toEqual("ZA")
end)
end)
describe("latest phase progress is independent of the selected phase", function()
before_each(function()
MockItems = {}
MockEquipped = {}
AmibisCharDB.overrideSpec = "Shadow"
AmibisDB.selectedPhase = "T4"
end)
it("falls back to latest-phase slot completion when the latest list is not cached", function()
local t4 = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "T4")
local za = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "ZA")
-- Make the selected phase look fully cached, but leave the ZA list uncached.
for _, entry in pairs(t4) do
MockItems[entry.itemID] = {
name = entry.name,
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 100,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 50,
},
}
end
-- Equip two ZA BIS pieces without caching the rest of the list.
equip("Head", za["Head"].itemID)
equip("Shoulder", za["Shoulder"].itemID)
local total = 0
for _ in pairs(za) do total = total + 1 end
local data = ns.Amibis:CompareGear()
expect(data.latestPhase).toEqual("ZA")
expect(data.latestStatsComplete).toBeFalsy()
expect(data.latestCompletionRatio).toBeCloseTo(2 / total)
end)
it("reports the same ratio for every selected phase once stats are cached", function()
for _, phase in ipairs({ "T4", "T5", "T6", "ZA" }) do
for _, entry in pairs(ns.Data.BISLists:GetBISList("PRIEST", "Shadow", phase)) do
MockItems[entry.itemID] = {
name = entry.name,
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 100,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 50,
},
}
end
end
local t6 = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "T6")
for slot, entry in pairs(t6) do
equip(slot, entry.itemID)
end
local results = {}
for _, phase in ipairs({ "T4", "T5", "T6", "ZA" }) do
AmibisDB.selectedPhase = phase
local data = ns.Amibis:CompareGear()
expect(data.latestStatsComplete).toBeTruthy()
table.insert(results, data.latestCompletionRatio)
end
for i = 2, #results do
expect(results[i]).toBeCloseTo(results[1])
end
end)
end)
+98 -1
View File
@@ -65,17 +65,19 @@ describe("phase ordering and resolution", function()
expect(phases[1]).toEqual("T4")
expect(phases[2]).toEqual("T5")
expect(phases[3]).toEqual("T6")
expect(phases[4]).toEqual("ZA")
end)
it("reports the latest phase for every spec", function()
for _, class in ipairs(BIS:GetAvailableClasses()) do
for _, spec in ipairs(BIS:GetAvailableSpecs(class)) do
expect(BIS:GetLatestPhase(class, spec)).toEqual("T6")
expect(BIS:GetLatestPhase(class, spec)).toEqual("ZA")
end
end
end)
it("keeps the saved phase when it exists", function()
expect(BIS:ResolvePhase("PRIEST", "Shadow", "ZA")).toEqual("ZA")
expect(BIS:ResolvePhase("PRIEST", "Shadow", "T6")).toEqual("T6")
expect(BIS:ResolvePhase("PRIEST", "Shadow", "T5")).toEqual("T5")
end)
@@ -143,3 +145,98 @@ describe("T4 (Phase 1) data", function()
expect(BIS:GetBISList("PALADIN", "Protection", "T5")).toBeNil()
end)
end)
describe("T5 (Phase 2) data", function()
it("shadow priest T5 trinket is current site data", function()
local list = BIS:GetBISList("PRIEST", "Shadow", "T5")
expect(list["Trinket1"].itemID).toEqual(27683)
expect(list["Trinket1"].name).toEqual("Quagmirran's Eye")
end)
it("warlock T5 splits between affliction and demonology/destruction", function()
local affliction = BIS:GetBISList("WARLOCK", "Affliction", "T5")
local demonology = BIS:GetBISList("WARLOCK", "Demonology", "T5")
local destruction = BIS:GetBISList("WARLOCK", "Destruction", "T5")
expect(affliction["Shoulder"].name).toEqual("Mantle of the Corruptor")
expect(demonology["Shoulder"].name).toEqual("Voidheart Mantle")
expect(demonology).toEqual(destruction)
local count = 0
for _ in pairs(affliction) do count = count + 1 end
expect(count >= 15).toBeTruthy()
end)
end)
describe("ZA (Phase 4) data", function()
it("covers every spec", function()
for _, class in ipairs(BIS:GetAvailableClasses()) do
for _, spec in ipairs(BIS:GetAvailableSpecs(class)) do
local list = BIS:GetBISList(class, spec, "ZA")
expect(list).toBeTruthy()
end
end
end)
it("shadow priest ZA neck comes from Zul'jin", function()
local list = BIS:GetBISList("PRIEST", "Shadow", "ZA")
expect(list["Neck"].itemID).toEqual(33466)
expect(list["Neck"].name).toEqual("Loop of Cursed Bones")
expect(list["Neck"].source).toEqual("Zul'Aman - Zul'jin")
end)
it("hunter BM and MM share the ZA list", function()
local bm = BIS:GetBISList("HUNTER", "Beast Mastery", "ZA")
expect(BIS:GetBISList("HUNTER", "Marksmanship", "ZA")).toEqual(bm)
expect(bm["Trinket0"].name).toEqual("Berserker's Call")
expect(bm["Trinket0"].source).toEqual("Zul'Aman - Zul'jin")
end)
it("discipline priest shares the holy ZA list", function()
expect(BIS:GetBISList("PRIEST", "Discipline", "ZA"))
.toEqual(BIS:GetBISList("PRIEST", "Holy", "ZA"))
end)
it("all three warlock specs share the ZA list", function()
local affliction = BIS:GetBISList("WARLOCK", "Affliction", "ZA")
expect(BIS:GetBISList("WARLOCK", "Demonology", "ZA")).toEqual(affliction)
expect(BIS:GetBISList("WARLOCK", "Destruction", "ZA")).toEqual(affliction)
end)
it("every list includes at least one Zul'Aman drop", function()
for _, class in ipairs(BIS:GetAvailableClasses()) do
for _, spec in ipairs(BIS:GetAvailableSpecs(class)) do
local list = BIS:GetBISList(class, spec, "ZA")
local found = false
for _, entry in pairs(list) do
if entry.source:find("Zul'Aman", 1, true) then
found = true
break
end
end
expect(found).toBeTruthy()
end
end
end)
it("excludes items that are not available until Sunwell", function()
local list = BIS:GetBISList("PALADIN", "Holy", "ZA")
expect(list["MainHand"].itemID).toEqual(32500)
expect(list["MainHand"].name).toEqual("Crystal Spire of Karabor")
end)
end)
describe("source formatting", function()
it("dash-joins quest rewards", function()
local list = BIS:GetBISList("PRIEST", "Holy", "T5")
expect(list["Neck"].source).toEqual("Quest Reward - Kael'thas and the Verdant Sphere")
end)
it("dash-joins heroic dungeon bosses", function()
local list = BIS:GetBISList("DRUID", "Balance", "T5")
expect(list["Trinket1"].source).toEqual("Slave Pens (H) - Quagmirran")
end)
it("space-joins profession vendors", function()
local list = BIS:GetBISList("DRUID", "Balance", "T5")
expect(list["Legs"].source).toEqual("Tailoring BoP Pattern (375)")
end)
end)
+53
View File
@@ -0,0 +1,53 @@
-- Slash-command tests: /amibis spec <name> and /amibis spec clear.
local _, ns = ...
-- WoW exposes string:trim(); plain Lua does not.
if not string.trim then
function string.trim(s)
return (s:gsub("^%s+", ""):gsub("%s+$", ""))
end
end
local function run(msg)
local output = {}
local realPrint = print
print = function(text) table.insert(output, tostring(text)) end
SlashCmdList["AMIBIS"](msg)
print = realPrint
return table.concat(output, "\n"), output
end
describe("/amibis spec", function()
before_each(function()
AmibisCharDB.overrideSpec = nil
end)
it("sets a spec override", function()
run("spec Holy")
expect(AmibisCharDB.overrideSpec).toEqual("Holy")
end)
it("normalizes case and multi-word spec names", function()
run(" SPEC beast mastery ")
expect(AmibisCharDB.overrideSpec).toEqual("Beast Mastery")
end)
it("clears the override instead of setting a spec named clear", function()
AmibisCharDB.overrideSpec = "Shadow"
local text = run("spec clear")
expect(AmibisCharDB.overrideSpec).toBeNil()
expect(text:find("cleared", 1, true)).toBeTruthy()
end)
it("clears the override regardless of case or extra spaces", function()
AmibisCharDB.overrideSpec = "Shadow"
run(" SPEC CLEAR ")
expect(AmibisCharDB.overrideSpec).toBeNil()
end)
it("keeps the override when the spec name is missing", function()
AmibisCharDB.overrideSpec = "Shadow"
run("spec")
expect(AmibisCharDB.overrideSpec).toEqual("Shadow")
end)
end)
+98 -1
View File
@@ -61,6 +61,46 @@ describe("ScanItemStats", function()
expect(stats.mp5).toEqual(10)
end)
it("reads TBC school-specific spell haste and crit keys", function()
MockItems[8] = {
name = "Sunfire Robe",
stats = {
["ITEM_MOD_HASTE_SPELL_RATING_SHORT"] = 40,
["ITEM_MOD_CRIT_SPELL_RATING_SHORT"] = 23,
["ITEM_MOD_SPELL_POWER_SHORT"] = 54,
},
}
local stats = ns.Amibis:ScanItemStats(8)
expect(stats.haste).toEqual(40)
expect(stats.crit).toEqual(23)
expect(stats.spellPower).toEqual(54)
end)
it("reads TBC melee and ranged haste keys", function()
MockItems[9] = {
name = "Physical Haste Item",
stats = {
["ITEM_MOD_HASTE_MELEE_RATING_SHORT"] = 30,
["ITEM_MOD_HASTE_RANGED_RATING_SHORT"] = 30,
["ITEM_MOD_CRIT_MELEE_RATING_SHORT"] = 15,
},
}
local stats = ns.Amibis:ScanItemStats(9)
expect(stats.haste).toEqual(30)
expect(stats.crit).toEqual(15)
end)
it("does not add generic and school-specific haste together", function()
MockItems[10] = {
name = "Double Reported Haste",
stats = {
["ITEM_MOD_HASTE_RATING_SHORT"] = 20,
["ITEM_MOD_HASTE_SPELL_RATING_SHORT"] = 20,
},
}
expect(ns.Amibis:ScanItemStats(10).haste).toEqual(20)
end)
it("keeps the highest school value", function()
MockItems[4] = {
name = "Mixed School Item",
@@ -94,7 +134,7 @@ describe("ScanItemStats", function()
name = "Resist Item",
stats = {
["ITEM_MOD_FIRE_RESISTANCE_SHORT"] = 15,
["ITEM_MOD_STRENGTH_SHORT"] = 8,
["ITEM_MOD_ARCANE_RESISTANCE_SHORT"] = 8,
["ITEM_MOD_INTELLECT_SHORT"] = 4,
},
}
@@ -105,6 +145,63 @@ describe("ScanItemStats", function()
expect(keyCount).toEqual(1)
end)
it("reads physical stats", function()
MockItems[11] = {
name = "Melee Item",
stats = {
["ITEM_MOD_STRENGTH_SHORT"] = 40,
["ITEM_MOD_AGILITY_SHORT"] = 25,
["ITEM_MOD_ATTACK_POWER_SHORT"] = 80,
["ITEM_MOD_HIT_RATING_SHORT"] = 10,
["ITEM_MOD_EXPERTISE_RATING_SHORT"] = 12,
["ITEM_MOD_ARMOR_PENETRATION_RATING_SHORT"] = 15,
["ITEM_MOD_CRIT_RATING_SHORT"] = 20,
},
}
local stats = ns.Amibis:ScanItemStats(11)
expect(stats.strength).toEqual(40)
expect(stats.agility).toEqual(25)
expect(stats.attackPower).toEqual(80)
expect(stats.hit).toEqual(10)
expect(stats.expertise).toEqual(12)
expect(stats.armorPen).toEqual(15)
expect(stats.crit).toEqual(20)
end)
it("reads tank and armor stats", function()
MockItems[12] = {
name = "Tank Item",
stats = {
["ITEM_MOD_STAMINA_SHORT"] = 60,
["ITEM_MOD_DEFENSE_SKILL_RATING_SHORT"] = 20,
["ITEM_MOD_DODGE_RATING_SHORT"] = 18,
["ITEM_MOD_PARRY_RATING_SHORT"] = 17,
["ITEM_MOD_BLOCK_RATING_SHORT"] = 16,
["ITEM_MOD_BLOCK_VALUE_SHORT"] = 40,
["RESISTANCE0_NAME"] = 1200,
},
}
local stats = ns.Amibis:ScanItemStats(12)
expect(stats.stamina).toEqual(60)
expect(stats.defense).toEqual(20)
expect(stats.dodge).toEqual(18)
expect(stats.parry).toEqual(17)
expect(stats.block).toEqual(16)
expect(stats.blockValue).toEqual(40)
expect(stats.armor).toEqual(1200)
end)
it("takes MAX across TBC hit rating keys", function()
MockItems[13] = {
name = "Hit Item",
stats = {
["ITEM_MOD_HIT_SPELL_RATING_SHORT"] = 14,
["ITEM_MOD_HIT_RATING_SHORT"] = 14,
},
}
expect(ns.Amibis:ScanItemStats(13).hit).toEqual(14)
end)
it("returns nil for unknown items", function()
expect(ns.Amibis:ScanItemStats(999999)).toBeNil()
end)
+82
View File
@@ -0,0 +1,82 @@
-- UI smoke tests: the stats panel must rebuild when the selected spec changes.
local _, ns = ...
local function cacheList(list)
for _, entry in pairs(list) do
MockItems[entry.itemID] = {
name = entry.name,
stats = {
["ITEM_MOD_INTELLECT_SHORT"] = 50,
["ITEM_MOD_SPIRIT_SHORT"] = 30,
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 40,
["ITEM_MOD_SPELL_HEALING_DONE_SHORT"] = 60,
},
}
end
end
local function visibleTexts()
local texts = {}
for _, frame in ipairs(MockFrames) do
for _, fontString in ipairs(frame.fonts or {}) do
if fontString.shown and fontString.text and fontString.text ~= "" then
texts[fontString.text] = true
end
end
end
return texts
end
describe("UI stat panel", function()
it("shows healing after switching from Shadow to Holy", function()
MockItems = {}
MockEquipped = {}
AmibisDB.selectedPhase = "ZA"
AmibisCharDB.overrideSpec = "Shadow"
cacheList(ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "ZA"))
cacheList(ns.Data.BISLists:GetBISList("PRIEST", "Holy", "ZA"))
ns.UI.Initialize()
if not ns.UI.IsShown() then
ns.UI.ToggleFrame()
end
local shadowTexts = visibleTexts()
expect(shadowTexts["+Spell Damage"]).toBeTruthy()
expect(shadowTexts["+Healing"]).toBeFalsy()
AmibisCharDB.overrideSpec = "Holy"
ns.UI.RefreshUI()
local holyTexts = visibleTexts()
expect(holyTexts["+Healing"]).toBeTruthy()
expect(holyTexts["+Spell Damage"]).toBeFalsy()
end)
it("closes the window when Escape is pressed", function()
ns.UI.Initialize()
if not ns.UI.IsShown() then
ns.UI.ToggleFrame()
end
expect(ns.UI.IsShown()).toBeTruthy()
local registered = false
for _, name in ipairs(UISpecialFrames) do
if name == "AmibisMainFrame" then registered = true end
end
expect(registered).toBeTruthy()
-- Simulate an in-flight stats retry so the OnHide cleanup is exercised.
ns.Amibis._statsRetryTimer = CreateFrame("Frame")
-- Mirrors FrameXML's CloseSpecialWindows(): hide every shown special frame.
for _, name in ipairs(UISpecialFrames) do
local frame = _G[name]
if frame and frame:IsShown() then frame:Hide() end
end
expect(ns.UI.IsShown()).toBeFalsy()
expect(ns.Amibis._statsRetryTimer).toBeNil()
end)
end)
+60 -4
View File
@@ -48,15 +48,30 @@ function IsShiftKeyDown() return false end
function IsControlKeyDown() return false end
local function makeChild()
return setmetatable({}, {
__index = function(_, key)
local child = { shown = true, text = "" }
return setmetatable(child, {
__index = function(self, key)
if key == "SetText" then
return function(_, value)
self.text = value
return self
end
elseif key == "GetText" then
return function() return self.text end
elseif key == "Show" then
return function() self.shown = true; return self end
elseif key == "Hide" then
return function() self.shown = false; return self end
elseif key == "IsShown" then
return function() return self.shown end
end
return function(_, ...) return nil end
end
})
end
local function makeFrame()
local frame = { fonts = {}, textures = {} }
local frame = { fonts = {}, textures = {}, shown = true, width = 0, height = 0, scripts = {} }
return setmetatable(frame, {
__index = function(self, key)
if key == "CreateFontString" then
@@ -71,6 +86,43 @@ local function makeFrame()
table.insert(self.textures, tx)
return tx
end
elseif key == "SetScript" then
return function(_, event, handler)
self.scripts[event] = handler
return self
end
elseif key == "GetScript" then
return function(_, event)
return self.scripts[event]
end
elseif key == "Show" then
return function()
self.shown = true
return self
end
elseif key == "Hide" then
return function()
local wasShown = self.shown
self.shown = false
local handler = self.scripts["OnHide"]
if wasShown and handler then handler(self) end
return self
end
elseif key == "IsShown" then
return function() return self.shown end
elseif key == "SetSize" then
return function(_, width, height)
self.width, self.height = width, height
return self
end
elseif key == "GetWidth" then
return function() return self.width end
elseif key == "GetHeight" then
return function() return self.height end
elseif key == "SetWidth" then
return function(_, width) self.width = width; return self end
elseif key == "SetHeight" then
return function(_, height) self.height = height; return self end
end
return function(_, ...) return self end
end
@@ -78,11 +130,15 @@ local function makeFrame()
end
_G.MockFrames = {}
function CreateFrame()
function CreateFrame(frameType, name, parent, template)
local f = makeFrame()
if name then
_G[name] = f
end
table.insert(_G.MockFrames, f)
return f
end
_G.GameTooltip = makeFrame()
_G.SlashCmdList = {}
_G.UISpecialFrames = { "GameMenuFrame", "StaticPopup1" }
+98 -24
View File
@@ -52,6 +52,27 @@ local function CreateMainFrame()
self:StopMovingOrSizing()
Amibis:SaveFramePosition(self)
end)
frame:SetScript("OnHide", function()
if Amibis._statsRetryTimer then
Amibis._statsRetryTimer:Hide()
Amibis._statsRetryTimer = nil
end
end)
-- Registering with UISpecialFrames makes the Escape key close the window
-- (and suppresses the game menu, like the default UI panels).
if UISpecialFrames then
local registered = false
for _, name in ipairs(UISpecialFrames) do
if name == "AmibisMainFrame" then
registered = true
break
end
end
if not registered then
table.insert(UISpecialFrames, "AmibisMainFrame")
end
end
frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
return frame
@@ -249,9 +270,25 @@ local STAT_LABELS = {
spellPower = "+Spell Power",
intellect = "Intellect",
spirit = "Spirit",
stamina = "Stamina",
mp5 = "MP5",
haste = "Haste",
crit = "Crit",
hit = "Hit",
attackPower = "Attack Power",
rangedAttackPower = "Ranged AP",
feralAttackPower = "Feral AP",
strength = "Strength",
agility = "Agility",
expertise = "Expertise",
armorPen = "Armor Pen",
defense = "Defense",
dodge = "Dodge",
parry = "Parry",
block = "Block",
blockValue = "Block Value",
armor = "Armor",
resilience = "Resilience",
}
local STAT_DISPLAY_NAME = {
@@ -260,9 +297,25 @@ local STAT_DISPLAY_NAME = {
spellPower = "spell power",
intellect = "intellect",
spirit = "spirit",
stamina = "stamina",
mp5 = "mp5",
haste = "haste",
crit = "crit",
hit = "hit",
attackPower = "attack power",
rangedAttackPower = "ranged AP",
feralAttackPower = "feral AP",
strength = "strength",
agility = "agility",
expertise = "expertise",
armorPen = "armor pen",
defense = "defense",
dodge = "dodge",
parry = "parry",
block = "block",
blockValue = "block value",
armor = "armor",
resilience = "resilience",
}
local STATS_COL_W = 60
@@ -291,7 +344,14 @@ local function FormatUpgradeEntry(idx, upgrade)
for statKey, diff in pairs(upgrade.statDiffs) do
table.insert(sorted, { key = statKey, diff = diff })
end
table.sort(sorted, function(a, b) return a.diff > b.diff end)
-- Show the gains this spec cares about most, not just the biggest number.
table.sort(sorted, function(a, b)
local aWeight = (upgrade.statWeights and upgrade.statWeights[a.key]) or 1
local bWeight = (upgrade.statWeights and upgrade.statWeights[b.key]) or 1
local aValue, bValue = a.diff * aWeight, b.diff * bWeight
if aValue ~= bValue then return aValue > bValue end
return a.diff > b.diff
end)
local parts = {}
local maxShow = math.min(2, #sorted)
@@ -414,7 +474,7 @@ local function RebuildStatRows(panel, statKeys)
diff:SetTextColor(1, 1, 1, 1)
StatLabels[statKey] = label
StatValues[statKey] = { current = current, bis = bis, diff = diff }
StatValues[statKey] = { label = label, current = current, bis = bis, diff = diff }
end
panel:SetHeight(#statKeys * 16 + 24)
@@ -535,23 +595,44 @@ function ns.UI.Initialize()
InitializeUI()
end
function ns.UI.IsShown()
return MainFrame ~= nil and MainFrame:IsShown()
end
function ns.UI.ToggleFrame()
if not MainFrame then
InitializeUI()
end
if MainFrame:IsShown() then
-- Hiding runs the frame's OnHide script, which stops the stats retry timer.
MainFrame:Hide()
if Amibis._statsRetryTimer then
Amibis._statsRetryTimer:Hide()
Amibis._statsRetryTimer = nil
end
else
MainFrame:Show()
Amibis._statsRetryAttempts = nil
ns.UI.RefreshUI()
end
end
local function ScheduleStatsRefresh()
if Amibis._statsRetryTimer then return end
Amibis._statsRetryAttempts = (Amibis._statsRetryAttempts or 0) + 1
if Amibis._statsRetryAttempts > 20 then return end
Amibis._statsRetryTimer = CreateFrame("Frame")
Amibis._statsRetryTimer.elapsed = 0
Amibis._statsRetryTimer:SetScript("OnUpdate", function(self, elapsed)
self.elapsed = self.elapsed + elapsed
if self.elapsed >= 1.5 then
self:Hide()
Amibis._statsRetryTimer = nil
if MainFrame and MainFrame:IsShown() then
ns.UI.RefreshUI()
end
end
end)
Amibis._statsRetryTimer:Show()
end
function ns.UI.RefreshUI()
if not MainFrame or not MainFrame:IsShown() then
return
@@ -590,13 +671,14 @@ function ns.UI.RefreshUI()
if PhaseBar then
RebuildPhaseButtons(data.class, data.spec, data.phase)
local ratio = data.latestCompletionRatio or Amibis:GetCompletionRatio(data)
local ratio = data.latestCompletionRatio or 0
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))
local prefix = data.latestStatsComplete == false and "~" or ""
PhaseProgressText:SetText(string.format("%s%d%% to %s", prefix, math.floor(ratio * 100 + 0.5), targetPhase))
end
end
@@ -688,22 +770,6 @@ function ns.UI.RefreshUI()
vals.diff:SetText("")
end
end
if not Amibis._statsRetryTimer then
Amibis._statsRetryTimer = CreateFrame("Frame")
Amibis._statsRetryTimer.elapsed = 0
Amibis._statsRetryTimer:SetScript("OnUpdate", function(self, elapsed)
self.elapsed = self.elapsed + elapsed
if self.elapsed >= 1.5 then
self:Hide()
Amibis._statsRetryTimer = nil
if MainFrame and MainFrame:IsShown() then
ns.UI.RefreshUI()
end
end
end)
Amibis._statsRetryTimer:Show()
end
else
if StatsPanelTitle then
StatsPanelTitle:SetText("Stats Comparison")
@@ -762,6 +828,14 @@ function ns.UI.RefreshUI()
end
end
end
-- Keep retrying until both the selected list and the latest-phase progress
-- have item stats; otherwise the bar can be stuck on the slot estimate.
if not data.statsComplete or data.latestStatsComplete == false then
ScheduleStatsRefresh()
else
Amibis._statsRetryAttempts = nil
end
end
local initFrame = CreateFrame("Frame")
+10 -2
View File
@@ -8,7 +8,7 @@ A World of Warcraft: The Burning Crusade Classic addon that compares your equipp
- **Gear Comparison** — See at a glance which slots are BIS and which can be upgraded
- **Auto-Detection** — Automatically detects your class and active talent spec
- **Stats Comparison** — Side-by-side stat breakdown (Healing, Spell Power, Intellect, Spirit, MP5, Haste, Crit)
- **Stats Comparison** — Side-by-side stat breakdown tailored to your spec (spell damage/hit/crit/haste for casters, strength/AP/expertise for melee, stamina/mitigation for tanks, healing/spirit/MP5 for healers)
- **Upgrade Highlight** — Identifies your biggest available upgrade
- **Persistent Settings** — Window position and spec overrides saved per character
@@ -26,6 +26,8 @@ A World of Warcraft: The Burning Crusade Classic addon that compares your equipp
- **Shift+Click** a row to link the BIS item in chat
- **Ctrl+Click** a row to open the dress-up preview
- **Hover** a row to see the item tooltip
- **Press Escape** to close the window (registered in `UISpecialFrames`)
- **Click a phase segment** (T4 | T5 | T6 | ZA) to switch the comparison target
## Adding BIS Lists
@@ -76,7 +78,13 @@ local BIS_DATA = {
- Class keys must match WoW's English class constants: `"WARRIOR"`, `"PRIEST"`, `"MAGE"`, etc. (all caps)
- Spec names must match the values in `Amibis:GetPlayerSpec()` (e.g. `"Discipline"`, `"Holy"`, `"Arms"`)
- Phase keys are strings like `"T5"`, `"T6"` — the default phase is set in `Amibis.lua` under `DEFAULT_AMIBIS_DB.selectedPhase`
- Phase keys are strings like `"T5"`, `"T6"`, `"ZA"` — the default phase is set in `Amibis.lua` under `DEFAULT_AMIBIS_DB.selectedPhase`
## Continuous integration
`.gitea/workflows/tests.yaml` runs the offline test suite on every push via
Gitea Actions (`lua5.4 Amibis/Tests/run.lua`). It needs a runner with the
`ubuntu-latest` label; results show up in the repository's **Actions** tab.
## Installation