commit 42e5cf94f29101c7ce1f5ea77aa42064d6f78b0f
parent 99b6686f8f5ec6ca0fa98ee58a1e5835ff4f677c
Author: anon <anon@example.com>
Date: Tue, 3 Nov 2026 18:20:52 +0000
Generate seeded two-room starter mission orientations
Diffstat:
13 files changed, 407 insertions(+), 12 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -2551,8 +2551,14 @@ client rendering fixes and checks are in [nano damage](docs/nano-damage.md).
keys held elsewhere. Current immediate bound-key deletion on abandonment is
provisional; original client journal behavior does not prove server key policy.
Preserve the documented distinction between period and later secondary evidence.
-- [ ] [P1] Generate one two-room mission layout. Check: a fixed test seed produces
- connected rooms with a reachable entrance, objective and exit.
+- [x] [P1] Generate one two-room mission layout. Fixed seeds now select north/south
+ orientations of the reviewed original room0/room37 pair. Encounter positions
+ rotate with the building; public acceptance/entry/cold checks retain the exact
+ seed, generator, connected passage, entrance, objective and five NPCs. All five
+ rotated encounters admit ordinary shots. A short controlled WASM route enters,
+ reconstructs the chamber after page reload, collects the exact book, visits
+ the far room and exits. Selection is explicitly provisional; broader original
+ ACG/style rules remain below. See [seeded layouts](docs/mission-generation.md).
- [ ] [P1] Apply difficulty and all six mission dimensions to generated content.
Difficulty now selects a provisional level/QL; the six dimensions are validated
and echoed, but the layout, objective and species remain fixed. Recover their
@@ -4517,6 +4523,13 @@ and server restarts. Turn every reproduced bug into a focused regression test.
and cold restart. This advances the connected gate without completing its
repeatable fresh-character, death/reclaim and next-level coverage. See
[earned creature upgrades](docs/earned-creature-upgrade.md).
+- [ ] [P2] Fix low-speed fractional final approaches in `GameTest.walk`.
+ A controlled Run Speed5 mission route stalls at Z13.99 when targeting14.5;
+ continuous native W crosses the same boundary. Short final-approach pulses
+ also stall at30.99 for31.5. Check fractional/integer destinations at low and
+ ordinary speeds without bypassing collision or losing wall-stall detection.
+ Evidence: `local/mission-generation/native-candidate-ticked.log`,
+ `native-held-route.log` and their retained traces.
- [ ] [P2] Audit native input across focus transitions and rapid target changes.
Cover leaving/returning to the tab, opening/closing options or chat, held
keys/modifiers, repeats, reconnect and slow frames. Compare the first input
diff --git a/docs/mission-generation.md b/docs/mission-generation.md
@@ -0,0 +1,71 @@
+# Seeded two-room starter missions
+
+Accepted starter missions now use their advertised seed to choose a north- or
+south-facing two-room building. Previously every seed saved the same north-facing
+layout. Both orientations use original resource331, room0 (`tarm_entrance1`)
+and room37 (`tarm_hartchamber2`), with one reciprocal passage and one exterior
+portal. Even seeds select north; odd seeds select south. This selection is a
+reconstruction policy, not the recovered original ACG distribution.
+
+The south-facing layout rotates the complete reviewed building through180
+degrees. Its authored encounter positions rotate with it: X becomes40-X and
+Z becomes60-Z. Profiles, levels, rewards, NPC identities and counts are unchanged.
+The shared scene computes the entrance, door and objective from the selected
+portals and actual floor. No separate per-orientation door or book position is
+introduced. The full generator blob commits with acceptance and remains the
+authority on reload; loading does not reroll from the seed.
+
+## Original evidence
+
+The complete original resource331 reparses to the existing independent room
+catalog. Selected original room SHA256 values:
+
+- Room0: `ae977d538be770597edd8746d652420f3574097ae271ec09e7217969d3e08d03`.
+- Room37: `54d541149cd1e116692192f433d9485fc3e3141f65aa546c950c9464917cc642`.
+
+The existing native portal/rotation checks cover all four orientations, including
+the exact south-facing placement used here. See
+[interior evidence](mission-interiors.md) and
+`TestMissionWorldRegistersOriginalPortalLinksAtEveryRotation`.
+The retained complete reparse is `local/mission-generation/original-rooms.json`.
+
+Room36 (`tarm_hartchamber1`) was also investigated. Its portal can connect and
+its floor samples admit the old encounter coordinates, but clear-shot checks
+reject two of those positions. Floor membership alone is insufficient evidence
+for reusing encounter placements. It remains outside this generator; the
+candidate audit and native probes are retained locally. Broader room/style
+selection and the six mission dimensions remain separate open work.
+
+## Focused checks
+
+`TestMissionSeedSelectsConnectedTwoRoomLayoutAndRetainsItsContents` accepts four
+fixed seeds through public handlers, enters with the allocated key, and reloads
+the database. It checks the exact selected chamber placement, saved seed/blob,
+connected passage, reachable entrance/objective and five persisted encounters.
+`TestMissionGeneratedChamberKeepsExistingEncountersReachable` checks an ordinary
+shot at each of the five rotated encounter placements. The concurrent-owner
+regression now explicitly uses equal seeds while retaining distinct worlds,
+keys and native doors.
+
+`TestBrowserGeneratedMission` uses a controlled accepted seed1 contract and
+trainable Run Speed5. Real input enters through the original backyard door,
+crosses the raised entrance, reaches the second room, reconstructs it after a
+page reload, picks up its exact book, visits the far room and returns outside.
+The native anonymous ordinary proxy is checked separately from its physical
+server ID. This geometry fixture does not earn progression or establish
+historical species, reward or room-selection distributions.
+
+The final native run `local/mission-generation/20261103-101536` passes in59.98s
+(Go67.665s). Five traces have no errors or dropped events. Its stopped SQLite
+snapshot retains seed1, the exact31-byte south-facing generator, world65536,
+objective3, all three owned item/location rows and the unchanged4-credit wallet.
+Both native interior full updates carry that same generator. After collection,
+the anonymous book proxy becomes physicalID3 on exterior replay. The independent
+audit is `local/mission-generation/verification.json`; chamber and exterior
+captures were reviewed.
+
+The affected Go run passes170 roots/1,075 results in126.475s. The generation,
+five-shot and concurrent-owner checks pass12 race results in99.132s. The normal
+starter controller maps its route and encounter ordering from the saved room
+orientation; the extended earned playthrough was not repeated. JavaScript
+syntax and whitespace checks pass.
diff --git a/server/browser_generated_mission_test.go b/server/browser_generated_mission_test.go
@@ -0,0 +1,106 @@
+package main
+
+import (
+ "bytes"
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestBrowserGeneratedMission(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for generated mission traversal")
+ }
+
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/mission-generation", time.Now().Format("20060102-150405"))
+ world, _ := newMissionOfferWorld(t)
+ client := world.clients[1]
+ if err := world.handleMissionOffers(client, missionOffersRequest()); err != nil {
+ t.Fatal(err)
+ }
+ client.missionOffer.seed = 1
+ if err := world.handleMissionAcceptance(client, missionAcceptanceRequest(*client.missionOffer)); err != nil {
+ t.Fatal(err)
+ }
+ player := world.characters[1]
+ player.stats.Speed.RunSpeed = 5
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("generated-mission")))
+ player.position, player.rotation = [3]float32{89.3, 115.75, 155}, [4]float32{0, 1, 0, 0}
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.savePosition_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.db.Close(); err != nil {
+ t.Fatal(err)
+ }
+ world = newServerForTest(t)
+ 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()
+ player := world.characters[1]
+ json.NewEncoder(w).Encode(map[string]any{"inventory": player.inventory, "playfield": player.playfield,
+ "mission": player.missions[0].world, "objective": player.missions[0].objective,
+ "position": player.position})
+ })
+ host := httptest.NewServer(mux)
+ t.Cleanup(host.Close)
+ closeTestBrowserStreams(t, world)
+ ctx, cancel := context.WithTimeout(context.Background(), 3*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.advancePlayerMovement(now)
+ world.advanceZoneCrossings(now)
+ case <-ctx.Done():
+ return
+ }
+ }
+ }()
+ defer func() { cancel(); <-stopped }()
+
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_generated_mission.mjs"), host.URL, output)
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ if err := command.Run(); err != nil {
+ t.Fatal(err)
+ }
+ cancel()
+ <-stopped
+ if err := world.flushPositions(time.Now().Add(20 * time.Second)); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := world.db.Exec("VACUUM INTO ?", filepath.Join(output, "world.sqlite")); err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t)
+
+ expected := []ownedItem{{ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 64, Count: 1},
+ {ID: 2, Type: 51053, Template: 28577, Quality: 1, Slot: 65, Count: 1},
+ {ID: 3, Type: 51005, Template: 40822, Quality: 1, Slot: 66, Count: 1}}
+ if cold.characters[1].missions[0].objective != 3 || !slices.Equal(cold.characters[1].inventory.Items, expected) ||
+ cold.characters[1].playfield != 3000 || !bytes.Equal(cold.characters[1].missions[0].layout, player.missions[0].layout) {
+ t.Fatal("generated mission lost its layout, exterior, key, objective or original item")
+ }
+ t.Logf("Browser artifacts: %s", output)
+}
diff --git a/server/mission_doors_test.go b/server/mission_doors_test.go
@@ -16,6 +16,7 @@ func newMissionDoorOfferWorld(t *testing.T) (*server, *combatTestConn) {
if err := world.handleMissionOffers(world.clients[1], missionOffersRequest()); err != nil {
t.Fatal(err)
}
+ world.clients[1].missionOffer.seed = 2
output.packets = nil
return world, output
}
diff --git a/server/mission_encounters.go b/server/mission_encounters.go
@@ -26,6 +26,10 @@ func (server *server) stageMissionEncounters_locked(mission *acceptedMission) ([
return nil, fmt.Errorf("unsupported mission encounter %s level %d", encounter.Definition, encounter.Level)
}
for _, position := range encounter.Positions {
+ // Rotate the authored starter positions with the seeded two-room building.
+ if mission.offer.seed&1 != 0 {
+ position[0], position[2] = 40-position[0], 60-position[2]
+ }
if uint64(server.nextNPC)+uint64(len(spawned))+1 > math.MaxUint32 {
return nil, fmt.Errorf("mission NPC identities exhausted")
}
diff --git a/server/mission_encounters_test.go b/server/mission_encounters_test.go
@@ -22,6 +22,7 @@ func newMissionEncounterOfferWorld(t *testing.T) (*server, *combatTestConn) {
if err := world.handleMissionOffers(world.clients[1], missionOffersRequest()); err != nil {
t.Fatal(err)
}
+ world.clients[1].missionOffer.seed = 2
output.packets = nil
return world, output
}
diff --git a/server/mission_generation_test.go b/server/mission_generation_test.go
@@ -0,0 +1,85 @@
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "testing"
+ "time"
+)
+
+func TestMissionSeedSelectsConnectedTwoRoomLayoutAndRetainsItsContents(t *testing.T) {
+ for _, seed := range []uint32{1, 2, 0x12345678, 0xffffffff} {
+ t.Run(fmt.Sprint(seed), func(t *testing.T) {
+ world, _ := newMissionEncounterOfferWorld(t)
+ client, player := world.clients[1], world.characters[1]
+ player.geometry = world.geometry
+ client.missionOffer.seed = seed
+ request := missionAcceptanceRequest(*client.missionOffer)
+
+ if err := world.handleMissionAcceptance(client, request); err != nil {
+ t.Fatal(err)
+ }
+ player.position, player.rotation = [3]float32{89.30216, 115.75, 152.5}, [4]float32{0, 1, 0, 0}
+ if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil {
+ t.Fatal(err)
+ }
+ cold := reloadMissionEntranceWorld(t)
+ mission, restored := player.missions[0], cold.characters[1].missions[0]
+ layout, err := decodeMissionLayout(restored.layout)
+ if err != nil {
+ t.Fatal(err)
+ }
+ scene := cold.geometry.mission(restored.world)
+
+ chamber := missionRoom{template: 37, x: 1, z: 1}
+ if seed&1 != 0 {
+ chamber = missionRoom{template: 37, x: 1, z: 3, rotation: 2}
+ }
+ if len(layout.rooms) != 2 || layout.rooms[1] != chamber || !bytes.Equal(mission.layout, restored.layout) || restored.offer.seed != seed {
+ t.Fatal("seed did not select and retain its two-room layout", layout, seed)
+ }
+ if len(scene.links) != 1 || scene.entrance != &scene.rooms[0] || scene.roomAt(cold.characters[1].position) != scene.entrance ||
+ scene.roomAt(cold.worldItems[restored.objective].position) != &scene.rooms[1] || len(cold.mobileNPCs[restored.world]) != 5 {
+ t.Fatal("generated rooms lost their entrance, objective, connected passage or encounters")
+ }
+ })
+ }
+}
+
+func TestMissionGeneratedChamberKeepsExistingEncountersReachable(t *testing.T) {
+ for index, position := range [][3]float32{{15, .011, 44.5}, {15, .011, 41.5}, {15, .011, 34.5}, {15, .011, 26.5}, {14.01, 1.5625, 22.01}} {
+ t.Run(fmt.Sprint(index), func(t *testing.T) {
+ world, _ := newMissionEncounterOfferWorld(t)
+ client, player := world.clients[1], world.characters[1]
+ player.geometry = world.geometry
+ client.missionOffer.seed = 1
+ if err := world.handleMissionAcceptance(client, missionAcceptanceRequest(*client.missionOffer)); err != nil {
+ t.Fatal(err)
+ }
+ player.position, player.rotation = [3]float32{89.30216, 115.75, 152.5}, [4]float32{0, 1, 0, 0}
+ if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil {
+ t.Fatal(err)
+ }
+ client.ready, client.loading = true, false
+ world.clients[1] = client
+ player.position, player.stats = [3]float32{40 - position[0], position[1], 60 - position[2]}, testCharacterStats()
+ player.movement = playerMovement{}
+ world.updateNPCInterest_locked(client, time.Now())
+ player.inventory.Items[0].Template, player.inventory.Items[0].Slot, player.inventory.Items[0].Ammo = 123742, 6, 3
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ world.combatRoll = func(uint32) uint32 { return 0 }
+ target := world.characters[2000000+uint32(index)]
+
+ if err := world.handleCombat(client, attackPacket(1, target.id)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ world.advanceCombat(player.nextAttack)
+
+ if target.health == 0 || target.health >= 100 || player.inventory.Items[0].Ammo != 2 {
+ t.Fatal("alternate chamber blocked an admitted encounter", target.position, target.health, player.inventory)
+ }
+ })
+ }
+}
diff --git a/server/mission_geometry.go b/server/mission_geometry.go
@@ -102,7 +102,12 @@ func decodeMissionLayout(blob []byte) (missionLayout, error) {
return layout, nil
}
-func starterMissionLayout() missionLayout {
- return missionLayout{template: 331, width: 4, depth: 6, floorHeight: 10, ambient: [3]byte{100, 100, 100},
+func starterMissionLayout(seed uint32) missionLayout {
+ layout := missionLayout{template: 331, width: 4, depth: 6, floorHeight: 10, ambient: [3]byte{100, 100, 100},
rooms: []missionRoom{{template: 0, x: 1, z: 3, rotation: 2}, {template: 37, x: 1, z: 1}}}
+ // Reconstruction selection between reviewed orientations of the connected pair.
+ if seed&1 != 0 {
+ layout.rooms = []missionRoom{{template: 0, x: 2, z: 1}, {template: 37, x: 1, z: 3, rotation: 2}}
+ }
+ return layout
}
diff --git a/server/mission_instance_test.go b/server/mission_instance_test.go
@@ -186,6 +186,7 @@ func TestMissionAssignmentsIsolateConcurrentOwners(t *testing.T) {
if err := world.handleMissionOffers(world.clients[id], request); err != nil {
t.Fatal(err)
}
+ world.clients[id].missionOffer.seed = 2
requests[id] = missionAcceptanceRequest(*world.clients[id].missionOffer)
binary.BigEndian.PutUint32(requests[id][8:12], id)
}
@@ -261,7 +262,7 @@ func TestMissionLayoutBlobRejectsMalformedFramingAndPlacements(t *testing.T) {
{"rotation", func(blob []byte) []byte { blob[24] = 4; return blob }},
} {
t.Run(scenario.name, func(t *testing.T) {
- blob, err := starterMissionLayout().blob()
+ blob, err := starterMissionLayout(2).blob()
if err != nil {
t.Fatal(err)
}
diff --git a/server/mission_retirement_test.go b/server/mission_retirement_test.go
@@ -18,6 +18,7 @@ func newAcceptedMissionWorld(t *testing.T) (*server, *combatTestConn) {
if err := world.handleMissionOffers(client, missionOffersRequest()); err != nil {
t.Fatal(err)
}
+ client.missionOffer.seed = 2
if err := world.handleMissionAcceptance(client, missionAcceptanceRequest(*client.missionOffer)); err != nil {
t.Fatal(err)
}
diff --git a/server/missions.go b/server/missions.go
@@ -136,7 +136,7 @@ func (server *server) handleMissionAcceptance(client *worldClient, body []byte)
inventory.Items = append(slices.Clone(inventory.Items), key)
mission := acceptedMission{id: key.ID, owner: player.id, offer: offer, expiresAt: time.Now().UTC().Add(48 * time.Hour)}
var err error
- mission.layout, err = starterMissionLayout().blob()
+ mission.layout, err = starterMissionLayout(offer.seed).blob()
if err != nil {
return err
}
diff --git a/tools/client/test_generated_mission.mjs b/tools/client/test_generated_mission.mjs
@@ -0,0 +1,104 @@
+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: 'generated-mission', 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();
+ evidence.initial = await server();
+ await game.walk(89.3, 151.2);
+ await game.wait('generated mission entered', snapshot => game.local(snapshot)?.playfield === evidence.initial.mission);
+ await game.ready();
+ evidence.entered = await server();
+ await game.save(output + '/entered');
+
+ // Clear the entrance's original raised lips using ordinary forward jumps.
+ for (const z of [14.5, 23.5]) {
+ await game.hold('KeyW', 'reach the jump takeoff', snapshot => game.local(snapshot).position[2] <= 60 - z);
+ const start = game.local().position;
+ await page.keyboard.down('KeyW');
+ try {
+ await game.key('Space');
+ await game.wait('raised doorway cleared', snapshot => {
+ const position = game.local(snapshot).position;
+ return Math.hypot(position[0] - start[0], position[2] - start[2]) >= 2.5;
+ });
+ } finally {
+ const sequence = game.sequence;
+ await page.keyboard.up('KeyW');
+ await game.waitInput(sequence, 769);
+ }
+ }
+ await game.hold('KeyW', 'reach the second room', snapshot => game.local(snapshot).position[2] <= 28.5);
+ await game.save(output + '/chamber');
+ await page.reload();
+ await game.ready();
+ await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
+ await game.snapshot();
+
+ // Frame and collect the original book through the native picker and pickup action.
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ const target = () => game.state.actors.find(actor => actor.type === 51005 && actor.id === evidence.entered.objective);
+ await game.wait('first-person camera and projected objective', snapshot => snapshot.camera.firstPerson && target()?.screenPosition);
+ const point = await game.point(512, 300), deadline = Date.now() + 10000;
+ let y = point.y;
+ await page.mouse.move(point.x, y);
+ await page.mouse.down({button: 'right'});
+ try {
+ for (;;) {
+ await game.snapshot();
+ const screenY = target().screenPosition[1];
+ if (screenY >= 350 && screenY <= 540) break;
+ assert(Date.now() < deadline, 'Objective did not enter the camera view');
+ y += screenY > 540 ? 20 : -20;
+ await page.mouse.move(point.x, y, {steps: 2});
+ }
+ } finally { await page.mouse.up({button: 'right'}); }
+ await game.click(...await game.pick(51005, evidence.entered.objective));
+ await game.key('KeyR');
+ await game.wait('objective proxy collected', snapshot => game.local(snapshot).inventory.some(item => item.templates.includes(40822)));
+ evidence.collected = await server();
+ assert.equal(evidence.collected.inventory.Items.filter(item => item.ID === evidence.entered.objective && item.Template === 40822).length, 1);
+ await game.save(output + '/collected');
+
+ // Reach the back of the second room, then return through the original exit.
+ await game.hold('KeyW', 'reach the far chamber', snapshot => game.local(snapshot).position[2] <= 17);
+ await game.save(output + '/far-room');
+ await game.walk(25, 32);
+ await game.hold('KeyW', 'return to the entrance lip', snapshot => game.local(snapshot).position[2] >= 33.5);
+ const start = game.local().position;
+ await page.keyboard.down('KeyW');
+ try {
+ await game.key('Space');
+ await game.wait('return lip cleared', snapshot => Math.hypot(
+ game.local(snapshot).position[0] - start[0], game.local(snapshot).position[2] - start[2]) >= 2.5);
+ } finally { await page.keyboard.up('KeyW'); }
+ await game.hold('KeyW', 'walk through the exterior portal', snapshot => game.local(snapshot)?.playfield === 3000);
+ await game.wait('original exterior reached', snapshot => game.local(snapshot)?.playfield === 3000);
+ await game.ready();
+ await page.waitForFunction(() => touchRegion(500, 400)?.world === true);
+ await game.snapshot();
+ evidence.final = await server();
+ assert.equal(evidence.final.inventory.Items.filter(item => item.ID === evidence.entered.objective).length, 1);
+ assert.deepEqual(game.errors, []);
+ console.log('PASS: seeded south-facing mission, native entrance/objective/exit and page recovery');
+} 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_starter_equipment.mjs b/tools/client/test_starter_equipment.mjs
@@ -412,6 +412,9 @@ try {
const accepted = await (await owner.page.request.get(url + '/test-state')).json();
assert.equal(accepted.missions.length, 1);
const mission = accepted.missions[0];
+ // Follow the saved room orientation, including retained contracts after reload.
+ const missionReversed = Buffer.from(mission.layout, 'base64')[24] === 0;
+ const missionPoint = (x, z) => missionReversed ? [40 - x, 60 - z] : [x, z];
for (const field of ['Description', 'Playfield', 'Entrance', 'Position', 'ObjectiveItem',
'Credits', 'Experience', 'RewardItem', 'RewardQuality'])
assert.deepEqual(mission.definition[field], advertised[field]);
@@ -436,22 +439,22 @@ try {
assert(entered.enemies.every(enemy => enemy.health === 100 && enemy.maximumHealth === 100));
assert.equal(entered.missions[0].layout, mission.layout);
mission.objective = entered.missions[0].objective;
- const encounters = entered.enemies.sort((a, b) => a.position[2] - b.position[2]);
+ const encounters = entered.enemies.sort((a, b) => (missionReversed ? -1 : 1) * (a.position[2] - b.position[2]));
await owner.save(output + '/mission-entered');
let book;
for (let index = 0; index < encounters.length; ++index) {
const z = [16.6, 27.5, 33.25, 40.25, 43.25][index];
- await owner.walk(15, z);
+ await owner.walk(...missionPoint(15, z));
fights.push(await fight(owner, encounters[index], 'mission-' + (index + 1)));
if (index === 0) {
for (const z of [16.6, 23.5]) {
- await owner.walk(15, z);
+ await owner.walk(...missionPoint(15, z));
await jump(owner);
}
}
if (index === 1) {
// Pick up the exact world book before later loot fills the visible bag rows.
- await owner.walk(15, 31);
+ await owner.walk(...missionPoint(15, 31));
await frame(owner, 51005, mission.objective);
const beforePickup = (await (await owner.page.request.get(url + '/test-state')).json()).inventory;
[x, y] = await owner.pick(51005, mission.objective);
@@ -490,10 +493,10 @@ try {
assert.equal(cleared.missions[0].completed, false);
// Return the allocated book to the issuing booth through native item-on-item Use.
- await owner.walk(15, 26.5);
+ await owner.walk(...missionPoint(15, 26.5));
await jump(owner);
for (const z of [12.5, 10]) {
- await owner.walk(15, z);
+ await owner.walk(...missionPoint(15, z));
if (owner.local().playfield === 3000) break;
}
await owner.wait('mission exterior return', state => owner.local(state)?.playfield === 3000, 60000);