aorecomp

Anarchy Online classic in the browser

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


commit a36fa454fd3f767efc2005ea02046225f3b4eff6
parent 59405ade33d574d7478c17d4690ba6198edd6c09
Author: anon <anon@example.com>
Date:   Thu,  5 Nov 2026 22:57:03 +0000

Give starter Clan lizards combat rewards and lifecycle

Diffstat:
MTODO.md | 13++++++++++---
Mdocs/alpha-item-recovery.md | 45++++++++++++++++++++++++++++++++++++++++-----
Mdocs/starter-fauna.md | 36++++++++++++++++++++++++++++++++++++
Dserver/browser_snake_corpse_test.go | 91-------------------------------------------------------------------------------
Aserver/browser_training_corpses_test.go | 111+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/gamedata/npc_combat.yaml | 24++++++++++++++++++++++++
Mserver/npc_shared_pursuit_test.go | 3++-
Mserver/starter_fauna_test.go | 9+++++++--
Dtools/client/test_snake_corpse.mjs | 44--------------------------------------------
Atools/client/test_training_corpses.mjs | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 295 insertions(+), 146 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -148,9 +148,10 @@ research separately. More screenshots and test cases do not count as new gamepla not the remaining corpse coverage. November 5: the [ordinary-action matrix](docs/alpha-item-recovery.md) now maps exact-state, rejected-write/retry and native reconnect/cold evidence for these actions. - An original Giant Snake placement also passes visible native corpse picking, - loot transfer, reconnect and database recovery. The matrix lists the remaining - early-route body checks; living appearance coverage alone does not close them. + Original Giant Snake, Reet, Malle and both Clan lizard populations pass visible + native corpse picking, loot transfer, reconnect and database recovery. The + matrix lists remaining body checks and their A7 encounter dependencies; + living appearance coverage alone does not close them. - [ ] **A7: All-faction early-game loop through levels 1-10.** Name the finite training/hunting routes, starter/basic shops, supported mission encounters @@ -167,6 +168,12 @@ research separately. More screenshots and test cases do not count as new gamepla November 5: generated offers and recovered journals now advertise zero completion XP, matching hand-in; cash and selected items remain payable. Keep a compact matrix of passed paths and specific remaining failures. + The A6 corpse check also reproduced missing combat rewards and lifecycle on + the Clan Green Lizard. LZ01/LZ02 now have an explicit provisional level-1..4 + profile using the original LizardBite weapon; see [starter fauna](docs/starter-fauna.md). + Blubbag and the five distinct Neutral creature bodies still lack profiles, + as does the Clan ROLL population (the separate RR01 Rollerrats are supported). + The six human opponent populations remain appearance-only combat scope. - [x] **A8: Isolate administration before public hosting.** The current HTTP and HTTPS listeners share a handler. Administration now requires separate diff --git a/docs/alpha-item-recovery.md b/docs/alpha-item-recovery.md @@ -50,14 +50,24 @@ relevant placement check. | Route | Corpse evidence established | Remaining body checks | | --- | --- | --- | -| Omni training | Leet (17655), Giant Snake (30252), Tiny Stalker (17708), Aquaan (30369) | Reet (30365), Malle (17660) | -| Clan training | Shared species use the evidence above | Grecko (22794), Rollerrat (17687), Blubbag (40075), Salamander (30354) | +| Omni training | Leet (17655), Giant Snake (30252), Tiny Stalker (17708), Aquaan (30369), Reet (30365), Malle (17660) | None in this finite creature list | +| Clan training | Green Lizard / Grecko (22794), plus shared species above | Rollerrat (17687), Blubbag (40075), Salamander (30354) | | Neutral training | Shared species use the evidence above | Android (17649), Biofreak (30258), Clawfinger (38387), Eye Mutant (17653), Blackout (45873) | The six clothed human opponent populations also have living-body evidence only -in A3. Their remains need a representative native check of the shared humanoid -corpse/equipment path when admitted to the selected combat route; living outfit -inspection alone must not be reported as corpse evidence. +in A3. The combat handler currently admits creature appearances only, so the +human encounter contract is A7 work before humanoid corpse/equipment checks. +Living outfit inspection alone must not be reported as corpse evidence. + +The November 5 Clan run exposed a content dependency: LZ01 had no combat +profile, so its death generated no rewards, expiry or respawn. LZ01/LZ02 are now +admitted under the explicit [starter lizard policy](starter-fauna.md#clan-lizard-admission-november-5). +The other remaining profile gaps are Blubbag, all five distinct Neutral bodies, +and Clan ROLL. The separate RR01 Rollerrat population has a supported profile; +the representative ROLL placement selected for A3 does not inherit it. Record +these as A7 content gaps rather than seeding loot into unsupported encounters +and claiming ordinary corpse coverage. Salamander and RR01 corpse checks can +proceed with their existing profiles. The remaining check is small: reach a fresh corpse through controlled combat at an original route placement, inspect its recognizable body, use native picking @@ -85,3 +95,28 @@ Evidence is under `local/alpha-snake-corpse/20261105-144656/`, with the run log `local/alpha-snake-corpse/native.log`. The browser and temporary server are closed by the fixture even on failure. This change adds coverage and the A6 map; it changes no gameplay behavior and does not close A6. + +### Further route checks and lizard fix + +`TestBrowserTrainingCorpses` reuses the Snake fixture for the Reet, Malle and +both original Clan lizard populations. The shared runner is now +`tools/client/test_training_corpses.mjs`; the Snake test remains available. +Ordinary mouse-look frames corpses above chat on slopes. The fixture also +requires the death to schedule expiry and respawn. + +| Capture under `local/alpha-training-corpses/` | Original population | Result | +| --- | --- | --- | +| `20261105-145123/950/district/2/group/1/authored_point/` | Reet | Visible body, native pickup, reconnect and cold ownership | +| `20261105-145141/950/district/4/group/1/authored_point/` | Malle | Visible body, native pickup, reconnect and cold ownership | +| `20261105-145458/952/district/0/group/1/authored_point/` | Green Lizard LZ01 | Same checks after adding the missing combat profile | +| `20261105-145512/952/district/2/group/1/authored_point/` | Grecko LZ02 | Same checks after adding the missing combat profile | + +The Omni checks passed in 32.91 seconds (`omni.log`); the lizard checks passed +in 31.04 seconds (`lizards-native.log`). Each transfers its generated Monster +Parts instance and exactly one credit, then verifies the emptied source and +exact destination after reconnect and a fresh database load. Images were +inspected, not inferred from a successful pick alone. The original failure is +retained in `clan-diagnostic.log`. Lizard behavior changes are documented in +the fauna policy; Reet and Malle required no gameplay change. A6 remains open. +The retained Snake scenario also passed with the shared runner in 13.69 seconds +(`snake-shared.log`, capture `20261105-145639/`). diff --git a/docs/starter-fauna.md b/docs/starter-fauna.md @@ -5,6 +5,7 @@ | Rollerrat 17687 | RR01 | 1..2 | Faceroll 121050/121051 | | Giant Snake 30252 | SN01, SN02 | 1..4 | GiantserpentBite 120846/120847 | | Malle 17660 | ML01 | 1..4 | MalleBite 120922/120923 | +| Green Lizard / Grecko 22794 | LZ01, LZ02 | 1..4 | LizardBite 125277/125278 | These are bounded profiles for the existing inferred species bindings. Names, bodies, authored levels, positions and confidence remain unchanged. Matching @@ -64,6 +65,41 @@ is added. ## Verification +### Clan lizard admission (November 5) + +The A6 corpse check reproduced a missing A7 encounter contract at +`952/district/0/group/1/authored_point`: the Green Lizard died with an empty +corpse, zero credits and no expiry or respawn deadline because it had no combat +profile. This also omitted its solo XP and ordinary profile-driven retaliation. +The three LZ01 positions and five LZ02 positions now use the bounded profile +above. LZ01 retains its authored level 1; LZ02 retains levels 1..4. Other codes, +placeholder bodies and levels above 4 do not inherit it. + +The original item records in `server/gamedata/items/items_044.yaml` identify +125277/125278 as LizardBite QL1/400. QL1 uses MA100 against Evade Close155, +MeleeAC91, range 2, damage 6..12, critical bonus 6 and 235-centisecond +attack/recharge phases. Bite rather than Breath is an explicit provisional +choice. HP, XP, raw ratings, cash, Monster Parts probabilities/quality, 100-second +respawn and 180-second corpse lifetime use the existing starter policy. These +choices do not claim recovery of the original complete lizard templates. + +The maintained fauna regressions now include both original populations, all +four profile levels, cold admission, rejected identities, native weapon fields, +damage/timing and rewards through six killing actions. Shared pursuit/return +checks include all four levels. The native corpse fixture uses a controlled +one-hit checkpoint at the original positions, not earned progression. + +The focused run passed 38 roots / 295 results, including failed-write/retry, +respawn and corpse-placement regressions. Gamedata tests and server/gamedata +vet passed. Both lizard populations passed native corpse picking, exact generated +loot/cash transfer, reconnect and database recovery in 31.04 seconds. The bodies +were also visually inspected. Logs are under `local/alpha-training-corpses/`; +[the A6 map](alpha-item-recovery.md#further-route-checks-and-lizard-fix) records +the individual capture paths and remaining encounters. Ordinary earned combat +balance and affordability remain A7 acceptance work. + +### Earlier fauna verification + Public-handler tests cover all six starter groups, selected levels and weapon endpoints, cold restoration, code/body/evidence/range rejection, original attack phases and selected-quality damage. Six direct killing actions cover every diff --git a/server/browser_snake_corpse_test.go b/server/browser_snake_corpse_test.go @@ -1,91 +0,0 @@ -package main - -import ( - "context" - "crypto/sha256" - "encoding/json" - "fmt" - "net/http" - "net/http/httptest" - "os" - "os/exec" - "path/filepath" - "reflect" - "runtime" - "testing" - "time" -) - -func TestBrowserTrainingSnakeCorpse(t *testing.T) { - if os.Getenv("AO_GAME_TEST") != "1" { - t.Skip("set AO_GAME_TEST=1 for the original training Snake corpse") - } - _, source, _, _ := runtime.Caller(0) - root := filepath.Dir(filepath.Dir(source)) - output := filepath.Join(root, "local/alpha-snake-corpse", time.Now().Format("20060102-150405")) - world := newTestServer(t) - var target *character - for _, actor := range world.characters { - if actor.npcDefinitionID == "950/district/1/group/2/authored_point" && (target == nil || actor.id < target.id) { - target = actor - } - } - if target == nil { - t.Fatal("missing original Snake population") - } - player := world.newCharacter() - player.position = target.position - player.position[2]++ - player.rotation = [4]float32{0, 1, 0, 0} - player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("snake-corpse"))) - if err := world.saveUser_locked(player); err != nil { - t.Fatal(err) - } - - // Reach a fresh corpse through the combat handler without earning progression. - target.health = 1 - world.combatRoll = func(uint32) uint32 { return 0 } - world.clients[1] = &worldClient{id: 1, ready: true, target: true, conn: &combatTestConn{}, npcs: map[uint32]bool{target.id: true}} - if err := world.handleCombat(world.clients[1], attackPacket(1, target.id)[20:]); err != nil { - t.Fatal(err) - } - world.advanceCombat(player.nextAttack) - if target.corpse == nil || len(target.corpse.items) != 1 { - t.Fatal("controlled attack did not produce one corpse item") - } - item, credits := target.corpse.items[0], target.corpse.credits - delete(world.clients, 1) - player.position[2] = target.position[2] + 4 - player.position[1], _ = world.terrain[player.playfield].elevation(player.position[0], player.position[2]) - player.position[1] += .2 - if err := world.saveUser_locked(player); 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(map[string]any{"target": target.id, "position": target.position, "items": target.corpse.items, - "credits": target.corpse.credits, "inventory": player.inventory}) - }) - host := httptest.NewServer(mux) - defer host.Close() - defer closeTestSessions(t, world) - ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) - defer cancel() - command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_snake_corpse.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) - item.Slot = 64 - if !reflect.DeepEqual(cold.characters[1].inventory.Items, []ownedItem{item}) || cold.characters[1].inventory.Credits != credits || - len(cold.characters[target.id].corpse.items) != 0 || cold.characters[target.id].corpse.credits != 0 { - t.Fatal("native corpse pickup changed exact ownership after cold load") - } -} diff --git a/server/browser_training_corpses_test.go b/server/browser_training_corpses_test.go @@ -0,0 +1,111 @@ +package main + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "reflect" + "runtime" + "testing" + "time" +) + +func TestBrowserTrainingSnakeCorpse(t *testing.T) { + testBrowserTrainingCorpse(t, "950/district/1/group/2/authored_point") +} + +func TestBrowserTrainingCorpses(t *testing.T) { + for _, route := range []string{ + "950/district/2/group/1/authored_point", "950/district/4/group/1/authored_point", + "952/district/0/group/1/authored_point", "952/district/2/group/1/authored_point", + } { + t.Run(route, func(t *testing.T) { testBrowserTrainingCorpse(t, route) }) + } +} + +func testBrowserTrainingCorpse(t *testing.T, route string) { + t.Helper() + if os.Getenv("AO_GAME_TEST") != "1" { + t.Skip("set AO_GAME_TEST=1 for original training corpses") + } + _, source, _, _ := runtime.Caller(0) + root := filepath.Dir(filepath.Dir(source)) + output := filepath.Join(root, "local/alpha-training-corpses", time.Now().Format("20060102-150405"), route) + world := newTestServer(t) + var target *character + for _, actor := range world.characters { + if actor.npcDefinitionID == route && (target == nil || actor.id < target.id) { + target = actor + } + } + if target == nil { + t.Fatal("missing original training population") + } + player := world.newCharacter() + player.playfield, player.position = target.playfield, target.position + player.position[2]++ + player.rotation = [4]float32{0, 1, 0, 0} + player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("training-corpse"))) + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + + // Reach a fresh corpse through the combat handler without earning progression. + target.health = 1 + world.combatRoll = func(uint32) uint32 { return 0 } + world.clients[1] = &worldClient{id: 1, ready: true, target: true, conn: &combatTestConn{}, npcs: map[uint32]bool{target.id: true}} + if err := world.handleCombat(world.clients[1], attackPacket(1, target.id)[20:]); err != nil { + t.Fatal(err) + } + world.advanceCombat(player.nextAttack) + if target.corpse == nil || len(target.corpse.items) != 1 { + t.Fatalf("controlled attack did not produce one corpse item: health=%d corpse=%+v player=%v target=%v appearance=%d range=%v visible=%v", + target.health, target.corpse, player.position, target.position, target.appearance, + world.combatInRange_locked(player, target, time.Now()), world.combatVisible_locked(player, target, time.Now())) + } + if target.corpse.expiresAt.IsZero() || len(world.npcRespawns) != 1 { + t.Fatal("training death did not schedule corpse expiry and respawn") + } + item, credits := target.corpse.items[0], target.corpse.credits + delete(world.clients, 1) + player.position[2] = target.position[2] + 4 + player.position[1], _ = world.terrain[player.playfield].elevation(player.position[0], player.position[2]) + player.position[1] += .2 + if err := world.saveUser_locked(player); 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(map[string]any{"target": target.id, "name": target.name, "monster": target.monsterData, "route": route, + "position": target.position, "items": target.corpse.items, + "credits": target.corpse.credits, "inventory": player.inventory}) + }) + host := httptest.NewServer(mux) + defer host.Close() + defer closeTestSessions(t, world) + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cancel() + command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_training_corpses.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) + item.Slot = 64 + if !reflect.DeepEqual(cold.characters[1].inventory.Items, []ownedItem{item}) || cold.characters[1].inventory.Credits != credits || + len(cold.characters[target.id].corpse.items) != 0 || cold.characters[target.id].corpse.credits != 0 { + t.Fatal("native corpse pickup changed exact ownership after cold load") + } +} diff --git a/server/gamedata/npc_combat.yaml b/server/gamedata/npc_combat.yaml @@ -253,6 +253,30 @@ quality: [3, 5] chance: 50 +22794: + 1: &starter_lizard + <<: *starter_snake + # Original Clan training LZ01/LZ02 populations use the inferred Green Lizard body. + template_codes: [LZ01, LZ02] + # Original LizardBite endpoints; choosing Bite instead of Breath is provisional. + # Health, skills, XP, loot and lifecycle retain the provisional starter baseline. + weapon: [125277, 125278] + 2: + <<: *starter_lizard + loot: + - template: 42640 + quality: [1, 3] + chance: 50 + 4: + <<: *starter_lizard + health: 150 + experience: 150 + skills: {100: 15, 153: 15, 154: 15, 155: 15, 168: 15} + loot: + - template: 42640 + quality: [3, 5] + chance: 50 + 30369: 4: # Only the authored Omni Training BNMO uses this level/body/code combination. diff --git a/server/npc_shared_pursuit_test.go b/server/npc_shared_pursuit_test.go @@ -13,7 +13,8 @@ func TestAdmittedNPCProfilesSharePursuitAndReturn(t *testing.T) { monster uint32 level uint16 }{{17655, 1}, {17655, 2}, {30365, 1}, {30365, 2}, {17708, 2}, {17708, 3}, {17708, 4}, {30354, 4}, - {17687, 1}, {17687, 2}, {30252, 1}, {30252, 2}, {30252, 3}, {30252, 4}, {17660, 1}, {17660, 2}, {17660, 3}, {17660, 4}} { + {17687, 1}, {17687, 2}, {30252, 1}, {30252, 2}, {30252, 3}, {30252, 4}, {17660, 1}, {17660, 2}, {17660, 3}, {17660, 4}, + {22794, 1}, {22794, 2}, {22794, 3}, {22794, 4}} { for _, roaming := range []bool{false, true} { t.Run(fmt.Sprintf("%d/%d/roaming=%t", profile.monster, profile.level, roaming), func(t *testing.T) { world, _, start := newNPCPursuitWorld(t) diff --git a/server/starter_fauna_test.go b/server/starter_fauna_test.go @@ -17,6 +17,8 @@ func TestStarterFaunaPopulationsRecoverProfilesAndNativeWeapons(t *testing.T) { levels []uint16 damage [][2]uint32 }{ + {"952/district/0/group/1/authored_point", 22794, [2]uint32{125277, 125278}, []uint16{1, 1, 1}, [][2]uint32{{6, 12}, {6, 12}, {6, 12}}}, + {"952/district/2/group/1/authored_point", 22794, [2]uint32{125277, 125278}, []uint16{1, 2, 3, 4, 1}, [][2]uint32{{6, 12}, {6, 13}, {7, 15}, {7, 16}, {6, 12}}}, {"952/district/4/group/2/authored_point", 17687, [2]uint32{121050, 121051}, []uint16{1, 2}, [][2]uint32{{6, 12}, {7, 14}}}, {"950/district/1/group/2/authored_point", 30252, [2]uint32{120846, 120847}, []uint16{1, 2, 1, 2}, [][2]uint32{{6, 12}, {6, 13}, {6, 12}, {6, 13}}}, {"950/district/2/group/2/authored_point", 30252, [2]uint32{120846, 120847}, []uint16{1}, [][2]uint32{{6, 12}}}, @@ -62,7 +64,7 @@ func TestStarterFaunaRejectsUnreviewedCodesBodiesEvidenceAndLevels(t *testing.T) code string monster uint32 outside uint16 - }{{"RR01", 17687, 3}, {"SN01", 30252, 5}, {"SN02", 30252, 5}, {"ML01", 17660, 5}} { + }{{"RR01", 17687, 3}, {"SN01", 30252, 5}, {"SN02", 30252, 5}, {"ML01", 17660, 5}, {"LZ01", 22794, 5}, {"LZ02", 22794, 5}} { for _, change := range []string{"code", "body", "placeholder", "level"} { t.Run(species.code+"/"+change, func(t *testing.T) { data := testNPCData() @@ -99,7 +101,8 @@ func TestStarterFaunaCombatUsesOriginalDamageAndTiming(t *testing.T) { code string monster uint32 phase time.Duration - }{{"RR01", 17687, 3200 * time.Millisecond}, {"SN01", 30252, 2350 * time.Millisecond}, {"SN02", 30252, 2350 * time.Millisecond}, {"ML01", 17660, 2350 * time.Millisecond}} { + }{{"RR01", 17687, 3200 * time.Millisecond}, {"SN01", 30252, 2350 * time.Millisecond}, {"SN02", 30252, 2350 * time.Millisecond}, {"ML01", 17660, 2350 * time.Millisecond}, + {"LZ01", 22794, 2350 * time.Millisecond}, {"LZ02", 22794, 2350 * time.Millisecond}} { t.Run(scenario.code, func(t *testing.T) { data := testNPCData() group := &data.Playfields[0].Districts[0].Groups[0] @@ -143,6 +146,8 @@ func TestStarterFaunaDeathsRetainSharedRewardsAcrossKillingActions(t *testing.T) quality uint32 xp uint32 }{ + {"952/district/0/group/1/authored_point", 22794, 1, 1, 100}, + {"952/district/2/group/1/authored_point", 22794, 4, 5, 150}, {"952/district/4/group/2/authored_point", 17687, 1, 1, 100}, {"952/district/4/group/2/authored_point", 17687, 2, 3, 100}, {"950/district/1/group/2/authored_point", 30252, 1, 1, 100}, diff --git a/tools/client/test_snake_corpse.mjs b/tools/client/test_snake_corpse.mjs @@ -1,44 +0,0 @@ -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: 'snake-corpse', url}]); - const page = await context.newPage(); - game = await GameTest.attach(page); - const server = async () => (await page.request.get(url + '/test-state')).json(); - await page.goto(url); - await game.ready(); - if (!game.state.camera.firstPerson) await game.key('F8'); - evidence.before = await server(); - await game.save(output + '/corpse'); - await game.click(...await game.pick(51050, evidence.before.target), 'right'); - await game.wait('original Snake loot appears', state => state.grids.some(grid => grid.cells.some(cell => cell.identity[0] === 107 && !cell.dummy))); - await game.save(output + '/loot'); - await game.click(30, 45); - await game.waitFor('exact original loot collected', async () => (await server()).items.length === 0); - evidence.collected = await server(); - assert.deepEqual(evidence.collected.inventory.Items, [{...evidence.before.items[0], Slot: 64}]); - assert.equal(evidence.collected.inventory.Credits, evidence.before.credits); - await page.reload(); - await game.ready(); - evidence.reconnected = await server(); - assert.deepEqual(evidence.reconnected.inventory, evidence.collected.inventory); - assert.deepEqual(game.errors, []); - console.log('PASS: training Snake corpse visible, picked and retained exact loot through reconnect'); -} 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(); } -} diff --git a/tools/client/test_training_corpses.mjs b/tools/client/test_training_corpses.mjs @@ -0,0 +1,65 @@ +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: 'training-corpse', url}]); + const page = await context.newPage(); + game = await GameTest.attach(page); + const server = async () => (await page.request.get(url + '/test-state')).json(); + await page.goto(url); + await game.ready(); + if (!game.state.camera.firstPerson) await game.key('F8'); + evidence.before = await server(); + // Aim above chat even when the original placement is on steep terrain. + const cameraPoint = await game.point(512, 300); + let mouseY = cameraPoint.y, sequence = game.sequence; + await game.page.mouse.move(cameraPoint.x, mouseY); + await game.page.mouse.down({button: 'right'}); + try { + await game.waitInput(sequence, 1025); + const deadline = Date.now() + 10000; + for (;;) { + await game.snapshot(); + const y = game.state.actors.find(actor => actor.type === 51050 && actor.id === evidence.before.target).screenPosition[1]; + if (y >= 500 && y <= 600) break; + assert(Date.now() < deadline, 'Camera did not frame the corpse above chat'); + mouseY += y > 600 ? 20 : -20; + await game.page.mouse.move(cameraPoint.x, mouseY, {steps: 2}); + } + } finally { + sequence = game.sequence; + await game.page.mouse.up({button: 'right'}); + } + await game.waitInput(sequence, 1026); + await game.save(output + '/corpse'); + await game.click(...await game.pick(51050, evidence.before.target), 'right'); + await game.wait('original training loot appears', state => state.grids.some(grid => grid.cells.some(cell => cell.identity[0] === 107 && !cell.dummy))); + await game.save(output + '/loot'); + await game.click(30, 45); + await game.waitFor('exact original loot collected', async () => (await server()).items.length === 0); + evidence.collected = await server(); + assert.deepEqual(evidence.collected.inventory.Items, [{...evidence.before.items[0], Slot: 64}]); + assert.equal(evidence.collected.inventory.Credits, evidence.before.credits); + await page.reload(); + await game.ready(); + evidence.reconnected = await server(); + assert.deepEqual(evidence.reconnected.inventory, evidence.collected.inventory); + assert.deepEqual(game.errors, []); + console.log('PASS:', evidence.before.route, 'corpse picked and retained exact loot through reconnect'); +} 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(); } +}