aorecomp

Anarchy Online classic in the browser

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


commit 8c228509f8b33ee079e754f29de77989c7f66a6a
parent a4b6834403ae7de717ca11d1cb25bfe68eb86132
Author: anon <anon@example.com>
Date:   Fri,  6 Nov 2026 02:00:11 +0000

Verify starter profession essentials and close early shop alpha gate

Diffstat:
MTODO.md | 12++++++++----
Adocs/alpha-profession-paths.md | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocs/early-shop-stock.md | 9++++++++-
Aserver/browser_basic_shop_armor_test.go | 105+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/starter_professions_test.go | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools/client/test_basic_shop_armor.mjs | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 421 insertions(+), 5 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -97,7 +97,7 @@ research separately. More screenshots and test cases do not count as new gamepla corrections. All selected portals have moving panels, including the whom-pah. See [door implementation, verification and scope](docs/city-doors.md). -- [ ] **A5: Useful, nonempty early shop stock.** Inventory every terminal in the +- [x] **A5: Useful, nonempty early shop stock.** Inventory every terminal in the selected starter and basic shops for all three factions. Supported purchases exist; unstocked categories now explain their purchase limitation on opening. Supply a coherent early subset: usable weapons/armor, ammunition, health/nano recovery @@ -151,7 +151,11 @@ research separately. More screenshots and test cases do not count as new gamepla with atomic damage/rewards, reveal and persistent cooldown. Concealment admission and damage use explicit provisional PvE rules; historical detection and player-versus-player invisibility remain deferred. - Remaining profession essentials stay open. The + The [twelve-profession closure matrix](docs/alpha-profession-paths.md) now + connects all issued tools, supported effects, upgrades and recovery supplies. + All nineteen issued crystals upload with ordinary level-one training and + survive cold recovery. Native Clan/Neutral armor purchase, wear and recovery + now supplement the retained Omni checks, completing this finite shop scope. The [bounded earned affordability sample](docs/early-shop-stock.md#earned-affordability-sample-november-5) now completes an ordinary level-two Omni mission, buys and wears gloves, replenishes recovery supplies and retains 758 credits without grants or sales. @@ -162,8 +166,8 @@ research separately. More screenshots and test cases do not count as new gamepla 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. + links each weapon special to its own implementation and native checks; + ordinary attack success alone is not treated as complete special support. ## P0: playable and releasable diff --git a/docs/alpha-profession-paths.md b/docs/alpha-profession-paths.md @@ -0,0 +1,124 @@ +# Alpha profession essentials + +This is the finite A5 starter/shop closure matrix for the twelve professions +currently offered by character creation. It connects the issued combat tools, +supported early purchases and shared recovery path. It does not certify A7's +all-faction mission loop, level-1..10 encounter balance or progression pace. +Full historical profession catalogs remain deferred. + +## Issued tools and applicable purchases + +Every row uses the actual issued inventory in `browserStartingItems_locked`, +not a substitute starting kit. Crystal/program identities are listed in +[character creation](character-creation.md). The purchased subset and all three +faction terminal bindings are in [early shop stock](early-shop-stock.md). + +| Profession | Supported issued combat tools and nanos | Applicable early shop upgrade | Detailed behavior evidence | +| --- | --- | --- | --- | +| Soldier | Solar assault rifle, Burst/Fling; Body Boost | E-Beamer or M-10; Minor Combat Barrier | [Burst](burst.md), [Fling](fling-shot.md), [maximum health](nano-health-buffs.md) | +| Martial Artist | Fists, Brawl/Dimach, Jab of the Snake; Lesser Controlled Rage | Toughen Skin; Martial Arts Proficiency | [Jab](jab-of-the-snake.md), [Brawl](brawl.md), [Dimach](dimach.md), [skill buffs](nano-skill-buffs.md) | +| Engineer | Solar pistol; Swift Weapon; issued robot shell and Feeble Automaton formula | M-10; Greater Armor Megaboost | [robot lifecycle](engineer-robots.md), [skill buffs](nano-skill-buffs.md) | +| Fixer | Solar SMG, Burst; Minor Suppressor | Kerans; Basic Insurance Hack | [Burst](burst.md), [periodic healing](nano-healing.md#periodic-healing-contracts) | +| Agent | Solar rifle, Aimed Shot; Shadow Veil and Minor Nano Augmentation | Gripo; Lesser Suspicious Death | [concealed opening shot](aimed-shot.md), [combat buffs](nano-combat-buffs.md), [skill buffs](nano-skill-buffs.md) | +| Adventurer | Solar pistol; Quick Heal | M-10; Rough Stitching | [direct healing](nano-healing.md), [pistols](catalog-weapons.md) | +| Trader | Solar shotgun, Fling; Weak Health Funnel and Weak Delayed Health Payment | Vektor; Balanced Striker | [health drain](nano-health-drains.md), [team heal and debt](trader-health-payment.md), [Fling](fling-shot.md) | +| Bureaucrat | Solar pistol; Winter's Bite and Momentary Daze | M-10; Lesser Illusory Paralysis | [direct damage](nano-direct-damage.md), [control effects](nano-control.md) | +| Enforcer | Baseballbat, Fast Attack/Brawl/Dimach; Thug's Delight | Sledgehammer; Threat of the Bully | [Brawl](brawl.md), [Dimach](dimach.md), [Sledgehammer](sledgehammer.md) | +| Doctor | Solar pistol; Improved Healing and Prototype Biotoxin | M-10; Inferior Wound Bindings | [direct healing](nano-healing.md), [periodic damage](nano-periodic-damage.md) | +| Nano-Technician | Solar pistol; Ice Flechette and Malaise of Movement | Fire Stream; M-10 | [damage and linked debuff](nano-initiative-debuffs.md), [control effects](nano-control.md) | +| Meta-Physicist | Meta Shield; Lesser Anger Manifestation and Mind Pain | Inferior, Greater and Supreme Anger Manifestation | [pet attacks](pet-attack.md), [Mind Pain](nano-initiative-debuffs.md#meta-physicist-starter-mind-pain), [pet stock](early-shop-stock.md#meta-physicist-pet-upgrades) | + +All professions receive the same combined health/nano laboratory and First Aid +kit. Their supported use, charge/lock conservation and combat delivery are in +[First Aid](first-aid.md) and [treatment kits](treatment-kit.md). The four training +terminals and each faction's basic medical terminal sell supported replenishment. +Ordinary sitting/idle recovery also works. Basic armor provides low-cost QL1/2 +Low-Tech pieces and QL5 Metaplast through the same wear and ownership path; +see [early armor](early-armor.md) and [shops](shops.md). + +These are alternatives and staged upgrades, not a recommendation to train every +weapon/nano skill at once. All rows retain original requirements. Engineer's +four-credit replacement shell follows use of the already-issued shell; that +cost does not prevent the initial robot. More robot tiers, heal pets, charms, +full profession nano lines and exact historical stealth remain deferred catalog +or balance work unless an A7 encounter demonstrates a required dependency. + +## Closure checks + +The new `TestCreatedProfessionsCanLearnTheirIssuedCrystalsAtLevelOne` creates a +normal Solitus of each profession through the account endpoint. It trains only +the skills needed by that issued kit through the normal skill-training handler, +spends the character's starting 1500 IP, and uploads all nineteen actual issued +crystals through inventory Use. No levels, cash, items or skills are granted. +It verifies the exact consumed crystals, unchanged remaining inventory, learned +programs, zero earned XP/cash, and cold recovery of the complete inventory and +trained stats. Separate characters share one world fixture; a single cold load +checks their independent ownership. + +This admission check complements existing effect regressions, rather than +substituting upload success for usable behavior: + +- Original starter weapons have equip/requirement/removal/cold checks. Solar + shotgun Fling and the recent Burst, Brawl, Dimach, Jab and Aimed Shot checks + establish the special paths. Their documents identify the exact native cases. +- Maximum-health, ordinary-skill, combat-buff, direct-healing, control and + periodic-damage tests execute full effects and check expiry/removal/recovery. + Dedicated tests cover Winter's Bite, Ice Flechette/Mind Pain's linked debuffs, + both Trader starter contracts, pet combat and Engineer shell activation. +- All 66 crystal/faction purchase combinations and 36 weapon/faction/quality + combinations are covered by the shop regressions. Retained native runs visit + all 39 crystal placements, the three weapon terminals and all four training + terminals, using purchases and applicable stock. Armor and medical purchases + have their own native three-faction evidence in the linked documents. +- The 190-placement census checks 70 stocked terminals and 120 named unsupported + purchase notices. The latter retain sales and do not pretend to offer stock. + All scoped shops have native browse, buy/use, sale, cancel/retry and reconnect + evidence. Atomic transaction failures and exact cold ownership use the shared + A6 inventory/reward regressions. +- Original prices fit the documented 500-credits-per-mission-level policy. + All-faction level 1/5/10 settlement and resupply checks establish the budget; + the retained ordinary level-two Omni mission funds armor and replenishment + without grants or selling issued equipment. Higher-level/profession pace + remains A7, not an inferred result of funded fixtures. + +There is no remaining named A5 profession contract gap after the recent +implementations. A5 is closed by the admission/effect checks and native coverage below; +a new player-visible failure reopens the relevant gate. A7 still requires its +finite encounter and faction/profession progression matrix. + +## November 5 result + +All twelve ordinary level-one Solitus cases pass, uploading nineteen crystals +and retaining 1394..1474 of the starting 1500 IP. All learned programs, trained +stats, remaining items and the shared item allocator survive cold recovery. +The check takes 5.43 seconds after package initialization. Twenty-one selected +existing effect/stock roots also pass, covering the full contracts and category +boundaries cited above. Logs are `local/alpha-profession-paths/verified.log` +and `created-final.log`; the latter resolves the new test's initial fixture +assertions about Use sequence numbers and sorted persistent program order. + +The retained native armor evidence was Omni-only. New `TestBrowserBasicShopArmor` +and `tools/client/test_basic_shop_armor.mjs` fill the Clan/Neutral gap with real +right-click/E, cancel/retry, QL1 glove purchase, wear and reconnect. Each buys +70562 for 131 credits from 1000, keeps 869, and gains 3 ProjectileAC. The server checks +the exact owned instance, slot 24, all inventory fields and armor after cold +startup. Native inventory, cash and effective armor agree. The initial draft +waited for an owned identity on the unbound purchase proxy; the final driver +observes its actual template before wear and checks the owned ID after reconnect. + +Both native cases pass in 32.03 seconds. Inspected captures and traces are under +`local/alpha-basic-armor/20261105-175749/{c021049c,c00d04a2}/`; the log is +`local/alpha-profession-paths/armor-browser-final.log`. The earlier Omni armor +and three-faction medical artifacts remain in `local/old/early-armor-research/`, +`local/old/low-tech-set/` and `local/old/charged-shop-smoke/`. Recent weapon, +crystal, pet-stock, unsupported-category and affordability logs were also checked. +The pet-stock combined log ends with an obsolete Bookstore-fixture failure; +its nine pet cases passed, and `local/alpha-mp-upgrades/bookstores-final.log` +separately proves the corrected three-faction Bookstore run. + +No production gameplay behavior or historical rule changed in this closure +audit. It adds the missing coverage and reconciles the completed implementations +with A5's finite acceptance criteria. It does not close A1, A7 or the P1 work. + +Go vet, JavaScript syntax, local document links and diff checks pass. The owned +native browsers and isolated test servers exited after the scenarios. diff --git a/docs/early-shop-stock.md b/docs/early-shop-stock.md @@ -15,6 +15,13 @@ contain four ammunition packages and twelve weapon rows. All 39 profession and general crystal terminals now stock an early subset, leaving 120 empty placements. The three Meta-Physicist terminals include the pet upgrades below. +A5 closed on November 5 after the [twelve-profession closure audit](alpha-profession-paths.md). +All nineteen issued crystals now pass normal level-one training/upload and cold +recovery. The last missing native armor cases, Clan and Neutral buy/wear/reconnect, +also pass. Earlier statements below about remaining profession essentials describe +the scope at those checkpoints; the closure matrix records the current status. +A7 retains faction/profession progression, encounter balance and pace checks. + ## Mission cash and resupply The retained [ordinary starter run](starter-progression.md#maintained-fresh-earned-level-and-recovery-loop) @@ -362,7 +369,7 @@ run. There was no extended progression or historical stock search. These checks complete this fixed stock subset, not the remaining A5 profession, specialty-label or affordability requirements. -### Remaining profession essentials +### Profession essentials Stock is not a claim that each profession has its complete early combat path. [Engineer Feeble Automaton](engineer-robots.md) (43329 -> 43325) now creates diff --git a/server/browser_basic_shop_armor_test.go b/server/browser_basic_shop_armor_test.go @@ -0,0 +1,105 @@ +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 TestBrowserBasicShopArmor(t *testing.T) { + if os.Getenv("AO_GAME_TEST") != "1" { + t.Skip("set AO_GAME_TEST=1 for the three basic armor terminals") + } + _, source, _, _ := runtime.Caller(0) + root := filepath.Dir(filepath.Dir(source)) + output := filepath.Join(root, "local/alpha-basic-armor", time.Now().Format("20060102-150405")) + for _, identity := range []uint32{3221226655, 3223389340, 3222078626} { + 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{1183: 0x515, 1180: 0x315, 1186: 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 funds and minimum QL1 glove abilities; no earned-progress claim. + player.stats.Abilities.Strength, player.stats.Abilities.Agility = 8, 8 + player.stats.TradeRepair.ComputerLiteracy = 0 + player.health, player.nano = player.maximumHealth(), player.maximumNano() + player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("basic-shop-armor"))) + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + inventory := playerInventory{Credits: 1000} + 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, 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{"machine": identity, "playfield": machine.Playfield, + "open": open, "purchases": purchases, "inventory": player.inventory, + "armor": player.equipmentBonus(90)}) + }) + host := httptest.NewServer(mux) + defer host.Close() + defer closeTestSessions(t, world) + ctx, cancel := context.WithTimeout(context.Background(), 2*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) + world.advanceEquipment(now) + case <-ctx.Done(): + return + } + } + }() + defer func() { cancel(); <-stopped }() + command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_basic_shop_armor.mjs"), host.URL, filepath.Join(output, fmt.Sprintf("%x", identity))) + command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr + err := command.Run() + cancel() + <-stopped + closeTestSessions(t, world) + t.Logf("Browser artifacts: %s", filepath.Join(output, fmt.Sprintf("%x", identity))) + if err != nil { + t.Fatal(err) + } + cold := newTestInventoryServer(t).characters[player.id] + if !reflect.DeepEqual(cold.inventory, player.inventory) || cold.equipmentBonus(90) != 3 || len(cold.inventory.Items) != 1 || cold.inventory.Items[0].Template != 70562 || cold.inventory.Items[0].Slot != 24 { + t.Fatal("native armor purchase/wear did not recover") + } + }) + } +} diff --git a/server/starter_professions_test.go b/server/starter_professions_test.go @@ -0,0 +1,100 @@ +package main + +import ( + "encoding/binary" + "fmt" + "net/http" + "reflect" + "slices" + "testing" +) + +func TestCreatedProfessionsCanLearnTheirIssuedCrystalsAtLevelOne(t *testing.T) { + world := newTestServer(t) + var created []uint32 + for _, scenario := range []struct { + profession uint16 + skills map[uint32]uint16 + crystals, programs []uint32 + }{ + {1, map[uint32]uint16{128: 8, 130: 6}, []uint32{29092}, []uint32{29091}}, + {2, map[uint32]uint16{129: 8, 122: 7}, []uint32{43382}, []uint32{43369}}, + {3, map[uint32]uint16{130: 7, 131: 7, 127: 7, 122: 6}, []uint32{43329, 29194}, []uint32{43325, 29188}}, + {4, map[uint32]uint16{129: 9, 122: 8}, []uint32{43380}, []uint32{43370}}, + {5, map[uint32]uint16{127: 7, 122: 9, 129: 8}, []uint32{43383, 29191}, []uint32{43367, 29153}}, + {6, map[uint32]uint16{128: 7, 127: 6}, []uint32{28742}, []uint32{26695}}, + {7, map[uint32]uint16{128: 9, 131: 8}, []uint32{43378, 78417}, []uint32{43374, 76742}}, + {8, map[uint32]uint16{129: 8, 131: 7, 130: 7}, []uint32{43381, 29625}, []uint32{43368, 29618}}, + {9, map[uint32]uint16{129: 7, 122: 6}, []uint32{43379}, []uint32{43371}}, + {10, map[uint32]uint16{128: 9, 127: 6, 130: 8}, []uint32{28778, 43384}, []uint32{28665, 43376}}, + {11, map[uint32]uint16{130: 9, 131: 7}, []uint32{28815, 42111}, []uint32{28612, 42110}}, + {12, map[uint32]uint16{130: 8, 131: 7, 129: 6}, []uint32{43330, 29193}, []uint32{43324, 29114}}, + } { + t.Run(fmt.Sprint(scenario.profession), func(t *testing.T) { + fields := creationForm() + fields.Set("profession", fmt.Sprint(scenario.profession)) + fields.Set("name", fmt.Sprintf("Profession%d", scenario.profession)) + if response := creationRequest(world, accountVisitor(t, world), fields); response.Code != http.StatusNoContent { + t.Fatal(response.Code, response.Body.String()) + } + player := world.characters[world.nextCharacter] + client := &worldClient{id: player.id, conn: &combatTestConn{}, target: true, ready: true} + world.clients[player.id] = client + created = append(created, player.id) + before := slices.Clone(player.inventory.Items) + + // Train only the nano skills needed by this Solitus starter kit, using its IP. + trained := player.baseStats() + for _, field := range trained.trainingStats() { + if value, ok := scenario.skills[field.stat]; ok { + *field.value = value + } + } + request := skillTrainingRequest(trained) + binary.BigEndian.PutUint32(request[28:32], player.id) + if err := world.handleSkillTraining(client, request[20:]); err != nil { + t.Fatal(err) + } + if player.stats.ImprovementPoints >= 1500 || player.level != 1 { + t.Fatal("starter training was refused") + } + for _, field := range player.stats.trainingStats() { + if value, ok := scenario.skills[field.stat]; ok && *field.value != value { + t.Fatal("starter training exceeded its cap or budget", field.stat, *field.value, value) + } + } + + // Upload the exact issued instances through ordinary inventory Use requests. + remaining := slices.Clone(before) + for sequence, crystal := range scenario.crystals { + index := slices.IndexFunc(before, func(item ownedItem) bool { return item.Template == crystal }) + if index < 0 { + t.Fatal("missing issued crystal", crystal) + } + if err := world.handleOwnedItemUse(client, backpackUseRequest(player.id, before[index].Slot, uint32(sequence+1))[20:]); err != nil { + t.Fatal(err) + } + remaining = slices.DeleteFunc(remaining, func(item ownedItem) bool { return item.Template == crystal }) + } + + if !slices.Equal(player.inventory.LearnedNanos, scenario.programs) || !reflect.DeepEqual(player.inventory.Items, remaining) || player.experience != 0 || player.inventory.Credits != 0 { + t.Fatal("issued crystal admission changed the starter kit", player.inventory.LearnedNanos, scenario.programs) + } + t.Logf("profession %d: %d issued crystals learned, %d IP remaining", scenario.profession, len(scenario.crystals), player.stats.ImprovementPoints) + }) + } + + // Recover all independently owned kits together without rebuilding world fixtures. + cold := newTestInventoryServer(t) + if cold.nextItem != world.nextItem { + t.Fatal("recovery changed the shared item allocator") + } + for _, id := range created { + player, restored := world.characters[id], cold.characters[id] + programs := slices.Clone(player.inventory.LearnedNanos) + slices.Sort(programs) + if !reflect.DeepEqual(player.inventory.Items, restored.inventory.Items) || !slices.Equal(programs, restored.inventory.LearnedNanos) || restored.inventory.Credits != 0 || !reflect.DeepEqual(player.stats, restored.stats) || restored.level != 1 || restored.experience != 0 { + t.Fatal("starter learning or training changed on recovery", id) + } + } +} diff --git a/tools/client/test_basic_shop_armor.mjs b/tools/client/test_basic_shop_armor.mjs @@ -0,0 +1,76 @@ +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: 'basic-shop-armor', 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, button = 'left') => { + assert(source, 'expected native catalog/inventory cell'); + await game.click((source.bounds[0]+source.bounds[2])/2, (source.bounds[1]+source.bounds[3])/2, button); + }; + 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('basic armor catalog opens', state => state.grids.some(grid => + grid.rows === 4 && grid.cells.some(cell => cell.identity[0] === 111 && cell.identity[1] === 6 && !cell.dummy))); + }; + await open(false); + await game.save(output + '/catalog'); + await click(cell(111, 6)); + await waitServer('gloves selected for cancellation', state => state.purchases === 1); + await game.click(945, 475); + await waitServer('cancelled without charge', state => !state.open); + assert.deepEqual((await server()).inventory, evidence.before.inventory); + + await open(true); + await click(cell(111, 6)); + await waitServer('gloves selected again', state => state.purchases === 1); + await game.click(873, 475); + await waitServer('purchase committed', state => !state.open && state.inventory.Items.length === 1); + evidence.purchased = await server(); + assert.equal(evidence.purchased.inventory.Credits, evidence.before.playfield === 1183 ? 875 : 869); + assert.deepEqual(evidence.purchased.inventory.Items.map(item => [item.ID, item.Template, item.Quality, item.Count, item.Slot]), [[1, 70562, 1, 1, 64]]); + await game.wait('native gloves delivered', state => game.local(state).inventory.some(item => item.templates[0] === 70562 && item.slot === 48)); + await click(cell(104, 48), 'right'); + await waitServer('server wears purchased gloves', state => state.inventory.Items[0].Slot === 24 && state.armor === 3); + await game.wait('native armor agrees', state => game.local(state).effectiveArmor[0] === 3); + evidence.worn = await server(); + await game.save(output + '/worn'); + + await page.reload(); + await game.ready(); + await game.wait('native armor retained', state => game.local(state).effectiveArmor[0] === 3); + evidence.reconnected = await server(); + assert.deepEqual(evidence.reconnected.inventory, evidence.worn.inventory); + assert.equal(game.local().stats[61], evidence.worn.inventory.Credits); + assert(game.local().inventory.some(item => item.id === 1 && item.slot === 24)); + await game.save(output + '/reconnected'); + assert.deepEqual(game.errors, []); + console.log('PASS:', evidence.before.playfield, 'native basic armor cancel, purchase, wear 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(); } +}