aorecomp

Anarchy Online classic in the browser

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


commit db258a21b50b383f00affdfe2d18304c98d05bd4
parent 22011eb232f6c59f9832e90684d19ec0bdd6a3f8
Author: anon <anon@example.com>
Date:   Thu,  5 Nov 2026 21:58:12 +0000

Fund early resupply with level-scaled mission cash rewards

Diffstat:
MTODO.md | 10+++++++---
Mdocs/early-shop-stock.md | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocs/mission-levels.md | 6++++++
Mdocs/starter-missions.md | 8++++++++
Aserver/browser_mission_cash_test.go | 96+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/gamedata/missions.yaml | 3++-
Mserver/gamedata/types.go | 2+-
Aserver/mission_cash_test.go | 149+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/mission_levels_test.go | 2+-
Mserver/mission_offers.go | 2++
Mserver/mission_offers_test.go | 1+
Mserver/starter_missions_test.go | 2+-
Atools/client/test_mission_cash.mjs | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtools/client/test_starter_equipment.mjs | 8+++++---
14 files changed, 418 insertions(+), 10 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -122,9 +122,13 @@ research separately. More screenshots and test cases do not count as new gamepla 123 placements remain empty and visibly identify unsupported purchases while retaining loot sales. Meta-Physicist combat nanos and pet attacks, Engineer robots and other unfinished profession essentials remain open, - alongside ordinary-reward affordability. Funded fixtures do not establish - affordability; the stock ledger also records unfinished weapon specials - rather than claiming complete combat support from a successful ordinary attack. + alongside the bounded ordinary-play affordability check. New mission offers + now pay an explicit provisional 500 credits per selected mission level; + level-one completion cash covers recovery/ammunition resupply in all three + factions without selling issued items. Controlled settlement/purchase checks + establish that budget, not ordinary progression pace. The stock ledger also + records unfinished weapon specials rather than claiming complete combat + support from a successful ordinary attack. ## P0: playable and releasable diff --git a/docs/early-shop-stock.md b/docs/early-shop-stock.md @@ -15,6 +15,71 @@ contain four ammunition packages and twelve weapon rows. Thirty-six profession a general crystal terminals now stock an early subset, leaving 123 empty placements. The three Meta-Physicist terminals still lack usable early combat stock. +## Mission cash and resupply + +The retained [ordinary starter run](starter-progression.md#maintained-fresh-earned-level-and-recovery-loop) +exhausted all 25 issued laboratory charges before reaching the medical shop with +59 credits. Its 150-credit replacement was unaffordable, and ordinary sitting +was needed. The original item prices are retained. New starter mission offers +instead pay a provisional 500 credits per selected mission level, replacing +the flat 20-credit payout. This is an explicit alpha balance choice, not a +historical reward formula. Request fees remain one credit per player level; +completion cash is resolved before advertisement and paid from the saved +contract without recomputing it at hand-in. + +One level-one completion pays 500 credits. Before skill discounts, a package +each of Treatment Laboratory (50), Simple Nano Kit (25), Basic Nano Recharger +(50), and Energy Weapon Ammo (100) costs 470 credits for Omni or 492 for +Clan/Neutral. The reward alone buys those supplies while retaining the mission +item reward and all existing equipment. Bullets cost less than the energy +package; the stocked Vektor also uses energy ammunition. + +The following conservative budgets include the most expensive stocked weapon +at that QL, the most expensive single stocked crystal and the four supply +packages above. They exclude all loot sales and corpse cash, subtract one +generation fee per same-level mission, and do not assume a skill discount. +These are price/reward arithmetic, not measured play times or earned upgrade +evidence. The maximum crystal and weapon need not suit the same profession. + +| Mission/weapon QL | Omni basket | Clan/Neutral basket | Net cash per completion | Completions needed Omni / Clan/Neutral | +| --- | ---: | ---: | ---: | --- | +| 5 | 7160 | 7515 | 2495 | 3 / 4 | +| 10 | 8392 | 8809 | 4990 | 2 / 2 | + +`TestStarterMissionCashFundsRecoveryAndSurvivesSettlement` covers all three +factions at neutral difficulty levels 1, 5 and 10, plus level five's QL8 hardest +offer. It checks advertised cash, accepted journal/cold recovery, unchanged +promise after a level change, duplicate hand-in and exact supply purchases. +The character/mission checkpoints and objective access are controlled. Only the +request fee is seeded; purchases spend completion cash, with no sale of issued +or reward items. This establishes the transaction budget, not ordinary +combat/progression pace. A5 still needs a +bounded ordinary-play affordability sample and the missing profession essentials. + +The original flat reward failed all 12 new cases. The existing mission suite +passed 175 roots, including failed-fee, acceptance rollback, concurrent returns, +rejected settlement writes, lost replies and starter-backyard completion. +The new fixture first read the objective identity before entry allocated it; +using the generated identity fixed the fixture, and all 12 cash cases pass. +Logs are `local/alpha-mission-cash/regressions.log` (existing passes and initial +fixture failure) and `cash-regressions.log` (corrected cash cases). + +`TestBrowserMissionCashResupply` uses cold hand-in and shop checkpoints for all +three factions. Real book-on-booth input changes a zero balance to 500 and +retains the selected QL1 glove reward. The same wallet then buys the four supply +packages through the native catalog, leaving 30/8/8 credits. Exact item IDs, +qualities, counts and balances survive page reconnect and cold recovery. +Travel and combat are deliberately excluded from these controlled checkpoints. +The maintained ordinary-play driver now expects the new reward and selects an +affordable laboratory before cancelling; its full leveling run was not repeated. +Passing browser captures are under `local/alpha-mission-cash/20261105-135632/`, +with booth subdirectories `3221228472`, `3221228572` and `3221228532`, each +containing `hand-in` and `resupply`. `browser-final.log` records the final run +with explicit session shutdown between checkpoints. Original starter-binding +checks, `go vet ./server`, JavaScript syntax and diff checks pass (`catalog.log` +and `vet.log`). Test servers and browsers were closed. No historical research +or full A5 closure is claimed. + ## Training-ground resupply The four terminals share the supported QL1 starter-peddler subset. Membership is diff --git a/docs/mission-levels.md b/docs/mission-levels.md @@ -8,6 +8,12 @@ requests. Accepted encounters and the selected reward retain their concrete values through reconnect and cold restart, independently of later recipe edits or player advancement. +Cash now follows the selected mission level as well: new starter offers pay +500 credits per mission level under the explicit provisional +[resupply policy](early-shop-stock.md#mission-cash-and-resupply). Scaling happens +before advertisement; accepted contracts retain their saved cash amount. The +earlier runs below describe the former flat 20-credit reward. + The reward pool is filtered to families supporting the selected quality. There is no endpoint clamping. A missing combat profile or an empty eligible reward pool produces an empty offer without charging, allocating persistent identities, diff --git a/docs/starter-missions.md b/docs/starter-missions.md @@ -6,6 +6,14 @@ The contract's description directs the player to its local waypoint and issuing booth. Difficulty, fees, admission, saved private worlds, objective ownership, selected-quality rewards and retirement use the existing shared handlers. +New offers pay a provisional 500 credits per selected mission level. The recipe's +cash is multiplied once during generation, then advertised and saved as a +concrete amount. Hand-in pays that promise even if the player gains levels or +the recipe changes. The request fee remains the player's level. This is alpha +resupply policy, not recovered historical balance; see the +[cash and supply budget](early-shop-stock.md#mission-cash-and-resupply). +The earlier ordinary-play records below retain their actual 20-credit payouts. + ## Original placements A fresh format-aware audit of all original 14.9.1 resource 1000026 statel lists diff --git a/server/browser_mission_cash_test.go b/server/browser_mission_cash_test.go @@ -0,0 +1,96 @@ +package main + +import ( + "ao/server/gamedata" + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "math" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "runtime" + "testing" + "time" +) + +func TestBrowserMissionCashResupply(t *testing.T) { + if os.Getenv("AO_GAME_TEST") != "1" { + t.Skip("set AO_GAME_TEST=1 for mission-funded resupply") + } + _, source, _, _ := runtime.Caller(0) + root := filepath.Dir(filepath.Dir(source)) + output := filepath.Join(root, "local/alpha-mission-cash", time.Now().Format("20060102-150405")) + for _, shop := range missionCashShops { + t.Run(fmt.Sprint(shop.booth), func(t *testing.T) { + world, _ := newMissionCashWorld(t, shop.booth, 1, 6) + collectMissionCashObjective(t, world) + player := world.characters[1] + player.appearance = shop.appearance + player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("mission-cash"))) + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + + // Separate cold checkpoints cover hand-in and resupply without replaying travel. + // The fixture seeds the generation fee; all purchase funds come from hand-in. + for _, phase := range []string{"hand-in", "resupply"} { + position, rotation := gamedata.MissionBooths[shop.booth].Position, [4]float32{0, 0, 0, 1} + player.playfield = gamedata.MissionBooths[shop.booth].Playfield + if phase == "resupply" { + machine := gamedata.ShopMachines[shop.machine] + player.playfield, position, rotation = machine.Playfield, machine.Position, machine.Rotation + } + forward, _ := bodyAxes(rotation) + player.position = [3]float32{position[0] + 3*forward[0], position[1] + .5, position[2] + 3*forward[2]} + yaw := math.Atan2(float64(position[0]-player.position[0]), float64(position[2]-player.position[2])) + player.rotation = [4]float32{0, float32(math.Sin(yaw / 2)), 0, float32(math.Cos(yaw / 2))} + if err := world.savePosition_locked(player); err != nil { + t.Fatal(err) + } + if err := world.db.Close(); err != nil { + t.Fatal(err) + } + world = newServerForTest(t) + player = world.characters[1] + 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, purchases := false, 0 + if client := world.clients[1]; client != nil && client.shop != nil { + open = true + for _, count := range client.shop.purchases { + purchases += int(count) + } + } + json.NewEncoder(w).Encode(map[string]any{"phase": phase, "booth": shop.booth, "machine": shop.machine, + "supplyCost": shop.supplyCost, "inventory": player.inventory, "completed": world.missionExpiry[0].completed, + "open": open, "purchases": purchases}) + }) + host := httptest.NewServer(mux) + closeTestBrowserStreams(t, world) + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_mission_cash.mjs"), host.URL, + filepath.Join(output, fmt.Sprint(shop.booth), phase)) + command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr + err := command.Run() + cancel() + host.Close() + closeTestSessions(t, world) + if err != nil { + t.Fatal(err) + } + } + cold := newTestInventoryServer(t).characters[1].inventory + if cold.Credits != 500-shop.supplyCost || cold.LastID != 8 || len(cold.Items) != 6 { + t.Fatal("completion-funded purchase changed during cold recovery", cold) + } + t.Logf("Browser artifacts: %s", filepath.Join(output, fmt.Sprint(shop.booth))) + }) + } +} diff --git a/server/gamedata/missions.yaml b/server/gamedata/missions.yaml @@ -14,7 +14,8 @@ entrance: 3221228472 position: [89.30216217041016, 115.14443969726562, 151.16087341308594] objective_item: 40822 - credits: 20 + # Provisional cash per selected mission level; supports early resupply/upgrades. + credits: 500 experience: 100 # Reconstruction pool at mission QL; original probabilities are unresolved. diff --git a/server/gamedata/types.go b/server/gamedata/types.go @@ -28,7 +28,7 @@ type MissionTemplate struct { Entrance uint32 `yaml:"entrance"` Position [3]float32 `yaml:"position"` ObjectiveItem uint32 `yaml:"objective_item"` - Credits uint32 `yaml:"credits"` + Credits uint32 `yaml:"credits"` // Per mission level in recipes; concrete amount in offers. Experience uint32 `yaml:"experience"` RewardItem uint32 `yaml:"-"` // Concrete choice saved with an advertised contract. RewardItems []uint32 `yaml:"reward_items"` diff --git a/server/mission_cash_test.go b/server/mission_cash_test.go @@ -0,0 +1,149 @@ +package main + +import ( + "ao/server/gamedata" + "bytes" + "encoding/binary" + "fmt" + "slices" + "testing" +) + +var missionCashShops = []struct { + booth, machine, supplyCost uint32 + appearance uint16 +}{ + {3221228472, 0xc00003b6, 470, 0x515}, + {3221228572, 0xc00003b8, 492, 0x315}, + {3221228532, 0xc00003ba, 492, 0x115}, +} + +func newMissionCashWorld(t *testing.T, boothID uint32, level uint16, difficulty byte) (*server, *combatTestConn) { + t.Helper() + world, output := newBackyardMissionWorld(t, boothID) + player, client := world.characters[1], world.clients[1] + player.level = level + // Only seed the generation fee; the completed contract must fund the purchases. + player.inventory.Credits = uint32(level) + player.stats.Abilities.Intelligence, player.stats.TradeRepair.ComputerLiteracy = 5, 0 + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + if err := world.saveInventory_locked(player, player.inventory); err != nil { + t.Fatal(err) + } + request := missionOffersRequest() + request[17] = difficulty + originator, accepted := world.missionBoothEligibility_locked(client, gamedata.MissionBooths[boothID]) + if !accepted { + t.Fatal("fixture cannot use its starter booth") + } + request[28] = byte(originator) + binary.BigEndian.PutUint32(request[33:37], boothID) + if err := world.handleMissionOffers(client, request); err != nil { + t.Fatal(err) + } + if client.missionOffer == nil { + t.Fatal("production starter mission was unavailable") + } + return world, output +} + +func collectMissionCashObjective(t *testing.T, world *server) { + t.Helper() + player, client := world.characters[1], world.clients[1] + if err := world.handleMissionAcceptance(client, missionAcceptanceRequest(*client.missionOffer)); err != nil { + t.Fatal(err) + } + mission := player.missions[0] + // Controlled placement isolates settlement from already-covered combat/travel. + player.position = mission.offer.definition.Position + if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil { + t.Fatal(err) + } + world.clients[1], client.ready, client.loading = client, true, false + player.position, player.movement = world.worldItems[player.missions[0].objective].position, playerMovement{} + if err := world.handleInventory(client, worldPickupRequest(1, player.missions[0].objective)); err != nil { + t.Fatal(err) + } + if len(player.inventory.Items) != 3 { + t.Fatal("fixture did not pick up its generated objective", player.inventory) + } + destination := player.userData() + destination.Playfield, destination.Position = mission.offer.definition.Playfield, gamedata.MissionBooths[mission.offer.booth].Position + if err := world.updateUser_locked(destination); err != nil { + t.Fatal(err) + } + world.clients[1], client.ready, client.loading = client, true, false +} + +func TestStarterMissionCashFundsRecoveryAndSurvivesSettlement(t *testing.T) { + for _, shop := range missionCashShops { + for _, scenario := range []struct { + level uint16 + difficulty byte + credits uint32 + }{{1, 6, 500}, {5, 6, 2500}, {10, 6, 5000}, {5, 11, 4000}} { + t.Run(fmt.Sprintf("%d/level%d/difficulty%d", shop.booth, scenario.level, scenario.difficulty), func(t *testing.T) { + world, output := newMissionCashWorld(t, shop.booth, scenario.level, scenario.difficulty) + player, client := world.characters[1], world.clients[1] + offer := *client.missionOffer + var advertised []byte + for _, word := range []uint32{56001, shop.booth, 5, scenario.credits, 0, offer.definition.Experience} { + advertised = binary.BigEndian.AppendUint32(advertised, word) + } + if offer.definition.Credits != scenario.credits || !bytes.Contains(output.packets[1], advertised) || player.inventory.Credits != 0 { + t.Fatal("mission did not advertise the level-scaled cash after charging its fee", offer.definition.Credits) + } + collectMissionCashObjective(t, world) + cold := reloadMissionEntranceWorld(t) + if cold.characters[1].missions[0].offer.definition.Credits != scenario.credits || + !bytes.Contains(missionJournalPacket(cold.characters[1].missions[0], cold.missionExpiry[0].expiresAt), advertised) { + t.Fatal("accepted cash reward changed during cold recovery") + } + + // Pay the saved promise, even after the player's level changes. + player.level++ + request := missionReturnRequest(1) + binary.BigEndian.PutUint32(request[52:56], shop.booth) + for range 2 { + if err := world.handleMissionReturn(client, request); err != nil { + t.Fatal(err) + } + } + cold = reloadMissionEntranceWorld(t) + if player.inventory.Credits != scenario.credits || cold.characters[1].inventory.Credits != scenario.credits || + len(player.missions) != 0 || !cold.missionExpiry[0].completed || player.experience != 0 { + t.Fatal("hand-in changed the promise, paid twice or granted completion XP", player.inventory) + } + + // Spend only completion cash, retaining the reward and original equipment. + machine := gamedata.ShopMachines[shop.machine] + player.playfield, player.position, player.appearance = machine.Playfield, machine.Position, shop.appearance + request = shopUseRequest(2) + binary.BigEndian.PutUint32(request[44:48], shop.machine) + if err := world.handleShopUse(client, request); err != nil { + t.Fatal(err) + } + for _, row := range []uint32{0, 1, 2, 4} { + if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 4, [2]uint32{51035, shop.machine}, [2]uint32{111, row})[20:]); err != nil { + t.Fatal(err) + } + } + if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 1, [2]uint32{}, [2]uint32{})[20:]); err != nil { + t.Fatal(err) + } + cold = reloadMissionEntranceWorld(t) + if cold.characters[1].inventory.Credits != scenario.credits-shop.supplyCost || len(cold.characters[1].inventory.Items) != 6 || + !slices.Equal(cold.characters[1].inventory.Items[2:], []ownedItem{ + {ID: 5, Type: 51005, Template: 25812, Quality: 1, Slot: 66, Count: 50}, + {ID: 6, Type: 51005, Template: 85366, Quality: 1, Slot: 67, Count: 25}, + {ID: 7, Type: 51005, Template: 25820, Quality: 1, Slot: 68, Count: 50}, + {ID: 8, Type: 51005, Template: 21609, Quality: 1, Slot: 69, Count: 100}, + }) { + t.Fatal("mission cash did not buy the exact recovery/ammunition packages", cold.characters[1].inventory) + } + }) + } + } +} diff --git a/server/mission_levels_test.go b/server/mission_levels_test.go @@ -221,7 +221,7 @@ func TestMissionScalableRewardGenerationThroughReturnAndColdOwnership(t *testing reward := cold.characters[1].inventory.Items[1] if reward.ID != 4 || reward.Template != 122691 || reward.Quality != uint32(level) || reward.Slot != 65 || reward.Count != 1 || - len(cold.characters[1].inventory.Items) != 2 || cold.characters[1].inventory.Credits != 25-uint32(level) || + len(cold.characters[1].inventory.Items) != 2 || cold.characters[1].inventory.Credits != 5+19*uint32(level) || cold.nextItem != 4 || len(cold.characters[1].missions) != 0 || !cold.missionExpiry[0].completed { t.Fatal("the generated selected-quality reward was lost, replaced or paid twice", reward) } diff --git a/server/mission_offers.go b/server/mission_offers.go @@ -122,6 +122,8 @@ func (server *server) handleMissionOffers(client *worldClient, body []byte) erro if supported { level := gamedata.MissionLevels[player.level][body[17]-1] supported = level != 0 + // Scale the provisional cash once; acceptance and hand-in retain this promise. + definition.Credits *= uint32(level) definition.Encounters = slices.Clone(definition.Encounters) for index := range definition.Encounters { encounter := &definition.Encounters[index] diff --git a/server/mission_offers_test.go b/server/mission_offers_test.go @@ -247,6 +247,7 @@ func newMissionOfferWorld(t *testing.T) (*server, *combatTestConn) { // Keep the cash-only contract available to isolate journal and world lifecycle. definition := gamedata.MissionTemplates[3221228472] cashOnly := definition + cashOnly.Credits = 20 cashOnly.RewardItem, cashOnly.RewardQuality = 0, 0 cashOnly.RewardItems = nil cashOnly.Encounters = nil diff --git a/server/starter_missions_test.go b/server/starter_missions_test.go @@ -121,7 +121,7 @@ func TestStarterMissionBackyardsCompleteAtTheirOwnBooths(t *testing.T) { } cold = reloadMissionEntranceWorld(t) - if player.inventory.Credits != 24 || len(player.missions) != 0 || player.experience != 0 || + if player.inventory.Credits != 504 || len(player.missions) != 0 || player.experience != 0 || !reflect.DeepEqual(player.inventory, cold.characters[1].inventory) || len(player.inventory.Items) != 2 || player.inventory.Items[1] != (ownedItem{ID: 4, Type: 51022, Template: 85596, Quality: 1, Count: 1, Slot: 65}) || !cold.missionExpiry[0].completed || cold.characters[1].playfield != backyard.playfield { diff --git a/tools/client/test_mission_cash.mjs b/tools/client/test_mission_cash.mjs @@ -0,0 +1,74 @@ +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: 'mission-cash', url}]); + const page = await context.newPage(); + game = await GameTest.attach(page); + const server = async () => (await page.request.get(url + '/test-state')).json(); + const waitServer = (label, predicate) => game.waitFor(label, async () => predicate(await server())); + 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 => { + assert(source, 'native item cell is visible'); + await game.click((source.bounds[0] + source.bounds[2]) / 2, (source.bounds[1] + source.bounds[3]) / 2); + }; + await page.goto(url); + await game.ready(); + if (!game.state.camera.firstPerson) await game.key('F8'); + await game.key('KeyI'); + const initial = evidence.initial = await server(); + if (initial.phase === 'hand-in') { + assert.equal(initial.inventory.Credits, 0); + assert.equal(initial.completed, false); + const book = initial.inventory.Items.find(item => item.Template === 40822); + assert(book); + await click(cell(104, book.Slot - 16)); + await game.wait('original mission book picked', state => state.dragged[0] === 104); + await game.click(...await game.pick(56001, initial.booth), 'right'); + await waitServer('mission cash paid', state => state.completed && state.inventory.Credits === 500); + await game.wait('native completion cash received', state => game.local(state).stats[61] === 500); + evidence.completed = await server(); + assert.deepEqual(evidence.completed.inventory.Items.map(item => [item.ID, item.Template]), [[1, 209283], [4, 85596]]); + await game.save(output + '/completed'); + } else { + assert.equal(initial.inventory.Credits, 500); + assert.equal(initial.completed, true); + await game.click(...await game.pick(51035, initial.machine), 'right'); + await game.wait('original recovery and ammunition catalog', () => [0, 1, 2, 4].every(row => cell(111, row))); + for (const row of [0, 1, 2, 4]) await click(cell(111, row)); + await waitServer('four funded supply packages selected', state => state.purchases === 4); + await game.save(output + '/funded-basket'); + await game.click(873, 475); + await waitServer('only completion cash funds the supplies', state => !state.open && state.inventory.Credits === 500 - initial.supplyCost); + await game.wait('native purchase balance agrees', state => game.local(state).stats[61] === 500 - initial.supplyCost); + evidence.bought = await server(); + assert.deepEqual(evidence.bought.inventory.Items.map(item => [item.ID, item.Template, item.Quality, item.Count]), + [[1, 209283, 1, 1], [4, 85596, 1, 1], [5, 25812, 1, 50], [6, 85366, 1, 25], [7, 25820, 1, 50], [8, 21609, 1, 100]]); + await game.save(output + '/resupplied'); + } + const beforeReload = (await server()).inventory; + await page.reload(); + await game.ready(); + evidence.reconnected = await server(); + assert.deepEqual(evidence.reconnected.inventory, beforeReload); + assert.equal(game.local().stats[61], beforeReload.Credits); + assert.deepEqual(game.errors, []); + console.log('PASS:', initial.booth, initial.phase, 'native cash/items 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 @@ -404,7 +404,7 @@ try { await owner.wait('earned mission request fee', state => owner.local(state).stats[61] === fights[0].corpse.credits - 1); const advertised = (await (await owner.page.request.get(url + '/test-state')).json()).offer; - assert(advertised && advertised.Credits === 20 && advertised.RewardQuality === 1); + assert(advertised && advertised.Credits === 500 && advertised.RewardQuality === 1); await owner.save(output + '/mission-offer'); await owner.click(30, 45); await owner.click(74, 190); @@ -617,7 +617,7 @@ try { assert.equal(funded.stats.Body.BodyDevelopment, 15); assert.equal(funded.stats.Melee.OneHandBlunt, 15); const sale = funded.inventory.Items.find(item => item.Template === 42640); - assert(sale && sale.Quality === 1 && credits >= 20 && credits < 150); + assert(sale && sale.Quality === 1 && credits >= 500); // Walk the original streets to the medical shop without crossing unverified geometry. for (const [x, z] of [[62, 74], [62, 65], [52.5, 57.6], [52.5973, 55.1362]]) { @@ -646,7 +646,9 @@ try { await owner.wait('original medical shop open', state => state.regions.some( ([left, top, right, bottom]) => left === 832 && top === 0 && right === 1024 && bottom === 494)); await owner.click(864, 85); - await owner.save(output + '/unaffordable-laboratory'); + await owner.wait('funded laboratory selected for cancellation', state => state.grids.some(grid => + grid.rows === 1 && grid.cells.some(cell => cell.identity[0] === 111 && !cell.dummy))); + await owner.save(output + '/affordable-laboratory'); assert.deepEqual((await (await owner.page.request.get(url + '/test-state')).json()).inventory, funded.inventory); // Cancel and retry the exact earned part sale before accepting its six-credit quote.