Compare commits
12
Commits
7fda3db472
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2abe972ad | ||
|
|
9d809309ac | ||
|
|
1fda0d3817 | ||
|
|
f46b039328 | ||
|
|
d8fefc947e | ||
|
|
cc3971fe93 | ||
|
|
5fba4ac10c | ||
|
|
b66491c5be | ||
|
|
e08e288f73 | ||
|
|
912ed8f255 | ||
|
|
907d274b3a | ||
|
|
48040c3ae1 |
No files matched your search
@@ -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
|
||||||
@@ -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).
|
- **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`
|
||||||
- **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.
|
- **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) 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.
|
- **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
|
## Adding new BIS data
|
||||||
1. Add a `local CLASS_T4 = { ... }` table in `Data/BISLists.lua` following the existing `PRIEST_T4` 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).
|
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
|
## 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)
|
||||||
- Color coding: green = BIS, yellow = upgrade available, gray = empty slot
|
- 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)
|
- 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.
|
||||||
+274
-58
@@ -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 = "T6",
|
selectedPhase = "ZA",
|
||||||
}
|
}
|
||||||
|
|
||||||
local DEFAULT_AMIBIS_CHAR_DB = {
|
local DEFAULT_AMIBIS_CHAR_DB = {
|
||||||
@@ -18,66 +18,101 @@ local DEFAULT_AMIBIS_CHAR_DB = {
|
|||||||
|
|
||||||
local TOP_UPGRADES_COUNT = 3
|
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"] = {
|
["PRIEST"] = {
|
||||||
["Discipline"] = { "healing", "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["Discipline"] = { { "healing", 3 }, { "intellect", 2 }, { "mp5", 2 }, { "haste", 2 }, { "spirit", 1 }, { "crit", 1 } },
|
||||||
["Holy"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["Holy"] = { { "healing", 3 }, { "intellect", 2 }, { "mp5", 2 }, { "haste", 2 }, { "spirit", 1 }, { "crit", 1 } },
|
||||||
["Shadow"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["Shadow"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 }, { "mp5", 1 } },
|
||||||
},
|
},
|
||||||
["DRUID"] = {
|
["DRUID"] = {
|
||||||
["Balance"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["Balance"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 }, { "mp5", 1 } },
|
||||||
["Restoration"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["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"] = {
|
["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"] = {
|
["SHAMAN"] = {
|
||||||
["Elemental"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["Elemental"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "mp5", 1 }, { "stamina", 1 } },
|
||||||
["Restoration"] = { "healing", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["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"] = {
|
["MAGE"] = {
|
||||||
["Arcane"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["Arcane"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
|
||||||
["Fire"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["Fire"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
|
||||||
["Frost"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["Frost"] = { { "spellDamage", 3 }, { "hit", 2 }, { "crit", 2 }, { "haste", 2 }, { "intellect", 1 }, { "spirit", 1 } },
|
||||||
},
|
},
|
||||||
["WARLOCK"] = {
|
["WARLOCK"] = {
|
||||||
["Affliction"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["Affliction"] = { { "spellDamage", 3 }, { "hit", 2 }, { "haste", 2 }, { "crit", 1 }, { "intellect", 1 }, { "spirit", 1 }, { "stamina", 1 } },
|
||||||
["Demonology"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["Demonology"] = { { "spellDamage", 3 }, { "hit", 2 }, { "haste", 2 }, { "crit", 1 }, { "intellect", 1 }, { "spirit", 1 }, { "stamina", 1 } },
|
||||||
["Destruction"] = { "spellDamage", "spellPower", "intellect", "spirit", "mp5", "haste", "crit" },
|
["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)
|
local function GetStatProfile(class, spec)
|
||||||
if class and UPGRADE_STAT_KEYS[class] and UPGRADE_STAT_KEYS[class][spec] then
|
local classProfiles = SPEC_STAT_PROFILES[class]
|
||||||
return UPGRADE_STAT_KEYS[class][spec]
|
if classProfiles and classProfiles[spec] then
|
||||||
|
return classProfiles[spec]
|
||||||
end
|
end
|
||||||
return DEFAULT_UPGRADE_STAT_KEYS
|
return DEFAULT_STAT_PROFILE
|
||||||
end
|
end
|
||||||
|
|
||||||
function Amibis:GetStatKeysForSpec(class, spec)
|
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
|
end
|
||||||
|
|
||||||
function Amibis:StatRatio(equippedStats, bisStats, class, spec)
|
function Amibis:StatRatio(equippedStats, bisStats, class, spec)
|
||||||
if not equippedStats or not bisStats then return 0 end
|
if not equippedStats or not bisStats then return 0 end
|
||||||
|
|
||||||
local statKeys = GetUpgradeStatKeys(class, spec)
|
local weightSum, sum = 0, 0
|
||||||
local count, sum = 0, 0
|
for _, entry in ipairs(GetStatProfile(class, spec)) do
|
||||||
for _, statKey in ipairs(statKeys) do
|
local statKey, weight = entry[1], entry[2]
|
||||||
local bis = bisStats[statKey] or 0
|
local bis = bisStats[statKey] or 0
|
||||||
if bis > 0 then
|
if bis > 0 then
|
||||||
local current = equippedStats[statKey] or 0
|
local current = equippedStats[statKey] or 0
|
||||||
local ratio = current / bis
|
local ratio = current / bis
|
||||||
if ratio > 1 then ratio = 1 end
|
if ratio > 1 then ratio = 1 end
|
||||||
sum = sum + ratio
|
sum = sum + ratio * weight
|
||||||
count = count + 1
|
weightSum = weightSum + weight
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if count == 0 then return 0 end
|
if weightSum == 0 then return 0 end
|
||||||
return sum / count
|
return sum / weightSum
|
||||||
end
|
end
|
||||||
|
|
||||||
function Amibis:GetCompletionRatio(data)
|
function Amibis:GetCompletionRatio(data)
|
||||||
@@ -188,6 +223,54 @@ function Amibis:GetEquippedItems()
|
|||||||
return items
|
return items
|
||||||
end
|
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 = {
|
local STAT_MAP = {
|
||||||
["ITEM_MOD_HEALING_DONE_SHORT"] = "healing",
|
["ITEM_MOD_HEALING_DONE_SHORT"] = "healing",
|
||||||
["ITEM_MOD_SPELL_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_SPIRIT_SHORT"] = "spirit",
|
||||||
["ITEM_MOD_STAMINA_SHORT"] = "stamina",
|
["ITEM_MOD_STAMINA_SHORT"] = "stamina",
|
||||||
["ITEM_MOD_MANA_REGENERATION_SHORT"] = "mp5",
|
["ITEM_MOD_MANA_REGENERATION_SHORT"] = "mp5",
|
||||||
|
["ITEM_MOD_MANA_REGENERATION"] = "mp5",
|
||||||
["ITEM_MOD_POWER_REGEN0_SHORT"] = "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_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_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_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_POWER_SHORT"] = "spellPower",
|
||||||
["ITEM_MOD_SPELL_DMG_SHORT"] = "spellDamage",
|
["ITEM_MOD_SPELL_DMG_SHORT"] = "spellDamage",
|
||||||
["ITEM_MOD_HEALING_SHORT"] = "healing",
|
["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
|
-- Stats that multiple WoW API keys map to (school-specific spell damage, hit,
|
||||||
-- rating, etc.): only one alias is ever active, so take MAX instead of SUM.
|
-- haste, crit, etc.): only one alias is ever active, so take MAX instead of SUM.
|
||||||
local ALIAS_STATS = {
|
local ALIAS_STATS = {
|
||||||
healing = true,
|
healing = true,
|
||||||
spellDamage = true,
|
spellDamage = true,
|
||||||
mp5 = true,
|
mp5 = true,
|
||||||
haste = true,
|
haste = true,
|
||||||
crit = true,
|
crit = true,
|
||||||
|
hit = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
function Amibis:ScanItemStats(itemID)
|
function Amibis:ScanItemStats(itemID)
|
||||||
@@ -254,13 +395,28 @@ function Amibis:AggregateStats(items)
|
|||||||
local totals = {
|
local totals = {
|
||||||
healing = 0,
|
healing = 0,
|
||||||
spellDamage = 0,
|
spellDamage = 0,
|
||||||
|
spellPower = 0,
|
||||||
intellect = 0,
|
intellect = 0,
|
||||||
spirit = 0,
|
spirit = 0,
|
||||||
stamina = 0,
|
stamina = 0,
|
||||||
mp5 = 0,
|
mp5 = 0,
|
||||||
haste = 0,
|
haste = 0,
|
||||||
crit = 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
|
for slotName, item in pairs(items) do
|
||||||
@@ -280,7 +436,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 = 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)
|
local bisList = ns.Data.BISLists:GetBISList(class, spec, phase)
|
||||||
if not bisList then
|
if not bisList then
|
||||||
@@ -301,10 +457,22 @@ function Amibis:CompareGear()
|
|||||||
local bisCount = 0
|
local bisCount = 0
|
||||||
local totalSlots = 0
|
local totalSlots = 0
|
||||||
local allUpgrades = {}
|
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
|
for slotName, bisItem in pairs(bisList) do
|
||||||
totalSlots = totalSlots + 1
|
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
|
local isBIS = false
|
||||||
|
|
||||||
if equippedItem and equippedItem.itemID == bisItem.itemID then
|
if equippedItem and equippedItem.itemID == bisItem.itemID then
|
||||||
@@ -324,13 +492,13 @@ function Amibis:CompareGear()
|
|||||||
local score = 0
|
local score = 0
|
||||||
local equippedStats = (equippedItem and self:ScanItemStats(equippedItem.itemID)) or {}
|
local equippedStats = (equippedItem and self:ScanItemStats(equippedItem.itemID)) or {}
|
||||||
local bisStats = self:ScanItemStats(bisItem.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)
|
local diff = (bisStats[statKey] or 0) - (equippedStats[statKey] or 0)
|
||||||
if diff > 0 then
|
if diff > 0 then
|
||||||
statDiffs[statKey] = diff
|
statDiffs[statKey] = diff
|
||||||
score = score + diff
|
score = score + diff * entry[2]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -339,6 +507,7 @@ function Amibis:CompareGear()
|
|||||||
equipped = equippedItem,
|
equipped = equippedItem,
|
||||||
bis = bisItem,
|
bis = bisItem,
|
||||||
statDiffs = statDiffs,
|
statDiffs = statDiffs,
|
||||||
|
statWeights = statWeights,
|
||||||
score = score,
|
score = score,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@@ -391,28 +560,55 @@ function Amibis:CompareGear()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local latestPhase = ns.Data.BISLists:GetLatestPhase(class, spec)
|
local latestPhase = ns.Data.BISLists:GetLatestPhase(class, spec)
|
||||||
local latestCompletionRatio = nil
|
local latestCompletionRatio = 0
|
||||||
if latestPhase and statsComplete then
|
local latestStatsComplete = false
|
||||||
|
if latestPhase then
|
||||||
local latestList = ns.Data.BISLists:GetBISList(class, spec, latestPhase)
|
local latestList = ns.Data.BISLists:GetBISList(class, spec, latestPhase)
|
||||||
if latestList then
|
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
|
for slotName, bisItem in pairs(latestList) do
|
||||||
|
latestItems[slotName] = { itemID = bisItem.itemID }
|
||||||
if not GetItemInfo(bisItem.itemID) then
|
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
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if latestStatsComplete then
|
|
||||||
if latestPhase == phase then
|
if latestItemsCached and equippedCached then
|
||||||
latestCompletionRatio = self:StatRatio(equippedStats, bisStats, class, spec)
|
local latestStats = bisStats
|
||||||
else
|
if latestPhase ~= phase then
|
||||||
local latestItems = {}
|
latestStats = self:AggregateStats(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
|
||||||
|
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
|
end
|
||||||
end
|
end
|
||||||
@@ -431,6 +627,7 @@ function Amibis:CompareGear()
|
|||||||
statsComplete = statsComplete,
|
statsComplete = statsComplete,
|
||||||
latestPhase = latestPhase,
|
latestPhase = latestPhase,
|
||||||
latestCompletionRatio = latestCompletionRatio,
|
latestCompletionRatio = latestCompletionRatio,
|
||||||
|
latestStatsComplete = latestStatsComplete,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -472,6 +669,7 @@ local eventFrame = CreateFrame("Frame")
|
|||||||
eventFrame:RegisterEvent("ADDON_LOADED")
|
eventFrame:RegisterEvent("ADDON_LOADED")
|
||||||
eventFrame:RegisterEvent("PLAYER_LOGIN")
|
eventFrame:RegisterEvent("PLAYER_LOGIN")
|
||||||
eventFrame:RegisterEvent("PLAYER_TALENT_UPDATE")
|
eventFrame:RegisterEvent("PLAYER_TALENT_UPDATE")
|
||||||
|
eventFrame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
|
||||||
|
|
||||||
eventFrame:SetScript("OnEvent", function(self, event, ...)
|
eventFrame:SetScript("OnEvent", function(self, event, ...)
|
||||||
if event == "ADDON_LOADED" then
|
if event == "ADDON_LOADED" then
|
||||||
@@ -481,28 +679,46 @@ eventFrame:SetScript("OnEvent", function(self, event, ...)
|
|||||||
end
|
end
|
||||||
elseif event == "PLAYER_LOGIN" then
|
elseif event == "PLAYER_LOGIN" then
|
||||||
Amibis:InitializeUI()
|
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
|
if ns.UI and ns.UI.RefreshUI then
|
||||||
ns.UI.RefreshUI()
|
ns.UI.RefreshUI()
|
||||||
end
|
end
|
||||||
end
|
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"
|
SLASH_AMIBIS1 = "/amibis"
|
||||||
SlashCmdList["AMIBIS"] = function(msg)
|
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
|
if cmd == "" then
|
||||||
Amibis:ToggleFrame()
|
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
|
elseif cmd:find("^spec%s+") then
|
||||||
local spec = cmd:match("^spec%s+(.+)")
|
local spec = cmd:match("^spec%s+(.+)")
|
||||||
if spec and spec ~= "" then
|
if spec and spec ~= "" then
|
||||||
spec = spec:gsub("^%l", string.upper)
|
spec = NormalizeSpecName(spec)
|
||||||
AmibisCharDB.overrideSpec = spec
|
AmibisCharDB.overrideSpec = spec
|
||||||
print("Amibis: Spec override set to " .. spec .. ". Type /amibis spec clear to reset.")
|
print("Amibis: Spec override set to " .. spec .. ". Type /amibis spec clear to reset.")
|
||||||
|
RefreshUI()
|
||||||
end
|
end
|
||||||
elseif cmd == "spec clear" then
|
|
||||||
AmibisCharDB.overrideSpec = nil
|
|
||||||
print("Amibis: Spec override cleared.")
|
|
||||||
else
|
else
|
||||||
Amibis:ToggleFrame()
|
Amibis:ToggleFrame()
|
||||||
end
|
end
|
||||||
|
|||||||
+891
-436
File diff suppressed because it is too large.
Load diff
+10
-5
@@ -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.
|
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:
|
No Lua installed? On Debian/Ubuntu you can get one without root:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -23,9 +26,11 @@ apt-get download lua5.4 && dpkg -x lua5.4_*.deb /tmp/lua && /tmp/lua/usr/bin/lua
|
|||||||
|
|
||||||
| File | Covers |
|
| 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_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
|
## Layout
|
||||||
|
|
||||||
@@ -53,6 +58,6 @@ your dev machine, never in the game client.
|
|||||||
|
|
||||||
## Not covered
|
## Not covered
|
||||||
|
|
||||||
`UI/ComparisonFrame.lua` — its helpers are file-locals and testing them would
|
Most of `UI/ComparisonFrame.lua` — layout/anchoring and event wiring still need in-game
|
||||||
require a full frame API mock. The logic worth testing (stat scanning, scoring,
|
verification. `test_ui.lua` covers the stats-panel rebuild path using mocked frames
|
||||||
phase data) lives in the two suites above.
|
(font strings record `text`/`shown`, frames track `Show`/`Hide`/`IsShown`).
|
||||||
@@ -18,10 +18,13 @@ _G.AmibisCharDB = {}
|
|||||||
|
|
||||||
assert(loadfile("Amibis/Amibis.lua"))(ADDON_NAME, ns)
|
assert(loadfile("Amibis/Amibis.lua"))(ADDON_NAME, ns)
|
||||||
assert(loadfile("Amibis/Data/BISLists.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_data.lua"))(ADDON_NAME, ns)
|
||||||
assert(loadfile("Amibis/Tests/test_stats.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_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()
|
local success = TestHarness_report()
|
||||||
os.exit(success and 0 or 1)
|
os.exit(success and 0 or 1)
|
||||||
+152
-29
@@ -25,7 +25,7 @@ describe("CompareGear: upgrade scoring", function()
|
|||||||
MockItems = {
|
MockItems = {
|
||||||
[21869] = {
|
[21869] = {
|
||||||
name = "Old Weapon",
|
name = "Old Weapon",
|
||||||
stats = { ["ITEM_MOD_SPELL_POWER_SHORT"] = 35 },
|
stats = { ["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 35 },
|
||||||
},
|
},
|
||||||
[31064] = {
|
[31064] = {
|
||||||
name = "Hood of Absolution",
|
name = "Hood of Absolution",
|
||||||
@@ -37,7 +37,7 @@ describe("CompareGear: upgrade scoring", function()
|
|||||||
[31070] = {
|
[31070] = {
|
||||||
name = "Shoulderpads of Absolution",
|
name = "Shoulderpads of Absolution",
|
||||||
stats = {
|
stats = {
|
||||||
["ITEM_MOD_SPELL_POWER_SHORT"] = 45,
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 45,
|
||||||
["ITEM_MOD_INTELLECT_SHORT"] = 20,
|
["ITEM_MOD_INTELLECT_SHORT"] = 20,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -47,7 +47,7 @@ describe("CompareGear: upgrade scoring", function()
|
|||||||
},
|
},
|
||||||
[32374] = {
|
[32374] = {
|
||||||
name = "Zhar'doom, Greatstaff of the Devourer",
|
name = "Zhar'doom, Greatstaff of the Devourer",
|
||||||
stats = { ["ITEM_MOD_SPELL_POWER_SHORT"] = 60 },
|
stats = { ["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 60 },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
MockEquipped = {}
|
MockEquipped = {}
|
||||||
@@ -64,18 +64,20 @@ describe("CompareGear: upgrade scoring", function()
|
|||||||
expect(data.totalSlots).toEqual(16)
|
expect(data.totalSlots).toEqual(16)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("ranks empty-slot upgrades by full BIS stat value", function()
|
it("ranks upgrades by weighted spec stats", function()
|
||||||
equip("MainHand", 21869)
|
equip("MainHand", 21869)
|
||||||
local data = ns.Amibis:CompareGear()
|
local data = ns.Amibis:CompareGear()
|
||||||
expect(#data.topUpgrades).toEqual(3)
|
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].slot).toEqual("Shoulder")
|
||||||
expect(data.topUpgrades[1].score).toEqual(65)
|
expect(data.topUpgrades[1].score).toEqual(155)
|
||||||
expect(data.topUpgrades[1].statDiffs).toEqual({ spellPower = 45, intellect = 20 })
|
expect(data.topUpgrades[1].statDiffs).toEqual({ spellDamage = 45, intellect = 20 })
|
||||||
expect(data.topUpgrades[2].slot).toEqual("Head")
|
-- MainHand: (60 - 35) spell damage (x3) = 75
|
||||||
expect(data.topUpgrades[2].score).toEqual(45)
|
expect(data.topUpgrades[2].slot).toEqual("MainHand")
|
||||||
expect(data.topUpgrades[3].slot).toEqual("MainHand")
|
expect(data.topUpgrades[2].score).toEqual(75)
|
||||||
expect(data.topUpgrades[3].score).toEqual(25)
|
-- Head: 20 intellect (x1) + 25 spirit (x1) = 45
|
||||||
expect(data.topUpgrades[3].statDiffs.spellPower).toEqual(25)
|
expect(data.topUpgrades[3].slot).toEqual("Head")
|
||||||
|
expect(data.topUpgrades[3].score).toEqual(45)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("includes a partial stat gain when only one stat improves", function()
|
it("includes a partial stat gain when only one stat improves", function()
|
||||||
@@ -84,7 +86,7 @@ describe("CompareGear: upgrade scoring", function()
|
|||||||
stats = {
|
stats = {
|
||||||
["ITEM_MOD_INTELLECT_SHORT"] = 15,
|
["ITEM_MOD_INTELLECT_SHORT"] = 15,
|
||||||
["ITEM_MOD_SPIRIT_SHORT"] = 10,
|
["ITEM_MOD_SPIRIT_SHORT"] = 10,
|
||||||
["ITEM_MOD_SPELL_POWER_SHORT"] = 8,
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 8,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
equip("Head", 21891)
|
equip("Head", 21891)
|
||||||
@@ -135,7 +137,7 @@ describe("CompareGear: spec-specific stat keys", function()
|
|||||||
MockItems = {
|
MockItems = {
|
||||||
[21869] = {
|
[21869] = {
|
||||||
name = "Old Weapon",
|
name = "Old Weapon",
|
||||||
stats = { ["ITEM_MOD_SPELL_POWER_SHORT"] = 20 },
|
stats = { ["ITEM_MOD_INTELLECT_SHORT"] = 20 },
|
||||||
},
|
},
|
||||||
[32374] = {
|
[32374] = {
|
||||||
name = "Zhar'doom, Greatstaff of the Devourer",
|
name = "Zhar'doom, Greatstaff of the Devourer",
|
||||||
@@ -161,7 +163,7 @@ describe("CompareGear: spec-specific stat keys", function()
|
|||||||
local mh = find_upgrade(data, "MainHand")
|
local mh = find_upgrade(data, "MainHand")
|
||||||
expect(mh).toBeTruthy()
|
expect(mh).toBeTruthy()
|
||||||
expect(mh.statDiffs.spellDamage).toEqual(40)
|
expect(mh.statDiffs.spellDamage).toEqual(40)
|
||||||
expect(mh.score).toEqual(40)
|
expect(mh.score).toEqual(120)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("ignores spell damage for Holy", function()
|
it("ignores spell damage for Holy", function()
|
||||||
@@ -199,15 +201,64 @@ describe("GetStatKeysForSpec", function()
|
|||||||
expect(found).toBeTruthy()
|
expect(found).toBeTruthy()
|
||||||
end)
|
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")
|
local keys = ns.Amibis:GetStatKeysForSpec("WARRIOR", "Arms")
|
||||||
expect(#keys).toEqual(6)
|
local seen = {}
|
||||||
for _, key in ipairs(keys) do
|
for _, key in ipairs(keys) do seen[key] = true end
|
||||||
expect(key ~= "healing" and key ~= "spellDamage").toBeTruthy()
|
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)
|
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)
|
||||||
|
|
||||||
describe("GetCompletionRatio", function()
|
describe("GetCompletionRatio", function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
MockItems = {}
|
MockItems = {}
|
||||||
@@ -231,7 +282,7 @@ describe("GetCompletionRatio", function()
|
|||||||
name = entry.name,
|
name = entry.name,
|
||||||
stats = {
|
stats = {
|
||||||
["ITEM_MOD_INTELLECT_SHORT"] = 100,
|
["ITEM_MOD_INTELLECT_SHORT"] = 100,
|
||||||
["ITEM_MOD_SPELL_POWER_SHORT"] = 50,
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 50,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
equip(slot, entry.itemID)
|
equip(slot, entry.itemID)
|
||||||
@@ -252,21 +303,23 @@ describe("latest phase progress", function()
|
|||||||
AmibisCharDB.overrideSpec = "Shadow"
|
AmibisCharDB.overrideSpec = "Shadow"
|
||||||
end)
|
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()
|
local data = ns.Amibis:CompareGear()
|
||||||
expect(data.latestPhase).toEqual("T6")
|
expect(data.latestPhase).toEqual("ZA")
|
||||||
expect(data.latestCompletionRatio).toBeNil()
|
expect(data.latestStatsComplete).toBeFalsy()
|
||||||
|
expect(type(data.latestCompletionRatio)).toEqual("number")
|
||||||
|
expect(data.latestCompletionRatio).toEqual(0)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("measures progress against the latest phase, not the selected one", function()
|
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")
|
local oldList = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "T4")
|
||||||
for slot, entry in pairs(oldList) do
|
for slot, entry in pairs(oldList) do
|
||||||
MockItems[entry.itemID] = {
|
MockItems[entry.itemID] = {
|
||||||
name = entry.name,
|
name = entry.name,
|
||||||
stats = {
|
stats = {
|
||||||
["ITEM_MOD_INTELLECT_SHORT"] = 100,
|
["ITEM_MOD_INTELLECT_SHORT"] = 100,
|
||||||
["ITEM_MOD_SPELL_POWER_SHORT"] = 50,
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 50,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
equip(slot, entry.itemID)
|
equip(slot, entry.itemID)
|
||||||
@@ -276,23 +329,93 @@ describe("latest phase progress", function()
|
|||||||
name = entry.name,
|
name = entry.name,
|
||||||
stats = {
|
stats = {
|
||||||
["ITEM_MOD_INTELLECT_SHORT"] = 200,
|
["ITEM_MOD_INTELLECT_SHORT"] = 200,
|
||||||
["ITEM_MOD_SPELL_POWER_SHORT"] = 90,
|
["ITEM_MOD_SPELL_DAMAGE_DONE_SHORT"] = 90,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
AmibisDB.selectedPhase = "T4"
|
AmibisDB.selectedPhase = "T4"
|
||||||
local data = ns.Amibis:CompareGear()
|
local data = ns.Amibis:CompareGear()
|
||||||
expect(data.phase).toEqual("T4")
|
expect(data.phase).toEqual("T4")
|
||||||
expect(data.latestPhase).toEqual("T6")
|
expect(data.latestPhase).toEqual("ZA")
|
||||||
expect(ns.Amibis:GetCompletionRatio(data)).toBeCloseTo(1.0)
|
expect(ns.Amibis:GetCompletionRatio(data)).toBeCloseTo(1.0)
|
||||||
expect(data.latestCompletionRatio < 1.0).toBeTruthy()
|
expect(data.latestCompletionRatio < 1.0).toBeTruthy()
|
||||||
expect(data.latestCompletionRatio > 0.3).toBeTruthy()
|
expect(data.latestCompletionRatio > 0.3).toBeTruthy()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("ratio matches for T6-only lists (latest equals selected)", function()
|
it("ratio matches when the latest phase is also selected", function()
|
||||||
local list = ns.Data.BISLists:GetBISList("PALADIN", "Protection", "T6")
|
local list = ns.Data.BISLists:GetBISList("PRIEST", "Shadow", "ZA")
|
||||||
expect(list).toBeTruthy()
|
expect(list).toBeTruthy()
|
||||||
|
AmibisDB.selectedPhase = "ZA"
|
||||||
local data = ns.Amibis:CompareGear()
|
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)
|
||||||
end)
|
end)
|
||||||
@@ -65,17 +65,19 @@ describe("phase ordering and resolution", function()
|
|||||||
expect(phases[1]).toEqual("T4")
|
expect(phases[1]).toEqual("T4")
|
||||||
expect(phases[2]).toEqual("T5")
|
expect(phases[2]).toEqual("T5")
|
||||||
expect(phases[3]).toEqual("T6")
|
expect(phases[3]).toEqual("T6")
|
||||||
|
expect(phases[4]).toEqual("ZA")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("reports the latest phase for every spec", function()
|
it("reports the latest phase for every spec", function()
|
||||||
for _, class in ipairs(BIS:GetAvailableClasses()) do
|
for _, class in ipairs(BIS:GetAvailableClasses()) do
|
||||||
for _, spec in ipairs(BIS:GetAvailableSpecs(class)) 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
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("keeps the saved phase when it exists", function()
|
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", "T6")).toEqual("T6")
|
||||||
expect(BIS:ResolvePhase("PRIEST", "Shadow", "T5")).toEqual("T5")
|
expect(BIS:ResolvePhase("PRIEST", "Shadow", "T5")).toEqual("T5")
|
||||||
end)
|
end)
|
||||||
@@ -143,3 +145,98 @@ describe("T4 (Phase 1) data", function()
|
|||||||
expect(BIS:GetBISList("PALADIN", "Protection", "T5")).toBeNil()
|
expect(BIS:GetBISList("PALADIN", "Protection", "T5")).toBeNil()
|
||||||
end)
|
end)
|
||||||
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)
|
||||||
@@ -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)
|
||||||
@@ -61,6 +61,46 @@ describe("ScanItemStats", function()
|
|||||||
expect(stats.mp5).toEqual(10)
|
expect(stats.mp5).toEqual(10)
|
||||||
end)
|
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()
|
it("keeps the highest school value", function()
|
||||||
MockItems[4] = {
|
MockItems[4] = {
|
||||||
name = "Mixed School Item",
|
name = "Mixed School Item",
|
||||||
@@ -94,7 +134,7 @@ describe("ScanItemStats", function()
|
|||||||
name = "Resist Item",
|
name = "Resist Item",
|
||||||
stats = {
|
stats = {
|
||||||
["ITEM_MOD_FIRE_RESISTANCE_SHORT"] = 15,
|
["ITEM_MOD_FIRE_RESISTANCE_SHORT"] = 15,
|
||||||
["ITEM_MOD_STRENGTH_SHORT"] = 8,
|
["ITEM_MOD_ARCANE_RESISTANCE_SHORT"] = 8,
|
||||||
["ITEM_MOD_INTELLECT_SHORT"] = 4,
|
["ITEM_MOD_INTELLECT_SHORT"] = 4,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -105,6 +145,63 @@ describe("ScanItemStats", function()
|
|||||||
expect(keyCount).toEqual(1)
|
expect(keyCount).toEqual(1)
|
||||||
end)
|
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()
|
it("returns nil for unknown items", function()
|
||||||
expect(ns.Amibis:ScanItemStats(999999)).toBeNil()
|
expect(ns.Amibis:ScanItemStats(999999)).toBeNil()
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -48,15 +48,30 @@ function IsShiftKeyDown() return false end
|
|||||||
function IsControlKeyDown() return false end
|
function IsControlKeyDown() return false end
|
||||||
|
|
||||||
local function makeChild()
|
local function makeChild()
|
||||||
return setmetatable({}, {
|
local child = { shown = true, text = "" }
|
||||||
__index = function(_, key)
|
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
|
return function(_, ...) return nil end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function makeFrame()
|
local function makeFrame()
|
||||||
local frame = { fonts = {}, textures = {} }
|
local frame = { fonts = {}, textures = {}, shown = true, width = 0, height = 0, scripts = {} }
|
||||||
return setmetatable(frame, {
|
return setmetatable(frame, {
|
||||||
__index = function(self, key)
|
__index = function(self, key)
|
||||||
if key == "CreateFontString" then
|
if key == "CreateFontString" then
|
||||||
@@ -71,6 +86,43 @@ local function makeFrame()
|
|||||||
table.insert(self.textures, tx)
|
table.insert(self.textures, tx)
|
||||||
return tx
|
return tx
|
||||||
end
|
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
|
end
|
||||||
return function(_, ...) return self end
|
return function(_, ...) return self end
|
||||||
end
|
end
|
||||||
@@ -78,11 +130,15 @@ local function makeFrame()
|
|||||||
end
|
end
|
||||||
|
|
||||||
_G.MockFrames = {}
|
_G.MockFrames = {}
|
||||||
function CreateFrame()
|
function CreateFrame(frameType, name, parent, template)
|
||||||
local f = makeFrame()
|
local f = makeFrame()
|
||||||
|
if name then
|
||||||
|
_G[name] = f
|
||||||
|
end
|
||||||
table.insert(_G.MockFrames, f)
|
table.insert(_G.MockFrames, f)
|
||||||
return f
|
return f
|
||||||
end
|
end
|
||||||
|
|
||||||
_G.GameTooltip = makeFrame()
|
_G.GameTooltip = makeFrame()
|
||||||
_G.SlashCmdList = {}
|
_G.SlashCmdList = {}
|
||||||
|
_G.UISpecialFrames = { "GameMenuFrame", "StaticPopup1" }
|
||||||
@@ -52,6 +52,27 @@ local function CreateMainFrame()
|
|||||||
self:StopMovingOrSizing()
|
self:StopMovingOrSizing()
|
||||||
Amibis:SaveFramePosition(self)
|
Amibis:SaveFramePosition(self)
|
||||||
end)
|
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)
|
frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
|
||||||
return frame
|
return frame
|
||||||
@@ -249,9 +270,25 @@ local STAT_LABELS = {
|
|||||||
spellPower = "+Spell Power",
|
spellPower = "+Spell Power",
|
||||||
intellect = "Intellect",
|
intellect = "Intellect",
|
||||||
spirit = "Spirit",
|
spirit = "Spirit",
|
||||||
|
stamina = "Stamina",
|
||||||
mp5 = "MP5",
|
mp5 = "MP5",
|
||||||
haste = "Haste",
|
haste = "Haste",
|
||||||
crit = "Crit",
|
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 = {
|
local STAT_DISPLAY_NAME = {
|
||||||
@@ -260,9 +297,25 @@ local STAT_DISPLAY_NAME = {
|
|||||||
spellPower = "spell power",
|
spellPower = "spell power",
|
||||||
intellect = "intellect",
|
intellect = "intellect",
|
||||||
spirit = "spirit",
|
spirit = "spirit",
|
||||||
|
stamina = "stamina",
|
||||||
mp5 = "mp5",
|
mp5 = "mp5",
|
||||||
haste = "haste",
|
haste = "haste",
|
||||||
crit = "crit",
|
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
|
local STATS_COL_W = 60
|
||||||
@@ -291,7 +344,14 @@ local function FormatUpgradeEntry(idx, upgrade)
|
|||||||
for statKey, diff in pairs(upgrade.statDiffs) do
|
for statKey, diff in pairs(upgrade.statDiffs) do
|
||||||
table.insert(sorted, { key = statKey, diff = diff })
|
table.insert(sorted, { key = statKey, diff = diff })
|
||||||
end
|
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 parts = {}
|
||||||
local maxShow = math.min(2, #sorted)
|
local maxShow = math.min(2, #sorted)
|
||||||
@@ -414,7 +474,7 @@ local function RebuildStatRows(panel, statKeys)
|
|||||||
diff:SetTextColor(1, 1, 1, 1)
|
diff:SetTextColor(1, 1, 1, 1)
|
||||||
|
|
||||||
StatLabels[statKey] = label
|
StatLabels[statKey] = label
|
||||||
StatValues[statKey] = { current = current, bis = bis, diff = diff }
|
StatValues[statKey] = { label = label, current = current, bis = bis, diff = diff }
|
||||||
end
|
end
|
||||||
|
|
||||||
panel:SetHeight(#statKeys * 16 + 24)
|
panel:SetHeight(#statKeys * 16 + 24)
|
||||||
@@ -535,23 +595,44 @@ function ns.UI.Initialize()
|
|||||||
InitializeUI()
|
InitializeUI()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ns.UI.IsShown()
|
||||||
|
return MainFrame ~= nil and MainFrame:IsShown()
|
||||||
|
end
|
||||||
|
|
||||||
function ns.UI.ToggleFrame()
|
function ns.UI.ToggleFrame()
|
||||||
if not MainFrame then
|
if not MainFrame then
|
||||||
InitializeUI()
|
InitializeUI()
|
||||||
end
|
end
|
||||||
|
|
||||||
if MainFrame:IsShown() then
|
if MainFrame:IsShown() then
|
||||||
|
-- Hiding runs the frame's OnHide script, which stops the stats retry timer.
|
||||||
MainFrame:Hide()
|
MainFrame:Hide()
|
||||||
if Amibis._statsRetryTimer then
|
|
||||||
Amibis._statsRetryTimer:Hide()
|
|
||||||
Amibis._statsRetryTimer = nil
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
MainFrame:Show()
|
MainFrame:Show()
|
||||||
|
Amibis._statsRetryAttempts = nil
|
||||||
ns.UI.RefreshUI()
|
ns.UI.RefreshUI()
|
||||||
end
|
end
|
||||||
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()
|
function ns.UI.RefreshUI()
|
||||||
if not MainFrame or not MainFrame:IsShown() then
|
if not MainFrame or not MainFrame:IsShown() then
|
||||||
return
|
return
|
||||||
@@ -590,13 +671,14 @@ function ns.UI.RefreshUI()
|
|||||||
|
|
||||||
if PhaseBar then
|
if PhaseBar then
|
||||||
RebuildPhaseButtons(data.class, data.spec, data.phase)
|
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
|
local targetPhase = data.latestPhase or data.phase
|
||||||
if PhaseProgressFill then
|
if PhaseProgressFill then
|
||||||
PhaseProgressFill:SetWidth(math.max(1, PhaseBar:GetWidth() * ratio))
|
PhaseProgressFill:SetWidth(math.max(1, PhaseBar:GetWidth() * ratio))
|
||||||
end
|
end
|
||||||
if PhaseProgressText then
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -688,22 +770,6 @@ function ns.UI.RefreshUI()
|
|||||||
vals.diff:SetText("")
|
vals.diff:SetText("")
|
||||||
end
|
end
|
||||||
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
|
else
|
||||||
if StatsPanelTitle then
|
if StatsPanelTitle then
|
||||||
StatsPanelTitle:SetText("Stats Comparison")
|
StatsPanelTitle:SetText("Stats Comparison")
|
||||||
@@ -762,6 +828,14 @@ function ns.UI.RefreshUI()
|
|||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
local initFrame = CreateFrame("Frame")
|
local initFrame = CreateFrame("Frame")
|
||||||
|
|||||||
@@ -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
|
- **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
|
- **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
|
- **Upgrade Highlight** — Identifies your biggest available upgrade
|
||||||
- **Persistent Settings** — Window position and spec overrides saved per character
|
- **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
|
- **Shift+Click** a row to link the BIS item in chat
|
||||||
- **Ctrl+Click** a row to open the dress-up preview
|
- **Ctrl+Click** a row to open the dress-up preview
|
||||||
- **Hover** a row to see the item tooltip
|
- **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
|
## 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)
|
- 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"`)
|
- 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
|
## Installation
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user