aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 825c28c2b7f9e1ff553b4bb99af1638896a2c3bd
parent c3462043d5f83cbf3d6c657bd3c275c9c3519f25
Author: anon <anon@example.com>
Date:   Mon,  2 Nov 2026 18:42:32 +0000

Admit reviewed Bau Cyber armor quality families

Diffstat:
MTODO.md | 6++++++
Adocs/bau-cyber-armor.md | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocs/leather-armor.md | 6+++---
Aserver/bau_cyber_armor_test.go | 224+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/browser_bau_cyber_test.go | 154+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/gamedata/item_families.yaml | 8++++++++
Mserver/gamedata/item_quality_test.go | 4+++-
Atools/client/test_bau_cyber_armor.mjs | 205+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/client/test_bau_cyber_cold.mjs | 46++++++++++++++++++++++++++++++++++++++++++++++
Mtools/client/test_leather_armor.mjs | 7+------
10 files changed, 733 insertions(+), 10 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -351,6 +351,12 @@ unverified mass/deletion/reclaim policies are in [backpacks](docs/backpacks.md). cover selected-quality wear/removal, strict Intelligence/Psychic gates, native UI training, sale and retained ownership. Acquisition remains open; see [Cyber contracts](docs/cyber-armor.md). + Seven regular Bau Cyber pairs now pass the same original descriptor audit and + shared QL1..200 path, with strict Intelligence/Psychic gates and both body + styles. Public-handler tests cover pickup, boundary QLs, wear/removal, sale + and cold ownership. A short controlled two-client WASM run covers both sleeves, + QL100/101 training, cancellation/acceptance and fresh-server native recovery. + Original acquisition remains open; see [Bau Cyber contracts](docs/bau-cyber-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/bau-cyber-armor.md b/docs/bau-cyber-armor.md @@ -0,0 +1,83 @@ +# Regular Bau Cyber armor qualities + +Seven reviewed Bau Cyber pairs now use the shared QL1..200 equipment path. +The ordinary set's intermediate qualities were rejected while the two stored +anchors existed. Admission now supplies selected requirements, AC, value and +native endpoints without a family-specific gameplay branch. Both body styles +and independent sleeve instances retain their original contracts. + +## Original records + +All fourteen complete resource1000020 records were independently decoded from +the original14.9.1 database and compared field-for-field with the catalog, +including text headers, sections and record offsets. Raw bytes, payload hashes +and the full descriptors are retained in `local/bau-cyber-armor/original/`. +The original index SHA-256 is +`46e5dc54af9358cc9bff05f4358e86af630e497bc677f361c133c88073b84d71`. + +| Piece | QL1 / QL200 templates | Native slot | Base value at QL2 | +| --- | --- | --- | --- | +| Pants | 85530 / 85529 | 27 | 943 | +| Helmet | 85571 / 85570 | 18 | 1132 | +| Gloves | 85611 / 85610 | 24 | 376 | +| Boots | 85654 / 85653 | 30 | 566 | +| Female body armor | 85708 / 85707 | 21 | 1510 | +| Body armor | 85710 / 85709 | 21 | 1510 | +| Sleeves | 85759 / 85758 | 23 or25 | 376 | + +Within each pair only scalar stats1/2/54/74, the eight AC amounts and the two +wear thresholds differ. Section byte offsets follow text lengths. Complete +remaining functions, criteria and appearance descriptors agree; no unknown +effect is discarded. The distinct Classic Bau boots161966 are not added to +these families. Matching names alone do not identify interpolation endpoints. + +Wear requires Intelligence19 and Psychic21 strictly greater than8 at QL1, +and greater than515/465 at QL200. Shared rounding gives QL20 thresholds56/52, +QL100 thresholds260/235 and QL101 thresholds263/238. The original shared +quadratic price path gives the QL100 glove87134 base value. + +The local Fandom page3312, touched2007-12-24, agrees with the original full +QL200 set totals but does not establish acquisition in14.9.1. The +[Hahnsoo guide updated January2008](https://gamefaqs.gamespot.com/pc/913777-anarchy-online/faqs/46197) +lists a later obtainable range beginning at QL20 and mentions several sources. +That is separate from the client's QL1..200 interpolation anchors. Bounded +period searches recovered no precise14.9.1 pool or minimum-acquisition rule. +Production stock, reward selections and creature drops are unchanged. + +## Verification + +Public inventory-handler cases cover both stored anchors, all seven pairs, +both arm slots, QL1/2/20/100/200 and glove5/101/199 rounding boundaries. +They verify strict equality rejection, native endpoint delivery, all eight ACs, +exact price, removal and cold ownership. A controlled generated-drop case +retains its same selected-quality glove through pickup/replay and wear/removal; +sale cases cover cancellation, acceptance and duplicate acceptance. Quality +range tests reject extrapolation and keep the unreviewed Classic boots exact. +Qualified QL2/20/200 glove wear failed before family admission. + +`TestBrowserBauCyberArmorQualities` supplies eleven controlled instances before +either WASM client connects. Actual input removes and re-wears all seven pieces, +explicitly places the left sleeve, wears QL100 gloves stored at the high anchor, +and rejects QL101 at both strict thresholds without sending a wear request. +Native ability training spends501 IP for Intelligence264/Psychic239; that exact +QL101 glove then wears. QL200 remains in inventory. The other body style wears +without losing the removed instance. + +The native basic-armor sale quotes5280 for glove9 at QL100: the original six +percent modifier gives5228 and effective Computer Literacy71 adds52. A cancelled +offer retains the glove; acceptance leaves5380 credits and the other ten exact +instances. Final all-eight AC totals are156/156/138/35/103/120/35/120; +the rendered Stats form shows156/156/138 for its three displayed ACs. + +Page replay and cold database loading retain every remaining ID, slot, quality, +count, wallet and trained stat. After closing the first server's database, two +fresh WASM clients reconstruct those same ten instances and endpoints. The +combined native run takes47.60 seconds, with no client errors, under +`local/game-tests/bau-cyber-20261102-103559/`. These are item-contract fixtures, +not earned acquisition or progression evidence. Test-owned clients and servers +close between runs and after failures. + +The focused normal server/game-data selection passes20.097s/7.726s; the expanded +race selection passes115.882s/103.103s. Vet and driver syntax checks pass. +Logs, original-resource audit and independent literal expectations are retained +under `local/bau-cyber-armor/`. diff --git a/docs/leather-armor.md b/docs/leather-armor.md @@ -58,9 +58,9 @@ historical Leather drop table. `TestBrowserLeatherArmorQualities` starts a controlled level100 Opifex with eleven physical instances before either WASM client connects. Actual browser input removes and re-wears all seven pieces, keeping both sleeve identities. -Right-click chooses the original default arm25; an occupied-arm rejection keeps -the other sleeve, which can be picked up and explicitly placed in arm23 after -the native action gate clears. Read-only snapshots expose the original action +Right-click selects default arm25 and can replace its current sleeve. To target +the other arm, the fixture picks up that sleeve and places it explicitly in +arm23 after the native action gate clears. Read-only snapshots expose the original action types3/6 used by `kkr.dll`'s inventory admission gate; no timer or guest mutation is used to bypass it. Placement uses click-to-pick-up/click-to-place. diff --git a/server/bau_cyber_armor_test.go b/server/bau_cyber_armor_test.go @@ -0,0 +1,224 @@ +package main + +import ( + "ao/server/gamedata" + "bytes" + "encoding/binary" + "fmt" + "slices" + "testing" +) + +func TestBauCyberGeneratedPickupKeepsSelectedQuality(t *testing.T) { + world, output := newKillExperienceWorld(t, "unarmed") + player, client := world.characters[1], world.clients[1] + player.stats.Abilities.Intelligence, player.stats.Abilities.Psychic = 261, 236 + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + // Controlled membership tests delivery, not historical BauCyber creature drops. + profile := *world.characters[1000000].combatProfile + profile.Loot = []gamedata.NPCLoot{{Template: 85610, 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, 85611, 85610, 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: 85610, Quality: 100, Slot: 24, Count: 1} + if !shown || !slices.Equal(worn.characters[1].inventory.Items, []ownedItem{expected}) || worn.characters[1].equipmentBonus(91) != 125 { + 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 TestBauCyberArmorQualitiesWearRemoveAndRecover(t *testing.T) { + for _, scenario := range []struct { + low, high, slot, quality, value uint32 + intelligence, psychic uint16 + armor [8]int32 + }{ + {85530, 85529, 27, 1, 921, 8, 8, [8]int32{3, 3, 3, 1, 3, 3, 1, 3}}, + {85530, 85529, 27, 2, 943, 11, 10, [8]int32{6, 6, 6, 2, 5, 5, 2, 5}}, + {85530, 85529, 27, 20, 8910, 56, 52, [8]int32{62, 62, 55, 13, 40, 47, 13, 47}}, + {85530, 85529, 27, 100, 217836, 260, 235, [8]int32{312, 312, 273, 63, 196, 234, 63, 234}}, + {85530, 85529, 27, 200, 877369, 515, 465, [8]int32{625, 625, 546, 125, 390, 468, 125, 468}}, + {85571, 85570, 18, 1, 1106, 8, 8, [8]int32{3, 3, 3, 1, 3, 3, 1, 3}}, + {85571, 85570, 18, 2, 1132, 11, 10, [8]int32{7, 7, 6, 2, 5, 6, 2, 6}}, + {85571, 85570, 18, 20, 10693, 56, 52, [8]int32{74, 74, 65, 15, 47, 56, 15, 56}}, + {85571, 85570, 18, 100, 261404, 260, 235, [8]int32{375, 375, 328, 75, 234, 281, 75, 281}}, + {85571, 85570, 18, 200, 1052843, 515, 465, [8]int32{750, 750, 656, 150, 468, 562, 150, 562}}, + {85611, 85610, 24, 1, 368, 8, 8, [8]int32{1, 1, 1, 1, 1, 1, 1, 1}}, + {85611, 85610, 24, 2, 376, 11, 10, [8]int32{2, 2, 2, 1, 2, 2, 1, 2}}, + {85611, 85610, 24, 5, 509, 18, 17, [8]int32{6, 6, 5, 2, 4, 5, 2, 5}}, + {85611, 85610, 24, 20, 3563, 56, 52, [8]int32{25, 25, 22, 6, 16, 19, 6, 19}}, + {85611, 85610, 24, 100, 87134, 260, 235, [8]int32{125, 125, 109, 25, 78, 94, 25, 94}}, + {85611, 85610, 24, 101, 88895, 263, 238, [8]int32{126, 126, 110, 26, 79, 94, 26, 94}}, + {85611, 85610, 24, 199, 347431, 512, 463, [8]int32{249, 249, 217, 50, 155, 186, 50, 186}}, + {85611, 85610, 24, 200, 350947, 515, 465, [8]int32{250, 250, 218, 50, 156, 187, 50, 187}}, + {85654, 85653, 30, 1, 553, 8, 8, [8]int32{1, 1, 1, 1, 1, 1, 1, 1}}, + {85654, 85653, 30, 2, 566, 11, 10, [8]int32{3, 3, 3, 1, 2, 2, 1, 2}}, + {85654, 85653, 30, 20, 5346, 56, 52, [8]int32{37, 37, 32, 8, 23, 28, 8, 28}}, + {85654, 85653, 30, 100, 130702, 260, 235, [8]int32{187, 187, 164, 38, 117, 140, 38, 140}}, + {85654, 85653, 30, 200, 526421, 515, 465, [8]int32{375, 375, 328, 75, 234, 281, 75, 281}}, + {85708, 85707, 21, 1, 1475, 8, 8, [8]int32{5, 5, 5, 1, 5, 5, 1, 5}}, + {85708, 85707, 21, 2, 1510, 11, 10, [8]int32{10, 10, 9, 2, 8, 9, 2, 9}}, + {85708, 85707, 21, 20, 14258, 56, 52, [8]int32{100, 100, 88, 20, 64, 76, 20, 76}}, + {85708, 85707, 21, 100, 348539, 260, 235, [8]int32{500, 500, 438, 100, 313, 376, 100, 376}}, + {85708, 85707, 21, 200, 1403790, 515, 465, [8]int32{1000, 1000, 875, 200, 625, 750, 200, 750}}, + {85710, 85709, 21, 1, 1475, 8, 8, [8]int32{5, 5, 5, 1, 5, 5, 1, 5}}, + {85710, 85709, 21, 2, 1510, 11, 10, [8]int32{10, 10, 9, 2, 8, 9, 2, 9}}, + {85710, 85709, 21, 20, 14258, 56, 52, [8]int32{100, 100, 88, 20, 64, 76, 20, 76}}, + {85710, 85709, 21, 100, 348539, 260, 235, [8]int32{500, 500, 438, 100, 313, 376, 100, 376}}, + {85710, 85709, 21, 200, 1403790, 515, 465, [8]int32{1000, 1000, 875, 200, 625, 750, 200, 750}}, + {85759, 85758, 25, 1, 368, 8, 8, [8]int32{1, 1, 1, 1, 1, 1, 1, 1}}, + {85759, 85758, 25, 2, 376, 11, 10, [8]int32{2, 2, 2, 1, 2, 2, 1, 2}}, + {85759, 85758, 23, 2, 376, 11, 10, [8]int32{2, 2, 2, 1, 2, 2, 1, 2}}, + {85759, 85758, 25, 20, 3563, 56, 52, [8]int32{25, 25, 22, 6, 16, 19, 6, 19}}, + {85759, 85758, 25, 100, 87134, 260, 235, [8]int32{125, 125, 109, 25, 78, 94, 25, 94}}, + {85759, 85758, 25, 200, 350947, 515, 465, [8]int32{250, 250, 218, 50, 156, 187, 50, 187}}, + } { + 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.Intelligence, player.stats.Abilities.Psychic = scenario.intelligence+1, scenario.psychic+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.Intelligence, &player.stats.Abilities.Psychic} { + *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 TestBauCyberSaleCancellationAndReplayKeepSelectedQuality(t *testing.T) { + for _, scenario := range []struct{ quality, sale uint32 }{ + {2, 18}, {100, 4356}, {101, 4444}, {200, 17547}, + } { + 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, 85611); 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/server/browser_bau_cyber_test.go b/server/browser_bau_cyber_test.go @@ -0,0 +1,154 @@ +package main + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "reflect" + "runtime" + "testing" + "time" +) + +func TestBrowserBauCyberArmorQualities(t *testing.T) { + if os.Getenv("AO_GAME_TEST") != "1" { + t.Skip("set AO_GAME_TEST=1 to run the real WASM client in Chromium") + } + + _, source, _, _ := runtime.Caller(0) + root := filepath.Dir(filepath.Dir(source)) + output := filepath.Join(root, "local", "game-tests", "bau-cyber-"+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 = "BauCyberowner", 100, 0x5b5 + 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.Intelligence, owner.stats.Abilities.Psychic = 263, 238 + owner.stats.ImprovementPoints, owner.inventory.Credits = 2000, 100 + owner.health, owner.nano = owner.maximumHealth(), owner.maximumNano() + owner.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("bau-cyber-owner"))) + watcher := world.newCharacter() + watcher.name, watcher.playfield, watcher.position = "BauCyberwatch", 1183, [3]float32{186, 5.11, 134.5} + watcher.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("bau-cyber-watch"))) + for _, player := range []*character{owner, watcher} { + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + if err := world.savePosition_locked(player); err != nil { + t.Fatal(err) + } + } + + // Seed a controlled item-contract fixture before either native client connects. + for _, item := range []struct{ template, quality, slot uint32 }{ + {85571, 2, 18}, {85530, 2, 27}, {85654, 2, 30}, + {85759, 2, 23}, {85759, 2, 25}, {85611, 2, 24}, {85710, 2, 21}, + {85708, 2, 64}, {85610, 100, 65}, {85611, 101, 66}, {85611, 200, 67}, + } { + 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) + } + 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) + defer host.Close() + closeTestBrowserStreams(t, world) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) + defer cancel() + stopped := make(chan struct{}) + go func() { + defer close(stopped) + ticker := time.NewTicker(50 * 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_bau_cyber_armor.mjs"), host.URL, output) + command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr + err := command.Run() + cancel() + <-stopped + t.Logf("Browser artifacts: %s", output) + if failure := world.flushPositions(time.Now().Add(20 * time.Second)); failure != nil { + t.Fatal(failure) + } + if failure := world.flushWorld(); failure != nil { + t.Fatal(failure) + } + if failure := os.MkdirAll(output, 755); failure != nil { + t.Fatal(failure) + } + if _, failure := world.db.Exec("VACUUM INTO ?", filepath.Join(output, "world.sqlite")); failure != nil { + t.Fatal(failure) + } + if err != nil { + t.Fatal(err) + } + cold := newServer() + defer cold.db.Close() + + for _, player := range []*character{owner, watcher} { + restored := cold.characters[player.id] + if !reflect.DeepEqual(player.inventory.Items, restored.inventory.Items) || player.inventory.Credits != restored.inventory.Credits || player.stats != restored.stats || + player.position != restored.position || player.rotation != restored.rotation { + t.Fatal("native armor outcome changed across cold loading", player.id) + } + } + if len(owner.inventory.Items) != 10 || owner.inventory.Credits != 5380 || owner.stats.ImprovementPoints != 1499 || + owner.stats.Abilities.Intelligence != 264 || owner.stats.Abilities.Psychic != 239 || len(watcher.inventory.Items) != 0 { + t.Fatal("native armor fixture lost ownership, selected-quality sale or ability training") + } + for index, armor := range [8]int32{156, 156, 138, 35, 103, 120, 35, 120} { + if owner.equipmentBonus(90+uint32(index)) != armor || cold.characters[owner.id].equipmentBonus(90+uint32(index)) != armor { + t.Fatal("native worn armor or independent sleeves changed", index) + } + } + + // Reconstruct the completed item contract in two fresh native clients. + host.Close() + if err := world.db.Close(); err != nil { + t.Fatal(err) + } + coldHost := httptest.NewServer(cold.httpHandler()) + t.Cleanup(coldHost.Close) + closeTestBrowserStreams(t, cold) + coldContext, coldCancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer coldCancel() + command = exec.CommandContext(coldContext, "node", filepath.Join(root, "tools/client/test_bau_cyber_cold.mjs"), coldHost.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 @@ -42,6 +42,14 @@ - [85655, 22104] - [85711, 22014] - [85712, 22010] +# Regular Bau Cyber armor: original descriptor audit; docs/bau-cyber-armor.md. +- [85530, 85529] +- [85571, 85570] +- [85611, 85610] +- [85654, 85653] +- [85708, 85707] +- [85710, 85709] +- [85759, 85758] # Regular recovery supplies, QL1..200: docs/medical-quality.md. - [25812, 25811] - [85366, 85367] diff --git a/server/gamedata/item_quality_test.go b/server/gamedata/item_quality_test.go @@ -19,6 +19,8 @@ func TestReviewedItemFamilyQualityRanges(t *testing.T) { {85645, 85644, 1, 200}, {85697, 85696, 1, 200}, {85750, 85749, 1, 200}, {85477, 21917, 1, 200}, {85531, 22289, 1, 200}, {85572, 22219, 1, 200}, {85612, 22166, 1, 200}, {85655, 22104, 1, 200}, {85711, 22014, 1, 200}, {85712, 22010, 1, 200}, + {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}, } { for _, template := range [2]uint32{family.lowTemplate, family.highTemplate} { @@ -45,7 +47,7 @@ func TestUnreviewedItemQualityRemainsExact(t *testing.T) { for _, entry := range []struct { template, quality uint32 supported bool - }{{209283, 1, true}, {209283, 2, false}, {85557, 0, false}, {4294967295, 1, false}} { + }{{209283, 1, true}, {209283, 2, false}, {85557, 0, false}, {161966, 200, true}, {161966, 199, 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/tools/client/test_bau_cyber_armor.mjs b/tools/client/test_bau_cyber_armor.mjs @@ -0,0 +1,205 @@ +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); +assert(url && output, 'Run through TestBrowserBauCyberArmorQualities'); +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']}); +const games = []; + +async function bagClick(game, id) { + await game.wait('native 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, 'Fixture item is outside its visible inventory cells'); + const cell = item.slot - 48; + await game.click(681 + cell % 3 * 54, 45 + Math.floor(cell / 3) * 54, 'right'); +} + +try { + for (const token of ['bau-cyber-owner', 'bau-cyber-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.equal(owner.local().id, 1); + assert.equal(observer.local().id, 2); + const state = async () => (await owner.page.request.get(url + '/test-state')).json(); + const baseline = await state(); + const watched = observer.local().inventory; + assert.equal(baseline.inventory.Items.length, 11); + assert.deepEqual(baseline.armor, [32, 32, 30, 10, 26, 28, 10, 28]); + 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.wait('native armor stats window', state => state.regions.some( + ([left, top, right, bottom]) => left === 832 && top === 380 && right === 1024 && bottom === 606)); + await owner.save(output + '/initial-set'); + await observer.save(output + '/observer-initial-set'); + + // Remove and re-wear every initial piece, retaining each sleeve independently. + for (const [id, slot, x, y, armor] of [ + [1, 18, 927, 94, [7, 7, 6, 2, 5, 6, 2, 6]], + [2, 27, 927, 262, [6, 6, 6, 2, 5, 5, 2, 5]], + [3, 30, 927, 316, [3, 3, 3, 1, 2, 2, 1, 2]], + [4, 23, 867, 206, [2, 2, 2, 1, 2, 2, 1, 2]], + [5, 25, 987, 206, [2, 2, 2, 1, 2, 2, 1, 2]], + [6, 24, 927, 206, [2, 2, 2, 1, 2, 2, 1, 2]], + [7, 21, 927, 148, [10, 10, 9, 2, 8, 9, 2, 9]], + ]) { + 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])); + await owner.save(output + '/removed-' + id); + if (slot === 23) { + // Explicit placement keeps the other sleeve in its own arm. + await owner.wait('native inventory actions finish', state => + !owner.local(state).actions.includes(3) && !owner.local(state).actions.includes(6)); + const item = owner.local().inventory.find(item => item.id === id); + const cell = item.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 re-worn', state => owner.local(state).inventory.some(item => item.id === id && item.slot === slot)); + await observer.wait('observer receives worn piece', () => 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 + '/worn-' + id); + await observer.save(output + '/observer-worn-' + id); + } + console.log('PASS: all seven worn pieces remove/re-wear, with independent sleeves'); + + // Wear an intermediate quality stored at the high endpoint, then reject equality at QL101. + await owner.click(927, 206, 'right'); + await owner.wait('QL2 gloves retained in inventory', state => owner.local(state).inventory.some(item => item.id === 6 && item.slot >= 48)); + await bagClick(owner, 9); + await owner.wait('QL100 gloves worn', state => owner.local(state).inventory.some(item => item.id === 9 && item.slot === 24)); + assert.deepEqual((await state()).armor, [155, 155, 137, 34, 102, 120, 34, 120]); + await owner.save(output + '/quality-100'); + await owner.click(927, 206, 'right'); + await owner.wait('QL100 gloves retained in inventory', state => owner.local(state).inventory.some(item => item.id === 9 && item.slot >= 48)); + const untrained = await state(); + const untrainedAttempt = owner.sequence; + await bagClick(owner, 10); + await owner.save(output + '/quality-101-rejected'); + assert(!owner.events.some(event => event.sequence > untrainedAttempt && + event.direction === 'framesent' && event.opcode === '47537a24'), 'Native requirements admitted unqualified gloves'); + const rejected = await state(); + assert.deepEqual(rejected.inventory, untrained.inventory); + assert.equal(rejected.pending, false); + assert(owner.local().inventory.some(item => item.id === 10 && item.slot >= 48)); + + // Train both strict ability thresholds through the original skill window. + 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, 256); + await owner.click(835, 316); + await owner.click(445, 622); + await owner.wait('one trained ability point each', state => owner.local(state).stats[21] === 239 && + owner.local(state).stats[19] === 264 && owner.local(state).stats[53] === 1499); + await bagClick(owner, 10); + await owner.wait('QL101 gloves worn after training', state => owner.local(state).inventory.some(item => item.id === 10 && item.slot === 24)); + assert.deepEqual((await state()).armor, [156, 156, 138, 35, 103, 120, 35, 120]); + await owner.page.keyboard.press('Control+1'); + await owner.click(953, 53); + await owner.page.keyboard.press('Control+9'); + await owner.wait('trained native armor stats window', state => state.regions.some( + ([left, top, right, bottom]) => left === 832 && top === 380 && right === 1024 && bottom === 606)); + await owner.save(output + '/quality-101-trained'); + const beforeHigh = await state(); + const highAttempt = owner.sequence; + await bagClick(owner, 11); + await owner.save(output + '/quality-200-rejected'); + assert(!owner.events.some(event => event.sequence > highAttempt && + event.direction === 'framesent' && event.opcode === '47537a24'), 'Native requirements admitted QL200 gloves'); + assert.deepEqual((await state()).inventory, beforeHigh.inventory); + + // Retain the original body instance while wearing the other authored style. + await owner.click(927, 148, 'right'); + await owner.wait('original body retained', state => owner.local(state).inventory.some(item => item.id === 7 && item.slot >= 48)); + await bagClick(owner, 8); + await owner.wait('alternate body style worn', state => owner.local(state).inventory.some(item => item.id === 8 && item.slot === 21)); + assert.deepEqual((await state()).armor, [156, 156, 138, 35, 103, 120, 35, 120]); + await owner.save(output + '/vest'); + + // Cancel and accept the exact QL100 sale through the original basic armor machine. + await owner.page.keyboard.press('Control+1'); + await owner.page.keyboard.press('Control+9'); + if (!owner.state.camera.firstPerson) await owner.key('F8'); + let offerState = 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('original armor shop open', state => state.regions.some( + ([left, top, right, bottom]) => left === 832 && top === 0 && right === 1024 && bottom === 494)); + const item = owner.local().inventory.find(item => item.id === 9); + const cell = item.slot - 48; + await owner.click(681 + cell % 3 * 54, 45 + Math.floor(cell / 3) * 54); + const offered = owner.sequence; + await owner.click(864, 416); + await owner.wait('exact native sale offered', () => owner.events.some(event => + event.sequence > offered && event.direction === 'framesent' && event.opcode === '36284f6e')); + assert.deepEqual((await state()).inventory, offerState.inventory); + await owner.save(output + '/sale-offer-' + attempt); + if (attempt === 0) { + await owner.click(945, 475); + await owner.wait('cancel restores QL100 identity in the first free cell', state => owner.local(state).inventory.some(item => item.id === 9 && item.slot === 48)); + const cancelled = await state(); + assert.deepEqual(cancelled.inventory, {...offerState.inventory, + Items: offerState.inventory.Items.map(item => item.ID === 9 ? {...item, Slot: 64} : item)}); + offerState = cancelled; + await owner.save(output + '/sale-cancelled'); + await fs.writeFile(output + '/sale-cancelled/server.json', JSON.stringify(cancelled, null, 2)); + } + } + await owner.click(874, 475); + await owner.wait('selected-quality sale committed', state => owner.local(state).stats[61] === 5380); + const final = await state(); + const slots = {1: 18, 2: 27, 3: 30, 4: 23, 5: 25, 6: 68, 7: 66, 8: 21, 10: 24, 11: 67}; + const expected = baseline.inventory.Items.filter(item => item.ID !== 9).map(item => ({...item, Slot: slots[item.ID]})); + assert.deepEqual(final.inventory.Items, expected); + assert.equal(final.stats.ImprovementPoints, 1499); + assert.deepEqual(final.observer, baseline.observer); + await owner.page.reload(); + await owner.ready(); + assert.equal(owner.local().inventory.length, 10); + for (const item of expected) { + const pair = {85571: [85571, 85570], 85530: [85530, 85529], 85654: [85654, 85653], + 85759: [85759, 85758], 85611: [85611, 85610], 85710: [85710, 85709], 85708: [85708, 85707]}[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.wait('reconnected native armor stats window', state => state.regions.some( + ([left, top, right, bottom]) => left === 832 && top === 380 && right === 1024 && bottom === 606)); + await owner.save(output + '/reconnected'); + await observer.snapshot(); + assert.deepEqual(observer.local().inventory, watched); + for (const game of games) assert.deepEqual(game.errors, []); + await fs.writeFile(output + '/ledger.json', JSON.stringify(final, null, 2)); + console.log('PASS: QL100/101 requirements, alternate body style, exact sale and page ownership'); +} finally { + try { + for (const [index, game] of games.entries()) await game.save(output + '/client-' + index); + } finally { await browser.close(); } +} diff --git a/tools/client/test_bau_cyber_cold.mjs b/tools/client/test_bau_cyber_cold.mjs @@ -0,0 +1,46 @@ +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', + 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 ['bau-cyber-owner', 'bau-cyber-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, 85571, 85570, 1], [2, 27, 2, 85530, 85529, 1], + [3, 30, 2, 85654, 85653, 1], [4, 23, 2, 85759, 85758, 1], + [5, 25, 2, 85759, 85758, 1], [6, 52, 2, 85611, 85610, 1], + [7, 50, 2, 85710, 85709, 1], [8, 21, 2, 85708, 85707, 1], + [10, 24, 101, 85611, 85610, 1], [11, 51, 200, 85610, 85610, 1], + ]); + assert.equal(owner.local().stats[19], 264); + assert.equal(owner.local().stats[21], 239); + assert.equal(owner.local().stats[53], 1499); + assert.equal(owner.local().stats[61], 5380); + 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'); + await owner.wait('cold native armor stats', state => state.regions.some( + ([left, top, right, bottom]) => left === 832 && top === 380 && right === 1024 && bottom === 606)); + assert(games.every(game => game.errors.length === 0)); + console.log('PASS: all ten exact Bau instances, endpoints, slots, trained abilities and sale wallet after cold startup'); +} finally { + try { await Promise.all(games.map((game, id) => game.save(output + '/' + id))); } + finally { await browser.close(); } +} diff --git a/tools/client/test_leather_armor.mjs b/tools/client/test_leather_armor.mjs @@ -63,12 +63,7 @@ try { assert.deepEqual((await state()).armor, baseline.armor.map((value, index) => value - armor[index])); await owner.save(output + '/removed-' + id); if (slot === 23) { - // Native right-click chooses default slot25; explicitly place the other sleeve. - const attempt = owner.sequence; - await bagClick(owner, id); - await owner.wait('occupied default arm correction', () => owner.events.filter(event => - event.sequence > attempt && event.direction === 'framereceived' && event.opcode === '47537a24').length >= 2); - await owner.save(output + '/default-arm-rejected'); + // Explicit placement keeps the other sleeve in its own arm. await owner.wait('native inventory actions finish', state => !owner.local(state).actions.includes(3) && !owner.local(state).actions.includes(6)); const item = owner.local().inventory.find(item => item.id === id);