Files
amibis/AGENTS.md
T
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

46 lines
4.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Amibis — WoW TBC Classic Addon
## What it is
World of Warcraft addon (TBC Classic, Interface 20505) that compares the player's equipped gear against Best-in-Slot lists sourced from wowtbc.gg.
## Project structure
```
Amibis/
├── Amibis.toc # Addon manifest — defines load order
├── Amibis.lua # Core: DB init, item scanning, stat aggregation, gear comparison, slash commands
├── Data/
│ └── BISLists.lua # BIS data store (class → spec → phase → slot)
├── UI/
│ └── ComparisonFrame.lua # Main UI frame, slot rows, stats panel, phase selector bar
└── Tests/ # Offline test suite (NOT in .toc — dev machine only)
├── run.lua # Entry point: lua5.4 Amibis/Tests/run.lua
├── harness.lua # describe/it/expect micro-framework
├── wow_mocks.lua # WoW API stubs + scriptable item fixtures
├── test_*.lua # Suites: data integrity, stat scanning, gear comparison
└── README.md # Coverage, layout, how to add tests
```
## Key facts
- **Load order** is defined in `Amibis.toc`: `Amibis.lua` → `Data/BISLists.lua` → `UI/ComparisonFrame.lua`
- **Slash command**: `/amibis` toggles the UI; `/amibis spec <SpecName>` overrides auto-detected spec; `/amibis spec clear` resets override. 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), 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", "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 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.
- 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.