commit a8b44db989338a93829b41878396430af0e9c1ed
parent d6f8a63f617be66f91dc517bc7f46a414219e2bf
Author: anon <anon@example.com>
Date: Mon, 2 Nov 2026 20:48:06 +0000
Admit reviewed Steel-Ribbed armor quality families
Diffstat:
8 files changed, 666 insertions(+), 0 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -364,6 +364,12 @@ unverified mass/deletion/reclaim policies are in [backpacks](docs/backpacks.md).
one energy shot, rejected QL125 wear, exactly-once LIZARD effects and fresh-server
recovery. Fixed QL180 DRAGON stays separate; historical acquisition remains open.
See [Vektor contracts](docs/vektor-shotguns.md).
+ Six regular Steel-Ribbed pairs now use the shared QL1..200 path after complete
+ original descriptor audits, fixing qualified selected-quality wear rejection.
+ Public-handler and short two-client WASM checks cover strict Sense/Agility
+ gates, AC/value, native endpoints, pickup, wear/removal, sale and cold ownership.
+ Acquisition remains open; see
+ [Steel-Ribbed contracts](docs/steel-ribbed-armor.md).
- [x] Admit the complete Low-Tech armor set through shared quality and shop data.
Eight explicit original pairs cover QL1..200, including alternate body and leg
styles and independent sleeves. All three basic armor factions offer the
diff --git a/docs/steel-ribbed-armor.md b/docs/steel-ribbed-armor.md
@@ -0,0 +1,89 @@
+# Regular Steel-Ribbed armor qualities
+
+Six reviewed regular Steel-Ribbed pairs use the shared QL1..200 equipment path.
+Previously a qualified QL2 or QL20 glove was rejected despite both original
+endpoint records being present. The fix adds only explicit family data; selected
+requirements, AC, value and native endpoints use the existing shared consumers.
+
+## Original contracts
+
+All twelve complete resource 1000020 records were reparsed from the shipped
+14.9.1 database and compared field-for-field with the extracted catalog. The
+index SHA-256 is
+`46e5dc54af9358cc9bff05f4358e86af630e497bc677f361c133c88073b84d71`.
+Raw payloads, individual hashes, full decoded records and comparisons are in
+`local/steel-ribbed-armor/original/`.
+
+| Piece | QL1 / QL200 templates | Native slot | QL2 base value |
+| --- | --- | --- | ---: |
+| Pants | 85494 / 22347 | 27 | 927 |
+| Helmet | 85541 / 22262 | 18 | 1113 |
+| Gloves | 85580 / 22212 | 24 | 370 |
+| Boots | 85620 / 22158 | 30 | 556 |
+| Body armor | 85668 / 22080 | 21 | 1484 |
+| Sleeves | 85724 / 21971 | 23 or 25 | 370 |
+
+Each pair has the same complete appearance/effect contract. Only scalar stats
+1/2/54/74, eight Modify 53045 AC amounts and two wear thresholds differ. Text
+lengths account for section-offset changes. No extra or opaque effect is dropped.
+Names selected candidates for inspection; the full descriptors establish pairing.
+Handy Steelribbed, Nadir, Obtru and Omni-Tek variants are separate contracts.
+
+Sense (20) and Agility (17) must be strictly greater than 8/8 at QL1 and
+530/480 at QL200. Shared rounding gives QL2 thresholds 11/10, QL20 thresholds
+58/53, QL100 thresholds 268/243 and QL101 thresholds 270/245. The existing
+quadratic value path gives QL100 gloves a base value of 85,657 credits; the
+stored QL200 glove value is 344,999. Exact endpoint qualities send one endpoint
+twice; intermediate qualities retain the low/high pair, regardless of the stored anchor.
+
+The local Fandom mirror page 3315, touched 2007-12-23, agrees with the full QL200
+set's AC totals. Its later craft reference does not establish acquisition in
+14.9.1. The [January 2008 Hahnsoo guide](https://gamefaqs.gamespot.com/pc/913777-anarchy-online/faqs/46197)
+lists ordinary Steel-Ribbed under Sense/Agility armor, while discussing
+Nadir, Obtru and the sided upgrade separately. Neither that classification nor
+the client interpolation anchors establish a period loot pool, minimum obtainable
+QL or shop selection rule. Bounded searches did not recover such a rule.
+Production stock, mission rewards and drop membership remain unchanged.
+
+## Verification
+
+Public inventory-handler tests cover all six pairs, both stored anchors,
+QL1/2/20/100/200, glove101/199 boundaries and independent sleeve slots. They
+exercise strict equality refusals, qualified delayed wear, native low/high
+serialization, all eight ACs, selected price, removal and cold ownership. A
+controlled generated glove follows normal kill/loot/pickup handlers and retains
+its exact selected quality through repeated pickup, cold replay and wear/removal.
+Sale checks cover cancellation, acceptance and duplicate acceptance. Quality
+range tests reject extrapolation and keep the Handy variant exact.
+
+`TestBrowserSteelRibbedArmorQualities` supplies ten controlled instances before
+two native clients connect. Real browser input removes and re-wears each of the
+seven worn pieces, explicitly keeps the sleeves in different arms, wears a
+QL100 glove stored at the high endpoint and rejects QL101 at the strict
+thresholds. Native ability training raises Sense 270 -> 271 and Agility 245 -> 246
+for 1,030 IP, then the same QL101 glove wears. QL200 remains rejected and owned.
+
+The QL100 glove's native basic-armor sale is 5,139 credits at the fixture's
+Computer Literacy 6. Cancellation retains it; acceptance leaves 5,239 credits and
+all nine other identities. Final AC totals are 156/138/156/156/35/35/138/35.
+Page replay and two fresh WASM clients after the warm server closes must retain
+the exact IDs, endpoints, slots, qualities, trained abilities and wallet.
+These are controlled item-contract checks, not earned acquisition or progression.
+Test sessions drain before SQLite closes, including on failures.
+
+The final native check passes in 77.12 seconds: 46.26 seconds for the warm/page
+phase and 28.27 seconds for cold clients. The sale screenshot shows 5,139 and
+the native Stats form shows projectile/melee/energy AC 156/138/156. The focused
+normal server/game-data checks pass in 18.281/7.710 seconds; the expanded race
+selection passes in 111.658/102.922 seconds. The published WASM is unchanged.
+Artifacts are in `local/steel-ribbed-armor/20261102-124309/`; the independent
+verifier checks all twelve original hashes and the exact page/cold item ledgers.
+
+```sh
+go test ./server ./server/gamedata -run '^Test(SteelRibbed|ReviewedItemFamily|UnreviewedItemQuality)' -count=1
+AO_GAME_TEST=1 go test ./server -run '^TestBrowserSteelRibbedArmorQualities$' -count=1 -timeout=9m -v
+```
+
+Original-resource audits, literal expectations, failed/passing regressions,
+native traces, screenshots and durable comparisons are retained under
+`local/steel-ribbed-armor/`.
diff --git a/server/browser_steel_ribbed_test.go b/server/browser_steel_ribbed_test.go
@@ -0,0 +1,141 @@
+package main
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "reflect"
+ "runtime"
+ "testing"
+ "time"
+)
+
+func TestBrowserSteelRibbedArmorQualities(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for the focused native Steel-Ribbed check")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/steel-ribbed-armor", time.Now().Format("20060102-150405"))
+ t.Chdir(t.TempDir())
+ world := newServer()
+ t.Cleanup(func() { world.db.Close() })
+ owner := world.newCharacter()
+ owner.name, owner.level, owner.appearance = "Steelowner", 100, 0x515
+ owner.playfield, owner.position = 1183, [3]float32{188, 5.11, 139.5}
+ owner.rotation = [4]float32{0, 0.70710677, 0, 0.70710677}
+ owner.stats.Abilities.Sense, owner.stats.Abilities.Agility = 270, 245
+ owner.stats.ImprovementPoints, owner.inventory.Credits = 2000, 100
+ owner.health, owner.nano = owner.maximumHealth(), owner.maximumNano()
+ owner.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("steel-owner")))
+ watcher := world.newCharacter()
+ watcher.name, watcher.playfield, watcher.position = "Steelwatch", 1183, [3]float32{186, 5.11, 134.5}
+ watcher.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("steel-watch")))
+ for _, player := range []*character{owner, watcher} {
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ }
+ // Controlled contracts isolate selected qualities without earning levels or gear.
+ for _, item := range []struct{ template, quality, slot uint32 }{
+ {85541, 2, 18}, {85494, 2, 27}, {85620, 2, 30},
+ {85724, 2, 23}, {85724, 2, 25}, {85580, 2, 24}, {85668, 2, 21},
+ {22212, 100, 64}, {85580, 101, 65}, {85580, 200, 66},
+ } {
+ if granted, err := world.grantItem_locked(owner, item.template); err != nil || !granted {
+ t.Fatal(granted, err)
+ }
+ owner.inventory.Items[len(owner.inventory.Items)-1].Quality = item.quality
+ owner.inventory.Items[len(owner.inventory.Items)-1].Slot = item.slot
+ }
+ if err := world.saveInventory_locked(owner, owner.inventory); err != nil {
+ t.Fatal(err)
+ }
+
+ // Each phase drains browser sessions before its database closes.
+ t.Run("warm", func(t *testing.T) {
+ t.Cleanup(func() { world.db.Close() })
+ 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()
+ armor := [8]int32{}
+ for index := range armor {
+ armor[index] = owner.equipmentBonus(90 + uint32(index))
+ }
+ json.NewEncoder(w).Encode(map[string]any{"inventory": owner.inventory, "stats": owner.stats,
+ "armor": armor, "observer": watcher.inventory, "pending": world.clients[owner.id].equipment != nil})
+ })
+ host := httptest.NewServer(mux)
+ t.Cleanup(host.Close)
+ closeTestBrowserStreams(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 4*time.Minute)
+ defer cancel()
+ stopped := make(chan struct{})
+ go func() {
+ defer close(stopped)
+ ticker := time.NewTicker(20 * time.Millisecond)
+ defer ticker.Stop()
+ 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_steel_ribbed_armor.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)
+ }
+ if len(owner.inventory.Items) != 9 || owner.inventory.Credits != 5239 || owner.stats.ImprovementPoints != 970 ||
+ owner.stats.Abilities.Sense != 271 || owner.stats.Abilities.Agility != 246 || len(watcher.inventory.Items) != 0 {
+ t.Fatal("native armor contract lost ownership, selected-quality price or trained abilities")
+ }
+ })
+ if t.Failed() {
+ return
+ }
+ t.Run("cold", func(t *testing.T) {
+ cold := newServer()
+ t.Cleanup(func() { cold.db.Close() })
+ for _, player := range []*character{owner, watcher} {
+ // Loaded inventory views share the world's last allocated item identity.
+ expected := player.inventory
+ expected.LastID = 10
+ if !reflect.DeepEqual(expected, cold.characters[player.id].inventory) || player.stats != cold.characters[player.id].stats {
+ t.Fatal("completed armor contract changed on cold loading", player.id)
+ }
+ }
+ for index, armor := range [8]int32{156, 138, 156, 156, 35, 35, 138, 35} {
+ if cold.characters[owner.id].equipmentBonus(90+uint32(index)) != armor {
+ t.Fatal("cold armor or independent sleeves changed", index)
+ }
+ }
+ host := httptest.NewServer(cold.httpHandler())
+ t.Cleanup(host.Close)
+ closeTestBrowserStreams(t, cold)
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
+ defer cancel()
+
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_steel_ribbed_cold.mjs"), host.URL, filepath.Join(output, "cold"))
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ if err := command.Run(); err != nil {
+ t.Fatal(err)
+ }
+ })
+}
diff --git a/server/gamedata/item_families.yaml b/server/gamedata/item_families.yaml
@@ -58,3 +58,10 @@
- [25812, 25811]
- [85366, 85367]
- [25820, 25821]
+# Regular Steel-Ribbed armor: original descriptor audit; docs/steel-ribbed-armor.md.
+- [85494, 22347]
+- [85541, 22262]
+- [85580, 22212]
+- [85620, 22158]
+- [85668, 22080]
+- [85724, 21971]
diff --git a/server/gamedata/item_quality_test.go b/server/gamedata/item_quality_test.go
@@ -23,6 +23,8 @@ func TestReviewedItemFamilyQualityRanges(t *testing.T) {
{85530, 85529, 1, 200}, {85571, 85570, 1, 200}, {85611, 85610, 1, 200},
{85654, 85653, 1, 200}, {85708, 85707, 1, 200}, {85710, 85709, 1, 200}, {85759, 85758, 1, 200},
{25812, 25811, 1, 200}, {85366, 85367, 1, 200}, {25820, 25821, 1, 200},
+ {85494, 22347, 1, 200}, {85541, 22262, 1, 200}, {85580, 22212, 1, 200},
+ {85620, 22158, 1, 200}, {85668, 22080, 1, 200}, {85724, 21971, 1, 200},
} {
for _, template := range [2]uint32{family.lowTemplate, family.highTemplate} {
t.Run(fmt.Sprint(template), func(t *testing.T) {
@@ -49,6 +51,7 @@ func TestUnreviewedItemQualityRemainsExact(t *testing.T) {
template, quality uint32
supported bool
}{{209283, 1, true}, {209283, 2, false}, {85557, 0, false}, {161966, 200, true}, {161966, 199, false},
+ {160417, 1, true}, {160417, 2, false},
{124262, 180, true}, {124262, 179, false}, {124262, 181, false}, {4294967295, 1, false}} {
t.Run(fmt.Sprintf("%d/%d", entry.template, entry.quality), func(t *testing.T) {
got := gamedata.ItemQualitySupported(entry.template, entry.quality)
diff --git a/server/steel_ribbed_armor_test.go b/server/steel_ribbed_armor_test.go
@@ -0,0 +1,218 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "bytes"
+ "encoding/binary"
+ "fmt"
+ "slices"
+ "testing"
+)
+
+func TestSteelRibbedGeneratedPickupKeepsSelectedQuality(t *testing.T) {
+ world, output := newKillExperienceWorld(t, "unarmed")
+ player, client := world.characters[1], world.clients[1]
+ player.stats.Abilities.Sense, player.stats.Abilities.Agility = 269, 244
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ // Controlled membership tests delivery, not historical SteelRibbed creature drops.
+ profile := *world.characters[1000000].combatProfile
+ profile.Loot = []gamedata.NPCLoot{{Template: 22212, Quality: [2]uint32{100, 100}, Chance: 100}}
+ world.characters[1000000].combatProfile = &profile
+ world.combatRoll = func(uint32) uint32 { return 0 }
+ identity := world.nextItem + 1
+ var wire []byte
+ for _, value := range []uint32{identity, 85580, 22212, 100, 0} {
+ wire = binary.BigEndian.AppendUint32(wire, value)
+ }
+
+ attackForExperience(t, world, "unarmed")
+ if err := world.handleLootUse(client, lootUseRequest(1)); err != nil {
+ t.Fatal(err)
+ }
+ shown := slices.ContainsFunc(output.packets, func(packet []byte) bool { return bytes.Contains(packet, wire) })
+ for range 2 {
+ if err := world.handleInventory(client, lootTakeRequest()); err != nil {
+ t.Fatal(err)
+ }
+ }
+ world = newTestInventoryServer(t)
+ client = &worldClient{id: 1, conn: output, target: true, ready: true}
+ world.clients[1] = client
+ if err := world.handleInventory(client, inventoryMovePacket(1, 64, 24)[20:]); err != nil || client.equipment == nil {
+ t.Fatal("picked-up gloves did not start wear", err)
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ worn := newTestInventoryServer(t)
+ if err := world.handleInventory(client, itemMovePacket(1, 24, 64)[20:]); err != nil || client.equipment == nil {
+ t.Fatal("picked-up gloves did not start removal", err)
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ removed := newTestInventoryServer(t)
+
+ expected := ownedItem{ID: identity, Type: 51022, Template: 22212, Quality: 100, Slot: 24, Count: 1}
+ if !shown || !slices.Equal(worn.characters[1].inventory.Items, []ownedItem{expected}) || worn.characters[1].equipmentBonus(91) != 109 {
+ t.Fatal("generated pickup lost its native endpoints, identity, selected quality or worn AC")
+ }
+ expected.Slot = 64
+ if !slices.Equal(removed.characters[1].inventory.Items, []ownedItem{expected}) || removed.characters[1].equipmentBonus(91) != 0 ||
+ len(removed.characters[1000000].corpse.items) != 0 || removed.nextItem != identity {
+ t.Fatal("duplicate pickup, removal or cold recovery lost or duplicated the gloves")
+ }
+}
+
+func TestSteelRibbedArmorQualitiesWearRemoveAndRecover(t *testing.T) {
+ for _, scenario := range []struct {
+ low, high, slot, quality, value uint32
+ sense, agility uint16
+ armor [8]int32
+ }{
+ {85494, 22347, 27, 1, 906, 8, 8, [8]int32{3, 3, 3, 3, 1, 1, 3, 1}},
+ {85494, 22347, 27, 2, 927, 11, 10, [8]int32{6, 6, 6, 6, 2, 2, 6, 2}},
+ {85494, 22347, 27, 20, 8760, 58, 53, [8]int32{62, 55, 62, 62, 13, 13, 55, 13}},
+ {85494, 22347, 27, 100, 214144, 268, 243, [8]int32{312, 273, 312, 312, 63, 63, 273, 63}},
+ {85494, 22347, 27, 200, 862498, 530, 480, [8]int32{625, 546, 625, 625, 125, 125, 546, 125}},
+ {85541, 22262, 18, 1, 1087, 8, 8, [8]int32{3, 3, 3, 3, 1, 1, 3, 1}},
+ {85541, 22262, 18, 2, 1113, 11, 10, [8]int32{7, 6, 7, 7, 2, 2, 6, 2}},
+ {85541, 22262, 18, 20, 10512, 58, 53, [8]int32{74, 65, 74, 74, 15, 15, 65, 15}},
+ {85541, 22262, 18, 100, 256973, 268, 243, [8]int32{375, 328, 375, 375, 75, 75, 328, 75}},
+ {85541, 22262, 18, 200, 1034998, 530, 480, [8]int32{750, 656, 750, 750, 150, 150, 656, 150}},
+ {85580, 22212, 24, 1, 362, 8, 8, [8]int32{1, 1, 1, 1, 1, 1, 1, 1}},
+ {85580, 22212, 24, 2, 370, 11, 10, [8]int32{2, 2, 2, 2, 1, 1, 2, 1}},
+ {85580, 22212, 24, 20, 3503, 58, 53, [8]int32{25, 22, 25, 25, 6, 6, 22, 6}},
+ {85580, 22212, 24, 100, 85657, 268, 243, [8]int32{125, 109, 125, 125, 25, 25, 109, 25}},
+ {85580, 22212, 24, 101, 87388, 270, 245, [8]int32{126, 110, 126, 126, 26, 26, 110, 26}},
+ {85580, 22212, 24, 199, 341543, 527, 478, [8]int32{249, 217, 249, 249, 50, 50, 217, 50}},
+ {85580, 22212, 24, 200, 344999, 530, 480, [8]int32{250, 218, 250, 250, 50, 50, 218, 50}},
+ {85620, 22158, 30, 1, 543, 8, 8, [8]int32{1, 1, 1, 1, 1, 1, 1, 1}},
+ {85620, 22158, 30, 2, 556, 11, 10, [8]int32{3, 3, 3, 3, 1, 1, 3, 1}},
+ {85620, 22158, 30, 20, 5255, 58, 53, [8]int32{37, 32, 37, 37, 8, 8, 32, 8}},
+ {85620, 22158, 30, 100, 128486, 268, 243, [8]int32{187, 164, 187, 187, 38, 38, 164, 38}},
+ {85620, 22158, 30, 200, 517499, 530, 480, [8]int32{375, 328, 375, 375, 75, 75, 328, 75}},
+ {85668, 22080, 21, 1, 1450, 8, 8, [8]int32{5, 5, 5, 5, 1, 1, 5, 1}},
+ {85668, 22080, 21, 2, 1484, 11, 10, [8]int32{10, 9, 10, 10, 2, 2, 9, 2}},
+ {85668, 22080, 21, 20, 14016, 58, 53, [8]int32{100, 88, 100, 100, 20, 20, 88, 20}},
+ {85668, 22080, 21, 100, 342631, 268, 243, [8]int32{500, 438, 500, 500, 100, 100, 438, 100}},
+ {85668, 22080, 21, 200, 1379997, 530, 480, [8]int32{1000, 875, 1000, 1000, 200, 200, 875, 200}},
+ {85724, 21971, 25, 1, 362, 8, 8, [8]int32{1, 1, 1, 1, 1, 1, 1, 1}},
+ {85724, 21971, 25, 2, 370, 11, 10, [8]int32{2, 2, 2, 2, 1, 1, 2, 1}},
+ {85724, 21971, 23, 2, 370, 11, 10, [8]int32{2, 2, 2, 2, 1, 1, 2, 1}},
+ {85724, 21971, 25, 20, 3503, 58, 53, [8]int32{25, 22, 25, 25, 6, 6, 22, 6}},
+ {85724, 21971, 25, 100, 85657, 268, 243, [8]int32{125, 109, 125, 125, 25, 25, 109, 25}},
+ {85724, 21971, 25, 200, 344999, 530, 480, [8]int32{250, 218, 250, 250, 50, 50, 218, 50}},
+ } {
+ for _, anchor := range []uint32{scenario.low, scenario.high} {
+ t.Run(fmt.Sprintf("%d/QL%d/slot%d", anchor, scenario.quality, scenario.slot), func(t *testing.T) {
+ world, output := newEquipmentWorld(t)
+ t.Cleanup(func() { world.db.Close() })
+ player, client := world.characters[1], world.clients[1]
+ player.stats.Abilities.Sense, player.stats.Abilities.Agility = scenario.sense+1, scenario.agility+1
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if granted, err := world.grantItem_locked(player, anchor); err != nil || !granted {
+ t.Fatal("grant armor", granted, err)
+ }
+ player.inventory.Items[1].Quality = scenario.quality
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ weapon := player.inventory.Items[0]
+
+ for _, ability := range []*uint16{&player.stats.Abilities.Sense, &player.stats.Abilities.Agility} {
+ *ability -= 1
+ if err := world.handleInventory(client, inventoryMovePacket(1, 65, scenario.slot)[20:]); err != nil || client.equipment != nil || player.inventory.Items[1].Slot != 65 {
+ t.Fatal("threshold equality equipped or lost the armor", err)
+ }
+ *ability += 1
+ }
+ output.packets = nil
+ if err := world.handleInventory(client, inventoryMovePacket(1, 65, scenario.slot)[20:]); err != nil || client.equipment == nil {
+ t.Fatal("qualified armor did not start wear", err)
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ worn := newTestInventoryServer(t)
+ low, high := scenario.low, scenario.high
+ if scenario.quality == 1 {
+ high = low
+ } else if scenario.quality == 200 {
+ low = high
+ }
+ var action []byte
+ for _, word := range []uint32{low, high, scenario.quality, 1, 6, 102, scenario.slot, 0, 0} {
+ action = binary.BigEndian.AppendUint32(action, word)
+ }
+ if len(output.packets) != 2 || !bytes.Equal(output.packets[1][29:65], action) {
+ t.Fatal("native wear lost the selected quality or endpoint pair")
+ }
+ if err := world.handleInventory(client, itemMovePacket(1, scenario.slot, 111)[20:]); err != nil || client.equipment == nil {
+ t.Fatal("armor did not start removal", err)
+ }
+ world.advanceEquipment(client.equipment.readyAt)
+ removed := newTestInventoryServer(t)
+
+ expected := ownedItem{ID: 2, Type: 51022, Template: anchor, Quality: scenario.quality, Slot: scenario.slot, Count: 1}
+ if !slices.Equal(worn.characters[1].inventory.Items, []ownedItem{weapon, expected}) || worn.characters[1].inventory.Items[1].shopPrice() != scenario.value {
+ t.Fatal("cold armor identity, quality, value or unrelated item changed")
+ }
+ expected.Slot = 65
+ if !slices.Equal(removed.characters[1].inventory.Items, []ownedItem{weapon, expected}) || removed.nextItem != 2 {
+ t.Fatal("removal lost or replaced an instance")
+ }
+ for index, bonus := range scenario.armor {
+ if worn.characters[1].equipmentBonus(90+uint32(index)) != bonus || removed.characters[1].equipmentBonus(90+uint32(index)) != 0 {
+ t.Fatal("selected armor effects or their removal changed", index)
+ }
+ }
+ })
+ }
+ }
+}
+
+func TestSteelRibbedSaleCancellationAndReplayKeepSelectedQuality(t *testing.T) {
+ for _, scenario := range []struct{ quality, sale uint32 }{
+ {2, 18}, {100, 4282}, {101, 4369}, {200, 17249},
+ } {
+ t.Run(fmt.Sprint(scenario.quality), func(t *testing.T) {
+ world, _ := newShopWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ if granted, err := world.grantItem_locked(player, 85580); err != nil || !granted {
+ t.Fatal(granted, err)
+ }
+ player.inventory.Items[1].Quality = scenario.quality
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ before := append([]ownedItem(nil), player.inventory.Items...)
+ offer := shopTradePacket([2]uint32{50000, 1}, 4, [2]uint32{50000, 1}, [2]uint32{104, 65})[20:]
+
+ if err := world.handleTrade(client, offer); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 2, [2]uint32{}, [2]uint32{})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ cancelled := newTestInventoryServer(t).characters[1].inventory
+ if err := world.handleShopUse(client, shopUseRequest(2)); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleTrade(client, offer); err != nil {
+ t.Fatal(err)
+ }
+ for range 2 {
+ if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 1, [2]uint32{}, [2]uint32{})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ sold := newTestInventoryServer(t).characters[1].inventory
+
+ if !slices.Equal(cancelled.Items, before) || cancelled.Credits != 100 {
+ t.Fatal("cancelled sale changed the selected instance or wallet", cancelled)
+ }
+ if !slices.Equal(sold.Items, before[:1]) || sold.Credits != 100+scenario.sale {
+ t.Fatal("accepted or repeated sale changed another item or its selected-quality price", sold)
+ }
+ })
+ }
+}
diff --git a/tools/client/test_steel_ribbed_armor.mjs b/tools/client/test_steel_ribbed_armor.mjs
@@ -0,0 +1,158 @@
+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', headless: false,
+ args: ['--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+const games = [];
+async function bagClick(game, id) {
+ await game.wait('inventory actions finish', state =>
+ !game.local(state).actions.includes(3) && !game.local(state).actions.includes(6));
+ const item = game.local().inventory.find(item => item.id === id);
+ assert(item && item.slot >= 48 && item.slot < 57);
+ const cell = item.slot - 48;
+ await game.click(681 + cell % 3 * 54, 45 + Math.floor(cell / 3) * 54, 'right');
+}
+try {
+ for (const token of ['steel-owner', 'steel-watch']) {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: token, url}]);
+ const page = await context.newPage();
+ const game = await GameTest.attach(page);
+ games.push(game);
+ await page.goto(url);
+ await game.ready();
+ }
+ const [owner, observer] = games;
+ const state = async () => (await owner.page.request.get(url + '/test-state')).json();
+ const baseline = await state();
+ assert.equal(baseline.inventory.Items.length, 10);
+ assert.deepEqual(baseline.armor, [32, 30, 32, 32, 10, 10, 30, 10]);
+ await owner.key('KeyI');
+ await owner.page.keyboard.press('Control+1');
+ await owner.click(953, 53);
+ await owner.page.keyboard.press('Control+9');
+ await owner.save(output + '/initial');
+
+ // Every piece uses native removal and wear, with explicit left-arm placement.
+ for (const [id, slot, x, y, armor] of [
+ [1, 18, 927, 94, [7, 6, 7, 7, 2, 2, 6, 2]],
+ [2, 27, 927, 262, [6, 6, 6, 6, 2, 2, 6, 2]],
+ [3, 30, 927, 316, [3, 3, 3, 3, 1, 1, 3, 1]],
+ [4, 23, 867, 206, [2, 2, 2, 2, 1, 1, 2, 1]],
+ [5, 25, 987, 206, [2, 2, 2, 2, 1, 1, 2, 1]],
+ [6, 24, 927, 206, [2, 2, 2, 2, 1, 1, 2, 1]],
+ [7, 21, 927, 148, [10, 9, 10, 10, 2, 2, 9, 2]],
+ ]) {
+ const sequence = observer.sequence;
+ await owner.click(x, y, 'right');
+ await owner.wait('exact piece removed', state => owner.local(state).inventory.some(item => item.id === id && item.slot >= 48));
+ assert.deepEqual((await state()).armor, baseline.armor.map((value, index) => value - armor[index]));
+ if (slot === 23) {
+ await owner.wait('arm action finishes', state => !owner.local(state).actions.includes(3));
+ const cell = owner.local().inventory.find(item => item.id === id).slot - 48;
+ await owner.click(681 + cell % 3 * 54, 45 + Math.floor(cell / 3) * 54);
+ await owner.click(x, y);
+ } else await bagClick(owner, id);
+ await owner.wait('exact piece worn', state => owner.local(state).inventory.some(item => item.id === id && item.slot === slot));
+ await observer.wait('observer receives wear', () => observer.events.some(event => {
+ if (event.sequence <= sequence || event.direction !== 'framereceived' || event.opcode !== '35505644' || event.actor[1] !== 1) return false;
+ const packet = Buffer.from(event.hex, 'hex');
+ return packet.readUInt32BE(45) === 6 && packet.readUInt32BE(53) === slot;
+ }));
+ assert.deepEqual((await state()).armor, baseline.armor);
+ }
+ await owner.save(output + '/all-pieces');
+ await observer.save(output + '/observer-all-pieces');
+
+ // The high stored endpoint must still deliver the selected QL100 contract.
+ await owner.click(927, 206, 'right');
+ await owner.wait('QL2 gloves retained', state => owner.local(state).inventory.some(item => item.id === 6 && item.slot >= 48));
+ await bagClick(owner, 8);
+ await owner.wait('QL100 gloves worn', state => owner.local(state).inventory.some(item => item.id === 8 && item.slot === 24));
+ assert.deepEqual((await state()).armor, [155, 137, 155, 155, 34, 34, 137, 34]);
+ await owner.save(output + '/quality-100');
+ await owner.click(927, 206, 'right');
+ await owner.wait('QL100 gloves retained', state => owner.local(state).inventory.some(item => item.id === 8 && item.slot >= 48));
+ const before = await state(), sequence = owner.sequence;
+ await bagClick(owner, 9);
+ await owner.save(output + '/quality-101-rejected');
+ assert(!owner.events.some(event => event.sequence > sequence && event.direction === 'framesent' && event.opcode === '47537a24'));
+ assert.deepEqual((await state()).inventory, before.inventory);
+ assert.equal((await state()).pending, false);
+
+ // Train one Agility and Sense point through the original ability form.
+ await owner.page.keyboard.press('Control+1');
+ await owner.page.keyboard.press('Control+9');
+ await owner.key('KeyU');
+ await owner.click(334, 256);
+ await owner.click(835, 196);
+ await owner.click(835, 286);
+ await owner.click(445, 622);
+ await owner.wait('trained strict thresholds', state => owner.local(state).stats[17] === 246 &&
+ owner.local(state).stats[20] === 271 && owner.local(state).stats[53] === 970);
+ await bagClick(owner, 9);
+ await owner.wait('QL101 gloves worn', state => owner.local(state).inventory.some(item => item.id === 9 && item.slot === 24));
+ assert.deepEqual((await state()).armor, [156, 138, 156, 156, 35, 35, 138, 35]);
+ const high = await state(), highSequence = owner.sequence;
+ await bagClick(owner, 10);
+ await owner.save(output + '/quality-200-rejected');
+ assert(!owner.events.some(event => event.sequence > highSequence && event.direction === 'framesent' && event.opcode === '47537a24'));
+ assert.deepEqual((await state()).inventory, high.inventory);
+
+ // Cancel, then accept one selected-quality sale at the original armor machine.
+ if (!owner.state.camera.firstPerson) await owner.key('F8');
+ let offered = await state();
+ for (let attempt = 0; attempt < 2; ++attempt) {
+ const [x, y] = await owner.pick(51035, 3221226655);
+ await owner.click(x, y, 'right');
+ await owner.wait('armor machine open', state => state.regions.some(([left, top, right, bottom]) =>
+ left === 832 && top === 0 && right === 1024 && bottom === 494));
+ const cell = owner.local().inventory.find(item => item.id === 8).slot - 48;
+ await owner.click(681 + cell % 3 * 54, 45 + Math.floor(cell / 3) * 54);
+ const sequence = owner.sequence;
+ await owner.click(864, 416);
+ await owner.wait('sale offered', () => owner.events.some(event => event.sequence > sequence &&
+ event.direction === 'framesent' && event.opcode === '36284f6e'));
+ assert.deepEqual((await state()).inventory, offered.inventory);
+ await owner.save(output + '/sale-offer-' + attempt);
+ if (attempt === 0) {
+ await owner.click(945, 475);
+ await owner.wait('cancelled glove restored', state => owner.local(state).inventory.some(item => item.id === 8 && item.slot === 48));
+ assert.deepEqual((await state()).inventory, offered.inventory);
+ offered = await state();
+ }
+ }
+ await owner.click(874, 475);
+ await owner.wait('exact selected-quality sale', state => owner.local(state).stats[61] === 5239);
+ const final = await state();
+ const slots = {1: 18, 2: 27, 3: 30, 4: 23, 5: 25, 6: 67, 7: 21, 9: 24, 10: 66};
+ const expected = baseline.inventory.Items.filter(item => item.ID !== 8).map(item => ({...item, Slot: slots[item.ID]}));
+ assert.deepEqual(final.inventory.Items, expected);
+ assert.deepEqual(final.observer, baseline.observer);
+ await fs.writeFile(output + '/ledger.json', JSON.stringify(final, null, 2));
+ await owner.page.reload();
+ await owner.ready();
+ const pairs = {85541: [85541, 22262], 85494: [85494, 22347], 85620: [85620, 22158],
+ 85724: [85724, 21971], 85580: [85580, 22212], 85668: [85668, 22080]};
+ for (const item of expected) {
+ const pair = pairs[item.Template];
+ assert.deepEqual(owner.local().inventory.find(actual => actual.id === item.ID), {
+ slot: item.Slot >= 64 ? item.Slot - 16 : item.Slot, type: item.Type, id: item.ID,
+ quality: item.Quality, templates: item.Quality === 200 ? [pair[1], pair[1]] : pair, count: 1});
+ }
+ await owner.key('KeyI');
+ await owner.page.keyboard.press('Control+1');
+ await owner.click(953, 53);
+ await owner.page.keyboard.press('Control+9');
+ await owner.save(output + '/reconnected');
+ assert(games.every(game => game.errors.length === 0));
+ console.log('PASS: Steel-Ribbed pieces, both sleeves, QL100/101 native gates/training, exact sale and page recovery');
+} finally {
+ try { await Promise.all(games.map((game, index) => game.save(output + '/final-' + index))); }
+ finally { await browser.close(); }
+}
diff --git a/tools/client/test_steel_ribbed_cold.mjs b/tools/client/test_steel_ribbed_cold.mjs
@@ -0,0 +1,44 @@
+import assert from 'node:assert/strict';
+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', headless: false,
+ args: ['--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+const games = [];
+try {
+ for (const token of ['steel-owner', 'steel-watch']) {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: token, url}]);
+ const page = await context.newPage();
+ const game = await GameTest.attach(page);
+ games.push(game);
+ await page.goto(url);
+ await game.ready();
+ }
+ const [owner, observer] = games;
+ assert.deepEqual(owner.local().inventory.map(item =>
+ [item.id, item.slot, item.quality, ...item.templates, item.count]).sort((a, b) => a[0] - b[0]), [
+ [1, 18, 2, 85541, 22262, 1], [2, 27, 2, 85494, 22347, 1],
+ [3, 30, 2, 85620, 22158, 1], [4, 23, 2, 85724, 21971, 1],
+ [5, 25, 2, 85724, 21971, 1], [6, 51, 2, 85580, 22212, 1],
+ [7, 21, 2, 85668, 22080, 1], [9, 24, 101, 85580, 22212, 1],
+ [10, 50, 200, 22212, 22212, 1],
+ ]);
+ assert.equal(owner.local().stats[17], 246);
+ assert.equal(owner.local().stats[20], 271);
+ assert.equal(owner.local().stats[53], 970);
+ assert.equal(owner.local().stats[61], 5239);
+ assert.deepEqual(observer.local().inventory, []);
+ await owner.key('KeyI');
+ await owner.page.keyboard.press('Control+1');
+ await owner.click(953, 53);
+ await owner.page.keyboard.press('Control+9');
+ assert(games.every(game => game.errors.length === 0));
+ console.log('PASS: all nine exact Steel-Ribbed identities, endpoints, slots, training and sale wallet after cold startup');
+} finally {
+ try { await Promise.all(games.map((game, index) => game.save(output + '/' + index))); }
+ finally { await browser.close(); }
+}