commit c62c42deaddd1dee5c6aa56dad9091021ef5eadc
parent 322f43006b49ef30d056bde271e9f2a8d9287435
Author: anon <anon@example.com>
Date: Wed, 4 Nov 2026 11:48:42 +0000
Verify original token-board wear gates and complete bonuses
Diffstat:
6 files changed, 504 insertions(+), 4 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -2655,10 +2655,19 @@ client rendering fixes and checks are in [nano damage](docs/nano-damage.md).
replies and SQL failure/ignored-update/commit rollback/retry. GPU WASM
verifies all six real icons; see [token redemption](docs/token-upload.md).
Acquisition and conditional completion XP remain separate P0 work below.
-- [ ] [P1] Verify token-board wear and advancement against the original templates
- using the persistent faction counters. Cover strict token/level/faction gates,
- upgrades, all companion bonuses, removal and cold recovery. Redemption alone
- does not establish board upgrade effects or broader event admission.
+- [x] [P1] Verify original token-board wear using persistent faction counters.
+ All30 original boards now have public wear/remove/re-wear and cold-ownership
+ checks for every companion, strict token/title gates, faction differences and
+ profession OR branches. Two short controlled WASM checks retain exact boards
+ through page replay; six Stats captures show effective HP/nano on wear/remove/re-wear.
+ Raw skills/counters remain unchanged; see [token-board wear](docs/token-boards.md).
+- [ ] [P1] Recover complete original token-board advancement. Establish53064's
+ CLMR/OMAW category selection, replacement identity/destination, full-inventory
+ and worn-use behavior before implementing atomic upgrades. Preserve each
+ authored predicate and Clan basic96358's additional Set53026/stat8/value2.
+ The classic chains terminate atQL8; the14 separate1750-token profession boards
+ have no upgrade Use contract. Redemption and wear do not establish advancement;
+ see [advancement gaps](docs/token-boards.md#advancement-evidence-gaps).
- [x] Retain each accepted mission's concrete population and deaths independently
of corpse lifetime. Acceptance saves NPC identities and selected levels; the
shared killing outcome records each death once with its costs, loot and XP.
diff --git a/docs/token-boards.md b/docs/token-boards.md
@@ -0,0 +1,89 @@
+# Original token-board wear
+
+The original14.9.1 resources contain16 classic board definitions at exact QL1..8
+and14 separate1750-token profession boards at fixedQL1. All30 complete OnWear
+contracts use the shared equipment consumers, including defense277. This does
+not implement board advancement or establish acquisition of the1750 boards.
+The AddAllDef admission change enables22 of these records; their original
+requirement combinations need coverage beyond the scalar modifier census.
+
+The independent [wear fixture](../server/testdata/token-board-wear.json) retains
+each original template, quality, action6 requirement expression and complete
+OnWear modifier list. Full payload reparses, hashes, application-form callers
+and the bounded category-code census are retained in `local/token-board-research/`.
+
+## Authored wear requirements
+
+Wear uses action6, including its postfix AND/OR operators and strict comparisons.
+Action136 is a separate contract: it omits title/profession gates on many boards,
+and some1750 boards use tokens equal1749 there instead of greater1749. It cannot
+replace action6 when deciding whether a character may wear the item.
+
+Basic96358/99719 contain no action6 faction/token gate and no bonuses. Both can
+be worn by another faction or a neutral under these original contracts.
+Higher tiers require their own faction and its persistent token counter.
+Clan96352/QL3 requires ClanTokens>29 without a title predicate; Omni99721/QL3
+also requires TitleLevel>1. The regression preserves this asymmetry instead of
+adding the Omni title gate to the Clan record.
+
+ClassicQL8 ends at96357/99726, requiring1000 tokens and TitleLevel>3. Its full
+bonuses include950 HP,950 nano,45 offense,60 defense, all authored damage types,
+the210/140 skill companions and XPModifier319+7. There is no inferred QL interpolation.
+
+All14 separate1750 boards require their own side, tokens>1749 and TitleLevel>5.
+Their professions are authored alternatives, not a shared profession filter:
+
+| Clan template | Omni template | Allowed profession IDs |
+| --- | --- | --- |
+|216284|216285|9|
+|216303|216302|11 or10|
+|216323|216325|8 or12|
+|216363|216364|4 or6|
+|216366|216367|1 or5|
+|216369|216368|3 or7|
+|216370|216371|2|
+
+Each complete bonus list remains distinct; neither matching board names nor
+equal token thresholds justify replacing those lists with one generic profile.
+
+## Verification
+
+Public inventory tests wear, remove and re-wear all30 boards, comparing every
+companion, raw skills, both token counters, exact item identity/quality/slot,
+allocation and cold ownership. Separate cases cover neutral/opposite factions,
+token equality and first eligible count, title boundaries, both profession OR
+branches and an excluded profession. Refusal must leave the item store unchanged
+and restore the carried source.
+The focused Go run passes2 roots/236 results in41.730 seconds; the matching race
+run passes the same236 results in133.940 seconds. Vet and driver syntax pass.
+
+Native verification uses controlled fixtures rather than earned tokens or levels.
+Board right-click invokes Use; actual wear/removal must use pickup and placement
+in the neck/inventory cells. Two15.85/15.79-second WASM checks retain exact board
+identities/counters through wear/remove/re-wear, page replay and cold Go loading.
+The ClanQL3 case succeeds at level1 with30 tokens; the Omni1750 case uses an
+eligible level190 Engineer. Six inspected Stats captures agree with server maxima:
+Clan HP97 ->37 ->97/nano75 ->35 ->75, Omni HP2621 ->1171 ->2621/nano3191 ->1741 ->3191.
+The native raw foundation array remains unchanged because direct wear modifiers
+are stored separately. No direct numeric native defense measurement is claimed.
+Captures are in `local/token-board-wear/20261104-033959/96352/` and
+`local/token-board-wear/20261104-034015/216368/`. Advancement remains separate.
+
+## Advancement evidence gaps
+
+Classic next-tier functions53064 contain category `CLMR` or `OMAW` and requested
+QL2..8, followed by conditional current-use-item deletion53130. Their exact
+per-function gates differ between factions. The QL8 records have no next-tier
+create/delete, and none of the1750 boards has an upgrade Use contract.
+
+Original client53130 resolves the saved current-use page/slot through100c2810,
+10061bc0 and DeleteItem1005f270, then clears that reference. Function53064 is
+gated out of the client effect executor. This does not recover authoritative
+category membership, replacement identity/destination or full-inventory and
+worn-use policies. Clan basic96358 also contains conditional Set53026 with
+prefix03000000/stat8/value2; it must not be silently omitted.
+
+The raw-code search found stock-category references, but no verified category
+membership map. Adjacent names, next-tier prose and matching qualities remain
+candidate mappings. Complete advancement requires those missing server rules
+and atomic source/replacement ownership before any success response.
diff --git a/server/browser_token_board_wear_test.go b/server/browser_token_board_wear_test.go
@@ -0,0 +1,101 @@
+package main
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestBrowserTokenBoardWear(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for token-board wear")
+ }
+ for _, template := range []uint32{96352, 216368} {
+ t.Run(fmt.Sprint(template), func(t *testing.T) {
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/token-board-wear", time.Now().Format("20060102-150405"), fmt.Sprint(template))
+ var fixture tokenBoardWearFixture
+ for _, board := range tokenBoardWearFixtures(t) {
+ if board.Template == template {
+ fixture = board
+ }
+ }
+ world := newTestServer(t)
+ player := world.newCharacter()
+ player.level, player.profession, player.stats = 190, 3, testCharacterStats()
+ appearance := unpackAppearance(player.appearance)
+ appearance.Side = fixture.Side
+ player.appearance = appearance.packed()
+ inventory := playerInventory{LastID: 1, ClanTokens: 1750, OmniTokens: 1750, Items: []ownedItem{
+ {ID: 1, Type: 51022, Template: template, Quality: fixture.Quality, Slot: 64, Count: 1}}}
+ if template == 96352 {
+ player.level = 1
+ inventory.ClanTokens = 30
+ }
+ player.playfield, player.position = 1183, [3]float32{193.79826, 5.01, 136.83983}
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("token-board-wear")))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ mux := http.NewServeMux()
+ mux.Handle("/", world.httpHandler())
+ mux.HandleFunc("GET /test-state", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ json.NewEncoder(w).Encode(struct {
+ Inventory playerInventory
+ Maximum [2]uint32
+ }{player.inventory, [2]uint32{player.maximumHealth(), player.maximumNano()}})
+ })
+ host := httptest.NewServer(mux)
+ t.Cleanup(host.Close)
+ closeTestBrowserStreams(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
+ defer cancel()
+ ticker := time.NewTicker(20 * time.Millisecond)
+ defer ticker.Stop()
+ stopped := make(chan struct{})
+ go func() {
+ defer close(stopped)
+ for {
+ select {
+ case now := <-ticker.C:
+ world.advanceEquipment(now)
+ case <-ctx.Done():
+ return
+ }
+ }
+ }()
+ defer func() { cancel(); <-stopped }()
+
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_token_board_wear.mjs"), host.URL, output)
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+
+ t.Logf("Browser artifacts: %s", output)
+ if err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t).characters[1]
+ if !slices.Equal(player.inventory.Items, cold.inventory.Items) ||
+ !slices.Equal(cold.inventory.Items, []ownedItem{{ID: 1, Type: 51022, Template: template, Quality: fixture.Quality, Slot: 17, Count: 1}}) ||
+ cold.inventory.ClanTokens != player.inventory.ClanTokens || cold.inventory.OmniTokens != player.inventory.OmniTokens || world.nextItem != 1 {
+ t.Fatal("native board wear changed cold ownership, counters or allocation")
+ }
+ })
+ }
+}
diff --git a/server/testdata/token-board-wear.json b/server/testdata/token-board-wear.json
@@ -0,0 +1,32 @@
+[
+ {"template":96351,"quality":2,"side":1,"name":"Clan Merits - Twig of Hope","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":9,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,30]]},
+ {"template":96352,"quality":3,"side":1,"name":"Clan Merits - Leaves of Spring","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":29,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,60],[221,40]]},
+ {"template":96353,"quality":4,"side":1,"name":"Clan Merits - Blossoms of Summer","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":59,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":1,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,200],[221,150],[319,1]]},
+ {"template":96354,"quality":5,"side":1,"name":"Clan Merits - Late Night","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":119,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":2,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,350],[221,300],[277,10],[319,3]]},
+ {"template":96355,"quality":6,"side":1,"name":"Clan Merits - Dawn","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":249,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":2,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,450],[221,400],[276,10],[277,20],[319,4]]},
+ {"template":96356,"quality":7,"side":1,"name":"Clan Merits - Sunrise","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":399,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":3,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,500],[221,500],[276,25],[277,35],[278,10],[279,10],[280,10],[281,10],[282,10],[311,10],[316,10],[317,10],[319,6]]},
+ {"template":96357,"quality":8,"side":1,"name":"Clan Merits - Double Sun","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":999,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":3,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,950],[156,210],[160,210],[161,210],[164,140],[221,950],[276,45],[277,60],[278,20],[279,20],[280,20],[281,20],[282,20],[311,20],[316,20],[317,20],[319,7]]},
+ {"template":96358,"quality":1,"side":1,"name":"Clan Merits - Basic Board","requirements":[],"modifiers":[]},
+ {"template":99719,"quality":1,"side":2,"name":"Omni-Tek Award - Basic Board","requirements":[],"modifiers":[]},
+ {"template":99720,"quality":2,"side":2,"name":"Omni-Tek Award - Ribbon of Strife","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":9,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,30]]},
+ {"template":99721,"quality":3,"side":2,"name":"Omni-Tek Award - Double Ribbons of Skirmish","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":29,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":1,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,60],[221,40]]},
+ {"template":99722,"quality":4,"side":2,"name":"Omni-Tek Award - Triple Ribbons of Battle","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":59,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":1,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,200],[221,150],[319,1]]},
+ {"template":99723,"quality":5,"side":2,"name":"Omni-Tek Award - Flag of Sacrifice","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":119,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":2,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,350],[221,300],[277,10],[319,3]]},
+ {"template":99724,"quality":6,"side":2,"name":"Omni-Tek Award - Double Flags of Righteousness","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":249,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":2,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,450],[221,400],[276,10],[277,20],[319,4]]},
+ {"template":99725,"quality":7,"side":2,"name":"Omni-Tek Award - Triple Flag of Humility","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":399,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":3,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,500],[221,500],[276,25],[277,35],[278,10],[279,10],[280,10],[281,10],[282,10],[311,10],[316,10],[317,10],[319,6]]},
+ {"template":99726,"quality":8,"side":2,"name":"Omni-Tek Award - Flags of Glory and Redemption","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":999,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":3,"operator":2},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,950],[156,210],[160,210],[161,210],[164,140],[221,950],[276,45],[277,60],[278,20],[279,20],[280,20],[281,20],[282,20],[311,20],[316,20],[317,20],[319,7]]},
+ {"template":216284,"quality":1,"side":1,"name":"Beefeater's Merit Board","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":9,"operator":0},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1900],[156,210],[160,210],[161,210],[164,140],[221,950],[276,40],[277,65],[279,25],[280,25],[281,25],[282,25],[311,25],[316,25],[317,25],[319,7]]},
+ {"template":216285,"quality":1,"side":2,"name":"Captain Lotto's Merit Board","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":9,"operator":0},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1900],[156,210],[160,210],[161,210],[164,140],[221,950],[276,40],[277,65],[279,25],[280,25],[281,25],[282,25],[311,25],[316,25],[317,25],[319,7]]},
+ {"template":216302,"quality":1,"side":2,"name":"Omni-Tek Nano Reservoire Merit Board","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":11,"operator":0},{"stat":60,"value":10,"operator":0},{"stat":0,"value":0,"operator":3},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,950],[156,210],[160,210],[161,210],[164,140],[221,1900],[276,50],[277,55],[280,25],[281,25],[282,25],[311,25],[316,25],[317,25],[319,7]]},
+ {"template":216303,"quality":1,"side":1,"name":"Merit Board of the Angry Men","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":11,"operator":0},{"stat":60,"value":10,"operator":0},{"stat":0,"value":0,"operator":3},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,950],[156,210],[160,210],[161,210],[164,140],[221,1900],[276,50],[277,55],[280,25],[281,25],[282,25],[311,25],[316,25],[317,25],[319,7]]},
+ {"template":216323,"quality":1,"side":1,"name":"Standard Clan Leader Merit Board","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":8,"operator":0},{"stat":60,"value":12,"operator":0},{"stat":0,"value":0,"operator":3},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1400],[156,210],[160,210],[161,210],[164,140],[221,1600],[276,45],[277,60],[279,20],[278,20],[280,20],[281,20],[282,20],[311,20],[316,20],[317,20],[319,8]]},
+ {"template":216325,"quality":1,"side":2,"name":"Technocrat Merit Board","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":8,"operator":0},{"stat":60,"value":12,"operator":0},{"stat":0,"value":0,"operator":3},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1400],[156,210],[160,210],[161,210],[164,140],[221,1600],[276,45],[277,60],[279,20],[278,20],[280,20],[281,20],[282,20],[311,20],[316,20],[317,20],[319,8]]},
+ {"template":216363,"quality":1,"side":1,"name":"Merit Board of the Long Distance Runner","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":4,"operator":0},{"stat":60,"value":6,"operator":0},{"stat":0,"value":0,"operator":3},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1450],[156,260],[160,210],[161,210],[164,140],[221,1450],[276,45],[277,60],[279,20],[278,20],[280,25],[281,25],[282,25],[311,25],[316,25],[317,25],[319,7]]},
+ {"template":216364,"quality":1,"side":2,"name":"Messenger Merit Board","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":4,"operator":0},{"stat":60,"value":6,"operator":0},{"stat":0,"value":0,"operator":3},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1450],[156,260],[160,210],[161,210],[164,140],[221,1450],[276,45],[277,60],[279,20],[278,20],[280,25],[281,25],[282,25],[311,25],[316,25],[317,25],[319,7]]},
+ {"template":216366,"quality":1,"side":1,"name":"Front Fighter Merit Board","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":1,"operator":0},{"stat":60,"value":5,"operator":0},{"stat":0,"value":0,"operator":3},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1600],[156,210],[160,210],[161,210],[164,140],[221,1300],[276,55],[277,50],[278,30],[280,30],[281,25],[282,25],[311,25],[316,25],[317,25],[319,7]]},
+ {"template":216367,"quality":1,"side":2,"name":"Omni-Tek Shock Trooper Merit Board","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":1,"operator":0},{"stat":60,"value":5,"operator":0},{"stat":0,"value":0,"operator":3},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1600],[156,210],[160,210],[161,210],[164,140],[221,1300],[276,55],[277,50],[278,30],[280,30],[281,25],[282,25],[311,25],[316,25],[317,25],[319,7]]},
+ {"template":216368,"quality":1,"side":2,"name":"Omni-Tek Engineer Corps Merit Board","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":3,"operator":0},{"stat":60,"value":7,"operator":0},{"stat":0,"value":0,"operator":3},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1450],[156,210],[160,235],[161,235],[164,140],[221,1450],[276,35],[277,70],[279,20],[278,20],[280,20],[281,20],[282,20],[311,20],[316,20],[317,20],[319,7]]},
+ {"template":216369,"quality":1,"side":1,"name":"Merit Board of the Blue Wolf","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":3,"operator":0},{"stat":60,"value":7,"operator":0},{"stat":0,"value":0,"operator":3},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1450],[156,210],[160,235],[161,235],[164,140],[221,1450],[276,35],[277,70],[279,20],[278,20],[280,20],[281,20],[282,20],[311,20],[316,20],[317,20],[319,7]]},
+ {"template":216370,"quality":1,"side":1,"name":"Merit Board of the Rainbow Chrysanthemum","requirements":[{"stat":33,"value":1,"operator":0},{"stat":62,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":2,"operator":0},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1600],[156,210],[160,210],[161,210],[164,140],[221,1200],[276,70],[277,40],[279,30],[278,20],[280,20],[281,20],[282,20],[311,20],[316,20],[317,20],[319,7]]},
+ {"template":216371,"quality":1,"side":2,"name":"Metal Fungus Merit Board","requirements":[{"stat":33,"value":2,"operator":0},{"stat":75,"value":1749,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":37,"value":5,"operator":2},{"stat":0,"value":0,"operator":4},{"stat":60,"value":2,"operator":0},{"stat":0,"value":0,"operator":4}],"modifiers":[[1,1600],[156,210],[160,210],[161,210],[164,140],[221,1200],[276,70],[277,40],[279,30],[278,20],[280,20],[281,20],[282,20],[311,20],[316,20],[317,20],[319,7]]}
+]
diff --git a/server/token_board_wear_test.go b/server/token_board_wear_test.go
@@ -0,0 +1,190 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "bytes"
+ _ "embed"
+ "encoding/json"
+ "fmt"
+ "slices"
+ "testing"
+)
+
+//go:embed testdata/token-board-wear.json
+var tokenBoardWearData []byte
+
+type tokenBoardWearFixture struct {
+ Template, Quality uint32
+ Side uint16
+ Name string
+ Requirements []gamedata.ItemRequirement
+ Modifiers [][2]int32
+}
+
+func tokenBoardWearFixtures(t *testing.T) []tokenBoardWearFixture {
+ t.Helper()
+ var fixtures []tokenBoardWearFixture
+ if err := json.Unmarshal(tokenBoardWearData, &fixtures); err != nil {
+ t.Fatal(err)
+ }
+ if len(fixtures) != 30 {
+ t.Fatal("original token-board census changed", len(fixtures))
+ }
+ return fixtures
+}
+
+func newTokenBoardWearWorld(t *testing.T, fixture tokenBoardWearFixture) (*server, *combatTestConn) {
+ t.Helper()
+ world, conn := newEquipmentWorld(t)
+ player := world.characters[1]
+ player.level = 190
+ appearance := unpackAppearance(player.appearance)
+ appearance.Side = fixture.Side
+ player.appearance = appearance.packed()
+ for _, requirement := range fixture.Requirements {
+ if requirement.Stat == 60 {
+ player.profession = uint16(requirement.Value)
+ break
+ }
+ }
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ inventory := playerInventory{LastID: 1, ClanTokens: 1750, OmniTokens: 1750, Items: []ownedItem{
+ {ID: 1, Type: 51022, Template: fixture.Template, Quality: fixture.Quality, Slot: 64, Count: 1}}}
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ return world, conn
+}
+
+func TestTokenBoardsWearRemoveAndRestoreEveryOriginalCompanion(t *testing.T) {
+ for _, fixture := range tokenBoardWearFixtures(t) {
+ t.Run(fmt.Sprint(fixture.Template), func(t *testing.T) {
+ world, _ := newTokenBoardWearWorld(t, fixture)
+ player, client := world.characters[1], world.clients[1]
+ before := player.stats
+ definition := gamedata.ItemTemplates[fixture.Template]
+ var requirements []gamedata.ItemRequirement
+ var modifiers [][2]int32
+ for _, section := range definition.Sections {
+ if section.Actions != nil {
+ for _, action := range *section.Actions {
+ if action.Type == 6 {
+ requirements = action.Requirements
+ }
+ }
+ }
+ if section.Type == 2 && section.Subtype == 14 {
+ for _, function := range *section.Functions {
+ if function.ID == 53045 {
+ modifiers = append(modifiers, [2]int32{*function.Arguments[0].Integer, *function.Arguments[1].Integer})
+ }
+ }
+ }
+ }
+ if !slices.Equal(requirements, fixture.Requirements) || !slices.Equal(modifiers, fixture.Modifiers) {
+ t.Fatal("board wear differs from the independently reparsed original contract")
+ }
+
+ for _, move := range [][2]uint32{{64, 17}, {17, 64}, {64, 17}} {
+ if err := world.handleInventory(client, itemMovePacket(1, move[0], move[1])[20:]); err != nil || client.equipment == nil {
+ t.Fatal("qualified board wear/removal was refused", move, err)
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ cold := newTestInventoryServer(t).characters[1]
+
+ if player.stats != before || cold.stats != before || !slices.Equal(player.inventory.Items, cold.inventory.Items) ||
+ !slices.Equal(player.inventory.Items, []ownedItem{{ID: 1, Type: 51022, Template: fixture.Template, Quality: fixture.Quality, Slot: move[1], Count: 1}}) ||
+ player.inventory.ClanTokens != 1750 || player.inventory.OmniTokens != 1750 || cold.inventory.ClanTokens != 1750 || cold.inventory.OmniTokens != 1750 ||
+ world.nextItem != 1 || cold.inventory.LastID != 1 {
+ t.Fatal("board wear changed raw skills, tokens, identity or cold ownership")
+ }
+ for _, modifier := range fixture.Modifiers {
+ expected := modifier[1]
+ if move[1] == 64 {
+ expected = 0
+ }
+ if player.equipmentBonus(uint32(modifier[0])) != expected || cold.equipmentBonus(uint32(modifier[0])) != expected {
+ t.Fatal("board companion did not apply/remove exactly once", modifier, move)
+ }
+ }
+ }
+ })
+ }
+}
+
+func TestTokenBoardWearPreservesEveryOriginalRequirement(t *testing.T) {
+ type wearCase struct {
+ stat, value int32
+ accepted bool
+ }
+ for _, fixture := range tokenBoardWearFixtures(t) {
+ scenarios := []wearCase{{33, 0, len(fixture.Requirements) == 0}, {33, int32(3 - fixture.Side), len(fixture.Requirements) == 0}}
+ profession := int32(0)
+ for _, requirement := range fixture.Requirements {
+ switch requirement.Stat {
+ case 62, 75:
+ scenarios = append(scenarios, wearCase{requirement.Stat, requirement.Value, false}, wearCase{requirement.Stat, requirement.Value + 1, true})
+ case 37:
+ level := map[int32]int32{1: 14, 2: 49, 3: 99, 5: 189}[requirement.Value]
+ scenarios = append(scenarios, wearCase{37, level, false}, wearCase{37, level + 1, true})
+ case 60:
+ scenarios = append(scenarios, wearCase{60, requirement.Value, true})
+ profession = 9
+ if requirement.Value == 9 {
+ profession = 1
+ }
+ }
+ }
+ if profession != 0 {
+ scenarios = append(scenarios, wearCase{60, profession, false})
+ }
+ for _, scenario := range scenarios {
+ t.Run(fmt.Sprintf("%d/stat%d=%d", fixture.Template, scenario.stat, scenario.value), func(t *testing.T) {
+ world, conn := newTokenBoardWearWorld(t, fixture)
+ player, client := world.characters[1], world.clients[1]
+ switch scenario.stat {
+ case 33:
+ appearance := unpackAppearance(player.appearance)
+ appearance.Side = uint16(scenario.value)
+ player.appearance = appearance.packed()
+ case 62:
+ player.inventory.ClanTokens = uint32(scenario.value)
+ case 75:
+ player.inventory.OmniTokens = uint32(scenario.value)
+ case 37:
+ player.level = uint16(scenario.value)
+ case 60:
+ player.profession = uint16(scenario.value)
+ }
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if err := world.handleInventory(client, inventoryMovePacket(1, 64, 17)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if scenario.accepted {
+ if client.equipment == nil {
+ t.Fatal("authored faction/profession alternative was rejected")
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ }
+ after, err := readTestItemStore(world)
+
+ if err != nil || !scenario.accepted && (client.equipment != nil || !bytes.Equal(before, after) || len(conn.packets) != 2) ||
+ (player.inventory.Items[0].Slot == 17) != scenario.accepted {
+ t.Fatal("original wear requirement or refusal ownership changed", scenario.accepted, err)
+ }
+ })
+ }
+ }
+}
diff --git a/tools/client/test_token_board_wear.mjs b/tools/client/test_token_board_wear.mjs
@@ -0,0 +1,79 @@
+import assert from 'node:assert/strict';
+import fs from 'node:fs/promises';
+import {createRequire} from 'node:module';
+import {GameTest} from './game_test.mjs';
+
+const {chromium} = createRequire(import.meta.url)('playwright');
+const [url, output] = process.argv.slice(2);
+const browser = await chromium.launch({executablePath: '/usr/bin/chromium', args: [
+ '--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+let game;
+const evidence = {};
+try {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: 'token-board-wear', url}]);
+ const page = await context.newPage();
+ game = await GameTest.attach(page);
+ const server = async () => (await page.request.get(url + '/test-state')).json();
+ const carried = state => state.grids.flatMap(grid => grid.cells).find(cell =>
+ cell.identity[0] === 104 && cell.identity[1] === 48 && !cell.dummy);
+ await page.goto(url);
+ await game.ready();
+ await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
+ await game.snapshot();
+ await game.key('i');
+ await page.keyboard.press('Control+1');
+ await game.click(953, 53);
+ await game.snapshot();
+ evidence.before = await server();
+ evidence.foundations = [game.local().stats[1], game.local().stats[221]];
+ assert.deepEqual([game.local().stats[62], game.local().stats[75]],
+ [evidence.before.Inventory.ClanTokens, evidence.before.Inventory.OmniTokens]);
+
+ for (const slot of [17, 64, 17]) {
+ const sequence = game.sequence;
+ if (slot === 17) {
+ const cell = carried(game.state);
+ assert(cell, 'the original board source must remain usable');
+ await game.click((cell.bounds[0] + cell.bounds[2]) / 2, (cell.bounds[1] + cell.bounds[3]) / 2);
+ await game.wait('carried board picked', state => state.dragged[0] === 104 && state.dragged[1] === 48);
+ await game.click(867, 94);
+ } else {
+ await game.click(867, 94);
+ await game.wait('worn board picked', state => state.dragged[0] === 102 && state.dragged[1] === 17);
+ const cell = game.state.grids.find(grid => grid.totalCells === 30).cells.find(cell => cell.identity[0] === 0);
+ await game.click((cell.bounds[0] + cell.bounds[2]) / 2, (cell.bounds[1] + cell.bounds[3]) / 2);
+ }
+ await game.wait('actual board wear/removal request', () => game.events.some(event =>
+ event.sequence > sequence && event.direction === 'framesent' && event.opcode === '47537a24'));
+ await game.wait('board placement completes', state => game.local(state).inventory.some(item => item.id === 1 && item.slot === (slot === 64 ? 48 : 17)));
+ const state = await server();
+ assert.deepEqual(state.Inventory.Items.map(item => [item.ID, item.Template, item.Quality, item.Slot]),
+ [[1, evidence.before.Inventory.Items[0].Template, evidence.before.Inventory.Items[0].Quality, slot]]);
+ assert.deepEqual([state.Inventory.ClanTokens, state.Inventory.OmniTokens],
+ [evidence.before.Inventory.ClanTokens, evidence.before.Inventory.OmniTokens]);
+ assert.deepEqual([game.local().stats[1], game.local().stats[221]], evidence.foundations);
+ evidence[slot === 64 ? 'removed' : evidence.worn ? 'reworn' : 'worn'] = state;
+ await page.keyboard.press('Control+9');
+ const statsOpen = current => current.regions.some(([left, top, right, bottom]) =>
+ left === 832 && top === 380 && right === 1024 && bottom === 606);
+ await game.wait('native Stats panel opens', statsOpen);
+ await game.save(output + '/' + (slot === 64 ? 'removed' : evidence.reworn ? 'reworn' : 'worn'));
+ await page.keyboard.press('Control+9');
+ await game.wait('native Stats panel closes', current => !statsOpen(current));
+ }
+
+ await page.reload();
+ await game.ready();
+ assert.deepEqual(game.local().inventory.map(item => [item.id, item.slot]), [[1, 17]]);
+ assert.deepEqual([game.local().stats[1], game.local().stats[221]], evidence.foundations);
+ assert.equal(game.errors.length, 0);
+ console.log('PASS: exact token-board wear/remove/rewear, raw foundations, counters and page/cold ownership');
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ if (game) await game.save(output + '/final');
+ } finally { await browser.close(); }
+}