commit b617f411c82f6672141dd25dd3d17b400a6e31e7
parent b983571b089fe747ffb43db2920f083cc32cf5a6
Author: anon <anon@example.com>
Date: Tue, 3 Nov 2026 01:09:26 +0000
Permit idle weapon moves while receiving attacks
Diffstat:
8 files changed, 396 insertions(+), 11 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -752,6 +752,9 @@ Normal-hit additions and weapon-range modifiers are described in
[equipment replacement](docs/inventory.md#occupied-equipment-replacement).
- [ ] [P1] Swap a weapon during combat. Check: swapping cannot bypass an existing
recharge or leave results queued for a removed weapon.
+ Incoming-only attacks now permit idle-owner weapon moves; this does not
+ establish active-player swap timing. Native binding resets its weapon timers,
+ but original authoritative recharge policy across replacement remains open.
The QL 1 Flechette Pistol and Bullets are the verified example. Native reload
replies update the loaded count at reload start and block firing until the
@@ -3631,6 +3634,10 @@ and server restarts. Turn every reproduced bug into a focused regression test.
supported bat/HeadText wear and page/cold replay retain all three fixture
instances. This focused rejection case leaves the broader audit open; see
[weapon wear admission](docs/weapon-wear-admission.md).
+ Idle-owner weapon wear, replacement and removal now survive incoming attacks,
+ including an opponent starting during the equip delay. Real native requests,
+ incoming damage, unchanged opponent clocks and both retained instances have
+ focused checks; see [incoming attacks](docs/inventory.md#weapon-moves-during-incoming-attacks).
The known occupied-hand rejection is now fixed using the recovered combined
delay and native slot exchange. Three replacements with a full ordinary
inventory retain all31 identities through two-client page and cold recovery;
diff --git a/docs/corpse-pose.md b/docs/corpse-pose.md
@@ -165,3 +165,12 @@ transforms. Extend the facing control to flat ground, warm transitions,
cold replay and scene reentry. Distinguish a current placement defect from
behavior inherent in the original clip. Keep the existing animation resources
and generic skeleton math unless contrary evidence identifies a defect.
+
+The public [MMSys2012 server trace](https://web.cs.wpi.edu/~claypool/mmsys-dataset/2012/anarchy/)
+cannot establish corpse anchors. Its first64KiB contains931 complete records
+with no TCP payload bytes; the authors' paper, section3, explicitly describes
+headers-only recording. This is Petlund, Halvorsen, Hansen, Lindgren, Casais and
+Griwodz, *Network Traffic from Anarchy Online: Analysis, Statistics and
+Applications*, MMSys2012, pp95-100. The bounded sample, source headers, TShark
+results and limitations are retained in `local/corpse-placement-research/`.
+No original placement rule follows from the transport lengths alone.
diff --git a/docs/inventory.md b/docs/inventory.md
@@ -352,8 +352,45 @@ remains at its source until the delay completes and the complete inventory
saves atomically. Repeated inventory requests cannot restart the timer or remove
the pending item. Completion rechecks requirements, destination occupancy and
session state. Full inventory and failed saves preserve the equipped item.
-Equipping during combat or outstanding recharge is currently rejected; combat
-swapping is not yet implemented, and this restriction is not a historical rule.
+The owner's active attack or outstanding recharge currently rejects weapon
+swaps; this restriction is not a recovered historical rule. Incoming attacks
+alone permit the weapon moves described below.
+
+### Weapon moves during incoming attacks
+
+An idle player can equip, replace or remove a weapon while another creature
+attacks. Previously any opponent targeting the player vetoed admission and
+cancelled an already pending move at completion. `equipmentBlocked_locked` now
+distinguishes the item and whose attack is active. Own attacks/recharge and
+other equipment's existing combat restrictions remain enforced, including
+ground and flying vehicles. Inventory transactions and replication are unchanged.
+
+The original equipment action belongs to the recipient's controller:
+`client/game/kkr.dll/lifted-0029.c::sub_36062830` schedules category6 through
+`sub_360529A0` in `lifted-0026.c`. It does not suspend the opponent's clock.
+The separate active-player swap milestone remains open: native binding resets
+weapon timers, but original authoritative recharge policy across replacement
+has not been established. Complete original REA records and those limits are
+under `local/combat-weapon-swap/`.
+
+`server/incoming_equipment_test.go` covers an attacker present at admission or
+starting during the delay, all three weapon moves, an actual incoming hit,
+unchanged opponent clocks, cold identity conservation and retained own-attack/
+recharge refusals. The short controlled two-client WASM fixture uses an original
+Leet and two granted weapons, with legal level100 skills and deterministic hits.
+It verifies actual equipment requests, an8-point hit before the replacement
+acknowledgement, removal/re-equip while still attacked, observer isolation and
+page/fresh-server retention of both complete instances. This is isolated fixture
+evidence, not earned progression. Captures and independent packet/identity
+checks are under `local/incoming-equipment/`.
+
+Final normal checks pass76 roots/352 individual results in51.456s. The three
+incoming-weapon roots and four preserved vehicle-gate roots also pass the race
+detector:42 individual results in105.751s. The final WASM run passes90.40s
+(live57.58, cold32.82), or98.097s including Go. It accounts for24 incoming
+damage and both items with no errors/dropped events in all ten retained traces.
+Vet, Node syntax, gofmt and whitespace checks pass. Final captures are under
+`local/incoming-equipment/20261102-170648/`.
### Occupied equipment replacement
diff --git a/server/browser_incoming_equipment_test.go b/server/browser_incoming_equipment_test.go
@@ -0,0 +1,137 @@
+package main
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestBrowserIncomingEquipment(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for equipment during incoming combat")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/incoming-equipment", time.Now().Format("20060102-150405"))
+ t.Chdir(t.TempDir())
+ for _, phase := range []string{"live", "cold"} {
+ if !t.Run(phase, func(t *testing.T) {
+ world := newServer()
+ world.combatRoll = landedCombatRoll
+ t.Cleanup(func() { world.db.Close() })
+ var npc *character
+ for _, actor := range world.characters {
+ if actor.npc && actor.playfield == 950 && actor.monsterData == 17655 && actor.level == 1 && actor.combatProfile != nil && (npc == nil || actor.id < npc.id) {
+ npc = actor
+ }
+ }
+ if npc == nil {
+ t.Fatal("no admitted Leet for incoming combat")
+ }
+ if phase == "live" {
+ for index := 0; index < 2; index++ {
+ player := world.newCharacter()
+ player.name, player.profession, player.level, player.appearance = fmt.Sprint("Incoming", index), 9, 100, 0x315
+ player.position, player.rotation = npc.position, [4]float32{0, 0, 0, 1}
+ player.position[2] -= float32(2 + index*3)
+ player.stats.Abilities = characterAbilitiesStats{200, 200, 200, 200, 200, 200}
+ player.stats.Melee.OneHandBlunt, player.stats.Melee.OneHandEdged, player.stats.Melee.FastAttack = 20, 20, 20
+ player.stats.Body.Brawling, player.stats.Body.Dimach = 20, 20
+ player.health, player.nano = player.maximumHealth(), player.maximumNano()
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte(fmt.Sprint("incoming-", index))))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ }
+ for _, template := range []uint32{209283, 122691} {
+ if granted, err := world.grantItem_locked(world.characters[1], template); !granted || err != nil {
+ t.Fatal(granted, err)
+ }
+ }
+ world.characters[1].inventory.Items[0].Slot = 6
+ world.characters[1].inventory.Items[1].Slot = 64
+ world.characters[1].inventory.Items[1].Quality = 3
+ if err := world.saveInventory_locked(world.characters[1], world.characters[1].inventory); err != nil {
+ t.Fatal(err)
+ }
+ }
+ owner := 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()
+ pending := world.clients[1] != nil && world.clients[1].equipment != nil
+ json.NewEncoder(w).Encode(map[string]any{"inventory": owner.inventory, "health": owner.health,
+ "pending": pending, "fighting": owner.fighting, "npc": npc.id, "target": npc.fighting,
+ "attack": npc.nextAttack, "recharge": npc.rechargeUntil})
+ })
+ // Controlled aggression isolates an idle recipient; no earned progression is claimed.
+ for _, action := range []string{"start", "stop"} {
+ mux.HandleFunc("POST /test-"+action, func(w http.ResponseWriter, r *http.Request) {
+ world.updateMutex.Lock()
+ defer world.updateMutex.Unlock()
+ world.mutex.Lock()
+ updates := make(map[*worldClient][][]byte)
+ if action == "start" {
+ world.startAttack_locked(npc, owner, time.Now(), updates)
+ } else {
+ world.stopAttack_locked(npc, updates)
+ }
+ world.mutex.Unlock()
+ world.sendCombatUpdates(updates)
+ w.WriteHeader(http.StatusNoContent)
+ })
+ }
+ 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.advanceCombat(now)
+ world.advanceEquipment(now)
+ case <-ctx.Done():
+ return
+ }
+ }
+ }()
+ defer func() { cancel(); <-stopped }()
+
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_incoming_equipment.mjs"), host.URL, filepath.Join(output, phase), phase)
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+ cancel()
+ <-stopped
+ t.Logf("Browser artifacts: %s", output)
+
+ expected := []ownedItem{
+ {ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 64, Count: 1},
+ {ID: 2, Type: 51018, Template: 122691, Quality: 3, Slot: 6, Count: 1},
+ }
+ if err != nil || !slices.Equal(owner.inventory.Items, expected) || owner.fighting != 0 || owner.health == 0 ||
+ owner.inventory.Credits != 0 || len(world.characters[2].inventory.Items) != 0 || world.nextItem != 2 {
+ t.Fatal("incoming combat changed equipment conservation or the idle recipient", err, owner.inventory)
+ }
+ }) {
+ return
+ }
+ }
+}
diff --git a/server/equipment.go b/server/equipment.go
@@ -170,13 +170,14 @@ func equipmentCorrectionPackets(owner, source uint32) [][]byte {
return [][]byte{itemMovePacket(owner, source, other), itemMovePacket(owner, other, source)}
}
-func (server *server) equipmentBlocked_locked(character *character, now time.Time) bool {
- // Combat swaps are a separate milestone; do not replace an active attack phase.
+func (server *server) equipmentBlocked_locked(character *character, item ownedItem, now time.Time) bool {
+ // Incoming hits do not interrupt an idle player's weapon move.
+ // Own combat swaps and other equipment's combat restrictions remain separate.
if now.Before(character.rechargeUntil) {
return true
}
for _, attacker := range server.fighting {
- if attacker.id == character.id || attacker.fighting == character.id {
+ if attacker.id == character.id || attacker.fighting == character.id && !item.isWieldableWeapon() {
return true
}
}
@@ -207,7 +208,7 @@ func (server *server) beginEquipment_locked(client *worldClient, index int, dest
replaced := slices.IndexFunc(character.inventory.Items, func(other ownedItem) bool { return other.Slot == destination })
if destination == item.Slot || destination >= 94 || !character.canMoveEquipment(item, destination, time.Now()) ||
replaced >= 0 && (item.Slot < 64 || destination >= 64 || !character.canMoveEquipment(character.inventory.Items[replaced], item.Slot, time.Now())) ||
- server.equipmentBlocked_locked(character, time.Now()) {
+ server.equipmentBlocked_locked(character, item, time.Now()) {
for _, packet := range equipmentCorrectionPackets(client.id, item.Slot) {
if err := client.send(packet); err != nil {
return err
@@ -250,7 +251,7 @@ func (server *server) advanceEquipment(now time.Time) {
if replaced >= 0 {
replacedID = character.inventory.Items[replaced].ID
}
- if server.equipmentBlocked_locked(character, now) || replacedID != move.replacedID ||
+ if server.equipmentBlocked_locked(character, character.inventory.Items[index], now) || replacedID != move.replacedID ||
!character.canMoveEquipment(character.inventory.Items[index], move.destination, now) ||
replaced >= 0 && !character.canMoveEquipment(character.inventory.Items[replaced], move.source, now) {
updates[client] = append(updates[client], equipmentCorrectionPackets(client.id, move.source)...)
diff --git a/server/equipment_test.go b/server/equipment_test.go
@@ -258,7 +258,7 @@ func TestEquipmentRejectedWearRestoresFullNativeInventory(t *testing.T) {
}
func TestEquipmentCompletionRechecksStateAndPreservesFailedSave(t *testing.T) {
- for _, scenario := range []string{"requirements", "own combat", "incoming combat", "recharge", "loading", "dead", "replaced session", "failed save"} {
+ for _, scenario := range []string{"requirements", "own combat", "recharge", "loading", "dead", "replaced session", "failed save"} {
t.Run(scenario, func(t *testing.T) {
world, _ := newEquipmentWorld(t)
world.handleInventory(world.clients[1], inventoryMovePacket(1, 64, 6)[20:])
@@ -269,9 +269,6 @@ func TestEquipmentCompletionRechecksStateAndPreservesFailedSave(t *testing.T) {
case "own combat":
world.characters[1].fighting = 1000000
world.fighting[1] = world.characters[1]
- case "incoming combat":
- world.characters[1000000].fighting = 1
- world.fighting[1000000] = world.characters[1000000]
case "recharge":
world.characters[1].rechargeUntil = finish.Add(time.Second)
case "loading":
diff --git a/server/incoming_equipment_test.go b/server/incoming_equipment_test.go
@@ -0,0 +1,107 @@
+package main
+
+import (
+ "bytes"
+ "fmt"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestIncomingCombatPermitsEquipmentAdmissionAndCompletion(t *testing.T) {
+ for _, move := range []string{"equip", "replace", "remove"} {
+ for _, alreadyAttacked := range []bool{false, true} {
+ t.Run(fmt.Sprintf("%s/attackedBeforeRequest=%t", move, alreadyAttacked), func(t *testing.T) {
+ world, _ := newEquipmentReplacementWorld(t)
+ player, npc, client := world.characters[1], world.characters[1000000], world.clients[1]
+ source, destination := uint32(64), uint32(6)
+ expected := []ownedItem{
+ {ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 64, Count: 1},
+ {ID: 2, Type: 51018, Template: 122691, Quality: 3, Slot: 6, Count: 1},
+ }
+ if move == "equip" {
+ player.inventory.Items[0].Slot, expected[0].Slot = 65, 65
+ } else if move == "remove" {
+ source, destination, expected[0].Slot, expected[1].Slot = 6, 111, 65, 64
+ }
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ before := slices.Clone(player.inventory.Items)
+ npc.nextAttack, npc.rechargeUntil = time.Now().Add(10*time.Second), time.Now().Add(8*time.Second)
+ attack, recharge := npc.nextAttack, npc.rechargeUntil
+ if alreadyAttacked {
+ npc.fighting, world.fighting[npc.id] = player.id, npc
+ }
+
+ if err := world.handleInventory(client, itemMovePacket(1, source, destination)[20:]); err != nil || client.equipment == nil {
+ t.Fatal("another actor's attack refused valid equipment", err)
+ }
+ deadline := client.equipment.readyAt
+ npc.fighting, world.fighting[npc.id] = player.id, npc
+ world.advanceEquipment(deadline.Add(-time.Nanosecond))
+ if !slices.Equal(player.inventory.Items, before) {
+ t.Fatal("equipment committed before its original delay")
+ }
+ world.advanceEquipment(deadline)
+ cold := newTestInventoryServer(t).characters[1]
+
+ if client.equipment != nil || !slices.Equal(player.inventory.Items, expected) || !slices.Equal(cold.inventory.Items, expected) ||
+ player.fighting != 0 || npc.fighting != 1 || npc.nextAttack != attack || npc.rechargeUntil != recharge {
+ t.Fatal("incoming combat interrupted equipment, changed attack timing or lost an instance", player.inventory.Items)
+ }
+ })
+ }
+ }
+}
+
+func TestIncomingHitDuringEquipmentPreservesTheOpponentAttackClock(t *testing.T) {
+ world, _ := newEquipmentReplacementWorld(t)
+ player, npc, client := world.characters[1], world.characters[1000000], world.clients[1]
+ world.startAttack_locked(npc, player, time.Now(), make(map[*worldClient][][]byte))
+ first := npc.nextAttack
+
+ if err := world.handleInventory(client, inventoryMovePacket(1, 64, 6)[20:]); err != nil || client.equipment == nil {
+ t.Fatal("incoming combat refused replacement", err)
+ }
+ deadline := client.equipment.readyAt
+ world.advanceCombat(first)
+ attack, recharge := npc.nextAttack, npc.rechargeUntil
+ if player.health >= 100 || client.equipment == nil || player.inventory.Items[0].Slot != 6 {
+ t.Fatal("incoming hit was suppressed or prematurely committed equipment")
+ }
+ world.advanceEquipment(deadline)
+
+ if player.inventory.Items[0].Slot != 64 || player.inventory.Items[1].Slot != 6 || player.fighting != 0 ||
+ npc.fighting != player.id || npc.nextAttack != attack || npc.rechargeUntil != recharge || !recharge.After(first) {
+ t.Fatal("replacement stopped, restarted or accelerated the opponent")
+ }
+}
+
+func TestIncomingCombatDoesNotBypassOwnAttackOrRechargeEquipmentGates(t *testing.T) {
+ for _, phase := range []string{"attack", "recharge"} {
+ t.Run(phase, func(t *testing.T) {
+ world, output := newEquipmentReplacementWorld(t)
+ player, npc, client := world.characters[1], world.characters[1000000], world.clients[1]
+ npc.fighting, world.fighting[npc.id] = player.id, npc
+ if phase == "attack" {
+ player.fighting, world.fighting[player.id] = npc.id, player
+ } else {
+ player.rechargeUntil = time.Now().Add(time.Second)
+ }
+ before, err := readTestItemStore(world)
+ if err != nil {
+ t.Fatal(err)
+ }
+ output.packets = nil
+
+ err = world.handleInventory(client, inventoryMovePacket(1, 64, 6)[20:])
+ after, readErr := readTestItemStore(world)
+
+ if err != nil || readErr != nil || !bytes.Equal(before, after) || client.equipment != nil || len(output.packets) != 2 ||
+ player.inventory.Items[0].Slot != 6 || player.inventory.Items[1].Slot != 64 || npc.fighting != player.id {
+ t.Fatal("incoming combat bypassed an independent own-attack/recharge gate", err, readErr)
+ }
+ })
+ }
+}
diff --git a/tools/client/test_incoming_equipment.mjs b/tools/client/test_incoming_equipment.mjs
@@ -0,0 +1,90 @@
+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, phase] = process.argv.slice(2);
+const browser = await chromium.launch({executablePath: '/usr/bin/chromium', headless: false,
+ args: ['--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+const games = [], evidence = {moves: []};
+try {
+ for (let index = 0; index < 2; ++index) {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: 'incoming-' + index, url}]);
+ const page = await context.newPage(), game = await GameTest.attach(page);
+ games.push(game);
+ await page.goto(url);
+ await game.ready();
+ }
+ const [owner, observer] = games;
+ const state = async () => (await owner.page.request.get(url + '/test-state')).json();
+ evidence.initial = await state();
+ const npc = game => game.state.actors.find(actor => actor.type === 50000 && actor.id === evidence.initial.npc);
+ await Promise.all(games.map(game => game.wait('both players and original Leet', () =>
+ npc(game) && game.state.actors.some(actor => actor.id === 1) && game.state.actors.some(actor => actor.id === 2))));
+ if (phase === 'live') {
+ await owner.key('KeyI');
+ await owner.page.keyboard.press('Control+1');
+ assert((await owner.page.request.post(url + '/test-start')).ok());
+ await Promise.all(games.map(game => game.wait('actual incoming fight', () => npc(game).combatTarget === 1)));
+ assert.equal(owner.local().combatTarget, 0);
+ for (const action of ['replace', 'remove', 'equip']) {
+ await owner.wait('native equipment action finishes', snapshot =>
+ !owner.local(snapshot).actions.includes(3) && !owner.local(snapshot).actions.includes(6));
+ const before = await state(), sequence = owner.sequence;
+ if (action === 'remove') await owner.click(867, 206, 'right');
+ else {
+ const cell = owner.local().inventory.find(item => item.id === 2).slot - 48;
+ await owner.click(681 + cell % 3 * 54, 45 + Math.floor(cell / 3) * 54, 'right');
+ }
+ await owner.wait('real equipment request', () => owner.events.some(event =>
+ event.sequence > sequence && event.direction === 'framesent' && event.opcode === '47537a24'));
+ const pending = await state();
+ evidence.moves.push({action, before, pending});
+ await owner.save(output + '/' + action + '-pending');
+ assert.equal(pending.pending, true, 'Incoming attack refused valid native equipment');
+ assert.deepEqual(pending.inventory, before.inventory);
+ const slot = action === 'remove' ? 49 : 6;
+ await owner.wait('native equipment completes under attack', snapshot =>
+ owner.local(snapshot).inventory.some(item => item.id === 2 && item.slot === slot));
+ const after = await state();
+ evidence.moves.at(-1).after = after;
+ assert.equal(after.fighting, 0);
+ assert.equal(after.target, 1);
+ assert.equal(after.pending, false);
+ assert.deepEqual(owner.local().inventory.map(item => [item.id, item.slot, item.quality, item.count, item.templates]).sort((a, b) => a[0] - b[0]),
+ [[1, 48, 1, 1, [209283, 209283]], [2, slot, 3, 1, [122691, 122692]]]);
+ assert.equal(owner.local().combatTarget, 0);
+ assert(owner.local().weapons.every(weapon => weapon.pending.length === 0));
+ assert.equal(npc(owner).combatTarget, 1);
+ assert.equal(npc(observer).combatTarget, 1);
+ if (action === 'replace') {
+ const received = owner.events.filter(event => event.sequence > sequence && event.direction === 'framereceived');
+ const hit = received.find(event => event.opcode === '46002f16');
+ const acknowledgement = received.find(event => event.opcode === '47537a24');
+ assert(hit && acknowledgement && hit.sequence < acknowledgement.sequence, 'No real hit arrived during the equipment delay');
+ assert(after.health < pending.health);
+ }
+ await owner.save(output + '/' + action + '-complete');
+ }
+ assert((await state()).health < evidence.initial.health, 'Incoming combat did not actually hit');
+ assert((await owner.page.request.post(url + '/test-stop')).ok());
+ await Promise.all(games.map(game => game.wait('incoming result queue drains', () =>
+ npc(game).combatTarget === 0 && npc(game).weapons.every(weapon => weapon.pending.length === 0))));
+ for (const game of games) { await game.page.reload(); await game.ready(); }
+ }
+ assert.deepEqual(owner.local().inventory.map(item => [item.id, item.slot, item.quality, item.count]).sort((a, b) => a[0] - b[0]),
+ [[1, 48, 1, 1], [2, 6, 3, 1]]);
+ assert.deepEqual(observer.local().inventory, []);
+ evidence.final = {server: await state(), native: owner.local().inventory};
+ assert(games.every(game => game.errors.length === 0));
+ console.log('PASS:', phase, 'idle recipient replaces, removes and equips under real incoming hits; both instances survive page/cold recovery');
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2));
+ await Promise.all(games.map((game, index) => game.save(output + '/final-' + index)));
+ } finally { await browser.close(); }
+}