commit 420c822299146f332118f12c26d78dc3d2bed9c3
parent f7d05b099ce78bc7ce3131de6f39050121821b50
Author: anon <anon@example.com>
Date: Thu, 5 Nov 2026 20:38:43 +0000
Stock faction training terminals with usable recovery and ammunition
Diffstat:
6 files changed, 356 insertions(+), 14 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -109,11 +109,13 @@ research separately. More screenshots and test cases do not count as new gamepla
Exact random stock rotation and the full historical catalog are deferred.
November 5: [the finite terminal inventory](docs/early-shop-stock.md) lists
all 190 placements in training grounds 950/952/954 and basic shops
- 1180/1183/1186. Of these, 163 have no catalog rows, including all four training
- terminals; basic weapon terminals supply ammunition but no weapons. Start
- with usable training-terminal resupply, then fill basic upgrades and profession
- essentials and explicitly identify deferred specialty terminals. This census
- establishes scope, not passing browse/purchase/use or affordability checks.
+ 1180/1183/1186. The four empty training terminals now carry seven original QL1
+ recovery/ammunition packages under an explicit provisional stock policy;
+ all four pass native buy/sell, cancel, recovery use, bullet reload, reconnect
+ and cold recovery checks. 159 placements still have no catalog rows. Basic
+ weapon terminals supply ammunition but no weapons. Next fill basic upgrades and profession essentials,
+ explicitly identify deferred specialty terminals and verify affordability
+ against ordinary rewards. Funded fixtures do not establish affordability.
## P0: playable and releasable
diff --git a/docs/early-shop-stock.md b/docs/early-shop-stock.md
@@ -6,18 +6,71 @@ This is 190 placements. NPC vendors retain their separately documented A2 scope.
Original placement identities and templates come from `server/gamedata/shops.yaml`;
names come from the maintained original item records. Row counts reflect the
current `shop_stock.yaml`; they do not prove affordability, usefulness or live
-browse/buy/use behavior. Those acceptance checks remain open.
+browse/buy/use behavior.
-Baseline: 163 placements have no catalog rows. All four training-ground
-terminals are empty. The three basic weapon terminals contain four ammunition
-packages and no weapons. Profession crystal terminals are also empty.
+Baseline: 163 placements had no catalog rows, including all four training-ground
+terminals. The training terminals now each carry seven recovery/ammunition rows,
+leaving 159 empty placements. The three basic weapon terminals still contain four
+ammunition packages and no weapons. Profession crystal terminals are also empty.
+
+## Training-ground resupply
+
+The four terminals share the supported QL1 starter-peddler subset. Membership is
+provisional alpha policy, not recovered historical stock. Original package sizes
+and terminal price modifiers are preserved. Prices below precede skill discounts.
+
+| Original item | Template | Charges/rounds | Omni credits | Clan/Neutral credits |
+| --- | --- | --- | --- | --- |
+| Treatment Laboratory | 25812 | 50 | 150 | 157 |
+| Simple Nano Kit | 85366 | 25 | 20 | 21 |
+| Basic Nano Recharger | 25820 | 50 | 250 | 262 |
+| Bullets | 21605 | 100 | 25 | 26 |
+| Energy Weapon Ammo | 21609 | 100 | 50 | 52 |
+| Shotgun Shells | 21613 | 100 | 80 | 84 |
+| Flamethrower Ammunition | 21601 | 100 | 80 | 84 |
+
+One of each costs 655 credits at the Omni terminal and 686 at the Clan/Neutral
+terminals. Controlled funded fixtures do not establish normal-play affordability;
+that acceptance check remains open, along with basic upgrades, profession
+essentials and visible identification of deferred specialty categories.
+
+### Verification, November 5
+
+`TestStarterTerminalsSellOriginalRecoveryAndAmmunitionPackages` first reproduced
+the empty catalogs, then passed all four placements with exact package identities,
+counts, prices, repeated Accept and cold database recovery. The focused nine-test
+batch also passed the existing peddler, medical, ammunition, concurrent Accept
+and rejected-write/retry checks; `go vet ./server` passed.
+
+`TestBrowserStarterShops` and `tools/client/test_starter_shops.mjs` use a controlled
+level-five patient, 1,000 credits, an empty finite pistol and one sale item. All
+four placements passed native right-click/E opening, seven visible stock rows,
+buy/sell, cancellation, use of all three recovery families, purchased-bullet
+reload, page reconnect and cold recovery. Exact durable instances and cash agree
+with the server. Catalog screenshots were inspected. The fixture advances
+movement but not server regeneration; native passive ticks still run, so resource
+comparisons occur at each medical use rather than after later sitting recovery.
+
+Passing artifacts under `local/alpha-shops/`:
+
+- Omni: `20261105-123448/c00003b6`.
+- Clan: `20261105-123747/c00003b8`.
+- Both Neutral placements: `20261105-123541/c00003ba` and `c00103ba`.
+- Server regressions: `regressions.log`; static checks: `vet.log`.
+
+The initial Clan browser run caught a late assertion observing passive recovery;
+its trace showed the correct treatment gain before that tick. The corrected
+per-use assertion passed. No historical stock research or ordinary-play funding
+check is claimed by this change. A5 remains open.
+
+## Placement census
| Playfield | Terminal identity | Template | Original name | Stock rows | Position X, Y, Z |
| --- | --- | --- | --- | --- | --- |
-| 950 | `0xc00003b6` | 100035 | Startup Shop! | 0 | 60.00, 14.00, 50.00 |
-| 952 | `0xc00003b8` | 100034 | Startup Shop! | 0 | 48.00, 14.00, 62.00 |
-| 954 | `0xc00003ba` | 99643 | Basic Startup Equipment | 0 | 227.01, 6.00, 83.07 |
-| 954 | `0xc00103ba` | 99643 | Basic Startup Equipment | 0 | 150.32, 3.47, 47.92 |
+| 950 | `0xc00003b6` | 100035 | Startup Shop! | 7 | 60.00, 14.00, 50.00 |
+| 952 | `0xc00003b8` | 100034 | Startup Shop! | 7 | 48.00, 14.00, 62.00 |
+| 954 | `0xc00003ba` | 99643 | Basic Startup Equipment | 7 | 227.01, 6.00, 83.07 |
+| 954 | `0xc00103ba` | 99643 | Basic Startup Equipment | 7 | 150.32, 3.47, 47.92 |
| 1180 | `0xc000049c` | 155222 | Basic Implants | 0 | 133.00, 11.01, 153.00 |
| 1180 | `0xc001049c` | 155233 | Basic Melee Weapon Construction Kits | 0 | 154.00, 11.01, 153.00 |
| 1180 | `0xc002049c` | 155236 | Basic Ranged Weapon Construction Kits | 0 | 159.00, 11.01, 153.00 |
diff --git a/server/browser_starter_shops_test.go b/server/browser_starter_shops_test.go
@@ -0,0 +1,104 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "math"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "reflect"
+ "runtime"
+ "testing"
+ "time"
+)
+
+func TestBrowserStarterShops(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for the four training-ground terminals")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/alpha-shops", time.Now().Format("20060102-150405"))
+ for _, identity := range []uint32{0xc00003b6, 0xc00003b8, 0xc00003ba, 0xc00103ba} {
+ t.Run(fmt.Sprintf("%x", identity), func(t *testing.T) {
+ world := newTestServer(t)
+ machine := gamedata.ShopMachines[identity]
+ player := world.newCharacter()
+ player.playfield, player.position = machine.Playfield, machine.Position
+ player.appearance = map[uint32]uint16{950: 0x515, 952: 0x315, 954: 0x115}[machine.Playfield]
+ forward, _ := bodyAxes(machine.Rotation)
+ player.position[0] += 3 * forward[0]
+ player.position[2] += 3 * forward[2]
+ player.position[1] += .5
+ yaw := math.Atan2(float64(machine.Position[0]-player.position[0]), float64(machine.Position[2]-player.position[2]))
+ player.rotation = [4]float32{0, float32(math.Sin(yaw / 2)), 0, float32(math.Cos(yaw / 2))}
+ // Controlled level-five patient, empty finite pistol and sale loot.
+ // Funding and trained skills are fixtures, not earned-progression evidence.
+ player.level, player.health, player.nano = 5, 1, 1
+ player.stats.Body.BodyDevelopment, player.stats.Body.NanoPool = 40, 40
+ player.stats.NanoAiding.Treatment, player.stats.NanoAiding.FirstAid, player.stats.NanoAiding.TimeAndSpace = 10, 10, 10
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("starter-shops")))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ inventory := playerInventory{Credits: 1000, LastID: 2, Items: []ownedItem{
+ {ID: 1, Type: 51018, Template: 123742, Quality: 1, Slot: 6, Count: 1},
+ {ID: 2, Type: 51018, Template: 209283, Quality: 1, Slot: 64, Count: 1},
+ }}
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ mux := http.NewServeMux()
+ mux.Handle("/", world.httpHandler())
+ mux.HandleFunc("GET /test-state", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ open, sales, purchases := false, 0, 0
+ if client := world.clients[1]; client != nil && client.shop != nil {
+ open, sales = true, len(client.shop.items)
+ for _, count := range client.shop.purchases {
+ purchases += int(count)
+ }
+ }
+ json.NewEncoder(w).Encode(map[string]any{"machine": identity, "playfield": machine.Playfield,
+ "open": open, "sales": sales, "purchases": purchases, "inventory": player.inventory,
+ "health": player.health, "nano": player.nano})
+ })
+ host := httptest.NewServer(mux)
+ defer host.Close()
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
+ stopped := make(chan struct{})
+ go func() {
+ defer close(stopped)
+ clock := time.NewTicker(time.Second / 60)
+ defer clock.Stop()
+ for {
+ select {
+ case now := <-clock.C:
+ world.advancePlayerMovement(now)
+ case <-ctx.Done():
+ return
+ }
+ }
+ }()
+ defer func() { cancel(); <-stopped }()
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_starter_shops.mjs"), host.URL, filepath.Join(output, fmt.Sprintf("%x", identity)))
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+ t.Logf("Browser artifacts: %s", filepath.Join(output, fmt.Sprintf("%x", identity)))
+ if err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t).characters[1]
+ if !reflect.DeepEqual(cold.inventory, player.inventory) || cold.health != player.health || cold.nano != player.nano {
+ t.Fatal("starter purchases and resource use changed during cold recovery")
+ }
+ })
+ }
+}
diff --git a/server/gamedata/shop_stock.yaml b/server/gamedata/shop_stock.yaml
@@ -99,4 +99,11 @@
# NPC starter route: fixed QL1 food and medical/ammunition subsets.
# These are provisional catalogs, not recovered NPC stock; docs/npc-shops.md.
120973: [{template: 130581, quality: 1}, {template: 130593, quality: 1}]
-27054: [{template: 25812, quality: 1}, {template: 85366, quality: 1}, {template: 25820, quality: 1}, {template: 21605, quality: 1}, {template: 21609, quality: 1}, {template: 21613, quality: 1}, {template: 21601, quality: 1}]
+27054: &starter_supplies
+ [{template: 25812, quality: 1}, {template: 85366, quality: 1}, {template: 25820, quality: 1}, {template: 21605, quality: 1}, {template: 21609, quality: 1}, {template: 21613, quality: 1}, {template: 21601, quality: 1}]
+
+# Four training-ground terminals share this provisional early resupply subset.
+# Their original price modifiers remain independent; docs/early-shop-stock.md.
+100035: *starter_supplies
+100034: *starter_supplies
+99643: *starter_supplies
diff --git a/server/starter_shop_test.go b/server/starter_shop_test.go
@@ -0,0 +1,65 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "encoding/binary"
+ "fmt"
+ "slices"
+ "testing"
+)
+
+func TestStarterTerminalsSellOriginalRecoveryAndAmmunitionPackages(t *testing.T) {
+ for _, scenario := range []struct {
+ machine, credits uint32
+ }{
+ {0xc00003b6, 345}, {0xc00003b8, 314}, {0xc00003ba, 314}, {0xc00103ba, 314},
+ } {
+ t.Run(fmt.Sprintf("%x", scenario.machine), func(t *testing.T) {
+ world, _ := newPurchaseWorld(t)
+ player, client := world.characters[1], world.clients[1]
+ machine := gamedata.ShopMachines[scenario.machine]
+ player.playfield, player.position = machine.Playfield, machine.Position
+ player.appearance = map[uint32]uint16{950: 0x515, 952: 0x315, 954: 0x115}[machine.Playfield]
+ player.stats.TradeRepair.ComputerLiteracy, player.stats.Abilities.Intelligence = 0, 0
+ request := shopUseRequest(2)
+ binary.BigEndian.PutUint32(request[44:48], scenario.machine)
+
+ if err := world.handleShopUse(client, request); err != nil {
+ t.Fatal(err)
+ }
+ if client.shop == nil || !slices.Equal(client.shop.stock, []gamedata.ShopItem{
+ {Template: 25812, Quality: 1}, {Template: 85366, Quality: 1}, {Template: 25820, Quality: 1},
+ {Template: 21605, Quality: 1}, {Template: 21609, Quality: 1}, {Template: 21613, Quality: 1}, {Template: 21601, Quality: 1},
+ }) {
+ t.Fatal("starter terminal has no usable recovery/ammunition catalog")
+ }
+ for index := range uint32(7) {
+ if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 4, [2]uint32{51035, scenario.machine}, [2]uint32{111, index})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ }
+ accept := shopTradePacket([2]uint32{50000, 1}, 1, [2]uint32{}, [2]uint32{})[20:]
+ if err := world.handleTrade(client, accept); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.handleTrade(client, accept); err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t).characters[1].inventory
+
+ expected := []ownedItem{
+ {ID: 2, Type: 51005, Template: 25812, Quality: 1, Slot: 65, Count: 50},
+ {ID: 3, Type: 51005, Template: 85366, Quality: 1, Slot: 66, Count: 25},
+ {ID: 4, Type: 51005, Template: 25820, Quality: 1, Slot: 67, Count: 50},
+ {ID: 5, Type: 51005, Template: 21605, Quality: 1, Slot: 68, Count: 100},
+ {ID: 6, Type: 51005, Template: 21609, Quality: 1, Slot: 69, Count: 100},
+ {ID: 7, Type: 51005, Template: 21613, Quality: 1, Slot: 70, Count: 100},
+ {ID: 8, Type: 51005, Template: 21601, Quality: 1, Slot: 71, Count: 100},
+ }
+ if cold.Credits != scenario.credits || player.inventory.Credits != scenario.credits || len(cold.Items) != 8 ||
+ !slices.Equal(cold.Items[1:], expected) || !slices.Equal(cold.Items, player.inventory.Items) || world.nextItem != 8 {
+ t.Fatal("starter purchase changed authored prices, packages or durable identities", cold)
+ }
+ })
+ }
+}
diff --git a/tools/client/test_starter_shops.mjs b/tools/client/test_starter_shops.mjs
@@ -0,0 +1,111 @@
+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: 'starter-shops', url}]);
+ const page = await context.newPage();
+ game = await GameTest.attach(page);
+ const server = async () => (await page.request.get(url + '/test-state')).json();
+ const cell = (type, slot) => game.state.grids.flatMap(grid => grid.cells).find(cell =>
+ cell.identity[0] === type && cell.identity[1] === slot && !cell.dummy);
+ const click = async (source, button = 'left') => {
+ assert(source, 'expected native inventory/catalog cell is present');
+ await game.click((source.bounds[0] + source.bounds[2]) / 2, (source.bounds[1] + source.bounds[3]) / 2, button);
+ };
+ const waitServer = (label, predicate) => game.waitFor(label, async () => predicate(await server()));
+ await page.goto(url);
+ await game.ready();
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ await game.key('KeyI');
+ evidence.before = await server();
+ const open = async keyboard => {
+ await game.click(...await game.pick(51035, evidence.before.machine), keyboard ? 'left' : 'right');
+ if (keyboard) await game.key('KeyE');
+ await game.wait('all seven starter catalog rows', () => [0, 1, 2, 3, 4, 5, 6].every(index => cell(111, index)));
+ assert((await server()).open);
+ };
+ await open(false);
+ await game.save(output + '/catalog');
+
+ // Buy every authored package and sell one controlled loot item atomically.
+ for (let index = 0; index < 7; ++index) {
+ await click(cell(111, index));
+ await waitServer('purchase row selected', state => state.purchases === index + 1);
+ }
+ await click(cell(104, 48));
+ await game.wait('sale loot picked', state => state.dragged[0] === 104);
+ await game.click(860, 412);
+ await waitServer('loot offered', state => state.sales === 1);
+ await game.save(output + '/basket');
+ await game.click(873, 475);
+ await waitServer('supplies committed', state => !state.open && state.inventory.Items.length === 8);
+ evidence.purchased = await server();
+ assert.equal(evidence.purchased.inventory.Credits, evidence.before.playfield === 950 ? 950 : 798);
+ assert.deepEqual(evidence.purchased.inventory.Items.slice(1).map(item => [item.ID, item.Template, item.Quality, item.Count]), [
+ [3, 25812, 1, 50], [4, 85366, 1, 25], [5, 25820, 1, 50],
+ [6, 21605, 1, 100], [7, 21609, 1, 100], [8, 21613, 1, 100], [9, 21601, 1, 100],
+ ]);
+
+ // Reopen with E and cancel a second basket without another debit or delivery.
+ await open(true);
+ await click(cell(111, 0));
+ await waitServer('cancel draft selected', state => state.purchases === 1);
+ await game.click(945, 475);
+ await waitServer('draft cancelled', state => !state.open);
+ assert.deepEqual((await server()).inventory, evidence.purchased.inventory);
+
+ // Use all three purchased recovery families through their real inventory cells.
+ await game.key('F1');
+ await game.key('KeyX');
+ await game.wait('patient seated', state => game.local(state).stats[430] === 2);
+ for (const [slot, id, remaining] of [[48, 3, 49], [49, 4, 24], [50, 5, 49]]) {
+ await click(cell(104, slot), 'right');
+ await waitServer('one purchased medical charge consumed', state => state.inventory.Items.find(item => item.ID === id)?.Count === remaining);
+ const treated = await server();
+ // Compare the item effect before later native passive recovery ticks.
+ await game.wait('native charge and recovered resource agree', state =>
+ game.local(state).inventory.find(item => item.slot === slot)?.count === remaining &&
+ (id === 3 ? game.local(state).stats[27] === treated.health : game.local(state).stats[214] === treated.nano));
+ }
+ evidence.treated = await server();
+ assert.equal(evidence.treated.health, 31);
+ assert(evidence.treated.nano >= 41 && evidence.treated.nano <= 43);
+ await game.save(output + '/recovery');
+
+ // Put the purchased bullets into the controlled empty finite pistol.
+ await game.key('KeyX');
+ await page.keyboard.press('Control+1');
+ await click(cell(104, 51));
+ await game.wait('purchased bullets picked', state => state.dragged[0] === 104 && state.dragged[1] === 51);
+ await game.click(867, 206, 'right');
+ await waitServer('reload commits both inventory sides', state => state.inventory.Items[0].Ammo === 20 && state.inventory.Items.find(item => item.ID === 6).Count === 80);
+ await game.wait('native pistol and ammunition agree', state => game.local(state).weapons.some(weapon => weapon.loadedAmmo === 20) &&
+ game.local(state).inventory.find(item => item.slot === 51)?.count === 80);
+ evidence.used = await server();
+ await game.save(output + '/reloaded-pistol');
+
+ await page.reload();
+ await game.ready();
+ evidence.reconnected = await server();
+ assert.deepEqual(evidence.reconnected.inventory, evidence.used.inventory);
+ assert.equal(evidence.reconnected.health, evidence.used.health);
+ assert.equal(evidence.reconnected.nano, evidence.used.nano);
+ assert.deepEqual(game.errors, []);
+ console.log('PASS:', evidence.before.machine, 'seven stock rows, buy/sell, E/cancel, three recovery uses, bullet reload and 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(); }
+}