aorecomp

Anarchy Online classic in the browser

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


commit 69638a7d96ed81d1b8a6138b942c2c303c190247
parent 1c8b4c5a3b5ddc46f4d4673bd0a61cb3547594bd
Author: anon <anon@example.com>
Date:   Mon,  9 Nov 2026 02:24:59 +0000

Checkpoint browser fixture repairs and remaining verification

Repair controlled NPC health and loot fixtures, Dimach equipment setup,
mission fixture initialization and reward expectations, browser input setup,
and earned starter-loot accounting without changing production gameplay code.

Katana, Kerans, Kinetic Axe and Loose Katana full families passed with the
health fixture repair. Most other checkpointed repairs await full reruns.
Current Go browser inventory: 53 passed, 24 failed, 3 interrupted and 93
unattempted. Keep the full-suite TODO open and record the remaining work.

All 155 JS unit tests and all 19 JS browser scenarios have passing results;
WASM snapshot checks passed. At checkpoint, server test compilation, gofmt,
changed JavaScript syntax and diff checks pass. Preserve logs locally.

Diffstat:
Mserver/browser_aleph_test.go | 5+++++
Mserver/browser_corpse_peer_pickup_test.go | 5++++-
Mserver/browser_corpse_reentry_test.go | 5++++-
Mserver/browser_corpse_replay_test.go | 5++++-
Mserver/browser_dimach_test.go | 11++++++++---
Mserver/browser_e_beamer_test.go | 5+++++
Mserver/browser_east_wind_test.go | 2+-
Mserver/browser_edge_less_katana_test.go | 5+++++
Mserver/browser_engineer_robot_test.go | 5++++-
Mserver/browser_faction_insurance_test.go | 5++++-
Mserver/browser_faction_progression_test.go | 4++++
Mserver/browser_generated_mission_test.go | 13++++++++++++-
Mserver/browser_gripo_test.go | 5+++++
Mserver/browser_health_drain_test.go | 4++--
Mserver/browser_home_defender_test.go | 5+++++
Mserver/browser_katana_test.go | 5+++++
Mserver/browser_kerans_test.go | 5+++++
Mserver/browser_kinetic_axe_test.go | 5+++++
Mserver/browser_loose_katana_test.go | 5+++++
Mserver/browser_loot_refusal_test.go | 5++++-
Mserver/browser_nova_flow_test.go | 5+++++
Mserver/browser_sledgehammer_test.go | 5+++++
Mserver/browser_support_beam_test.go | 5+++++
Mserver/browser_team_loot_order_test.go | 5++++-
Mtools/client/test_dimach.mjs | 4+++-
Mtools/client/test_east_wind_cold.mjs | 2+-
Mtools/client/test_east_wind_reward.mjs | 2+-
Mtools/client/test_ground_drop.mjs | 8+++++---
Mtools/client/test_health_drain.mjs | 13+++++++------
Mtools/client/test_inventory_grid.mjs | 3++-
Mtools/client/test_starter_equipment.mjs | 31+++++++++++++++++++------------
31 files changed, 153 insertions(+), 39 deletions(-)

diff --git a/server/browser_aleph_test.go b/server/browser_aleph_test.go @@ -33,6 +33,10 @@ func TestBrowserAlephQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -70,6 +74,7 @@ func TestBrowserAlephQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = func(limit uint32) uint32 { if limit == 100 { diff --git a/server/browser_corpse_peer_pickup_test.go b/server/browser_corpse_peer_pickup_test.go @@ -36,10 +36,13 @@ func newBrowserCorpsePeerWorld(t *testing.T) *server { if _, err := world.changeTeam(teamCommand{actor: 1, action: 28, member: 2}, make(map[*worldClient][][]byte)); err != nil { t.Fatal(err) } + // Keep transfer fixtures to one known Monster Part. + profile := *gamedata.NPCCombatProfiles[17655][1] + profile.Loot = []gamedata.NPCLoot{{Template: 42640, Quality: [2]uint32{1, 1}, Chance: 50}} world.characters[1000000] = &character{id: 1000000, name: "Shared Leet", npc: true, level: 1, playfield: 705, position: [3]float32{960, 16.5, 514}, rotation: [4]float32{0, 0, 0, 1}, health: 1, appearance: 229, monsterData: 17655, npcDefinitionID: "950/district/2/group/0/authored_point", - combatProfile: gamedata.NPCCombatProfiles[17655][1]} + combatProfile: &profile} world.clients[1] = &worldClient{id: 1, target: true, ready: true, conn: &combatTestConn{}, npcs: map[uint32]bool{1000000: true}} world.combatRoll = func(uint32) uint32 { return 0 } if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { diff --git a/server/browser_corpse_reentry_test.go b/server/browser_corpse_reentry_test.go @@ -34,11 +34,14 @@ func TestBrowserPartiallyLootedCorpseSceneReentry(t *testing.T) { if err := world.saveUser(player); err != nil { t.Fatal(err) } + // Keep transfer fixtures to one known Monster Part. + profile := *gamedata.NPCCombatProfiles[17655][1] + profile.Loot = []gamedata.NPCLoot{{Template: 42640, Quality: [2]uint32{1, 1}, Chance: 50}} world.characters = map[uint32]*character{1: player, 1000000: { id: 1000000, name: "Reentry Leet", npc: true, level: 1, health: 1, playfield: 950, position: [3]float32{173, 14, 55}, rotation: [4]float32{0, 0, 0, 1}, appearance: 229, monsterData: 17655, npcDefinitionID: "950/district/2/group/0/authored_point", - combatProfile: gamedata.NPCCombatProfiles[17655][1], + combatProfile: &profile, }} world.clients[1] = &worldClient{id: 1, target: true, ready: true, conn: &combatTestConn{}, npcs: map[uint32]bool{1000000: true}} world.combatRoll = func(uint32) uint32 { return 0 } diff --git a/server/browser_corpse_replay_test.go b/server/browser_corpse_replay_test.go @@ -59,10 +59,13 @@ func testBrowserColdCorpsePickup(t *testing.T, mode uint32) { t.Fatal(err) } } + // Keep transfer fixtures to one known Monster Part. + profile := *gamedata.NPCCombatProfiles[17655][1] + profile.Loot = []gamedata.NPCLoot{{Template: 42640, Quality: [2]uint32{1, 1}, Chance: 50}} world.characters[1000000] = &character{id: 1000000, name: "Cold Leet", npc: true, playfield: 705, position: [3]float32{960, 16.5, 514}, rotation: [4]float32{0, 0, 0, 1}, appearance: 229, monsterData: 17655, level: 1, health: 1, - npcDefinitionID: "950/district/2/group/0/authored_point", combatProfile: gamedata.NPCCombatProfiles[17655][1]} + npcDefinitionID: "950/district/2/group/0/authored_point", combatProfile: &profile} world.combatRoll = func(uint32) uint32 { return 0 } if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { t.Fatal(err) diff --git a/server/browser_dimach_test.go b/server/browser_dimach_test.go @@ -62,14 +62,19 @@ func TestBrowserDimach(t *testing.T) { if err := world.flushWorld(); err != nil { t.Fatal(err) } - // Keep ordinary attacks and recovery beyond this focused special-action check. - player.rechargeUntil = time.Now().Add(5 * time.Minute) - target.rechargeUntil, target.regenerationAt = player.rechargeUntil, player.rechargeUntil + // Keep target attacks and recovery beyond this focused special-action check. + target.rechargeUntil = time.Now().Add(5 * time.Minute) + target.regenerationAt = target.rechargeUntil target.motion.roaming = false targetID := target.id shutdown := startTestService(t, world) mux := http.NewServeMux() mux.Handle("/", world.httpHandler()) + // Suppress ordinary player attacks only after the real equipment action. + mux.HandleFunc("POST /test-hold-attacks", testPlayerHTTP(world, 2, func(world *server, w http.ResponseWriter, r *http.Request) { + world.characters[2].rechargeUntil = time.Now().Add(5 * time.Minute) + w.WriteHeader(http.StatusNoContent) + })) mux.HandleFunc("GET /test-state", testPlayerHTTP(world, 2, func(world *server, w http.ResponseWriter, r *http.Request) { player, target := world.characters[2], world.characters[targetID] json.NewEncoder(w).Encode(map[string]any{"target": target.id, "health": target.health, "fighting": player.fighting, diff --git a/server/browser_e_beamer_test.go b/server/browser_e_beamer_test.go @@ -33,6 +33,10 @@ func TestBrowserEBeamerQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -70,6 +74,7 @@ func TestBrowserEBeamerQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = func(limit uint32) uint32 { if limit == 100 { diff --git a/server/browser_east_wind_test.go b/server/browser_east_wind_test.go @@ -66,7 +66,7 @@ func TestBrowserEastWindMissionReward(t *testing.T) { } expected := []ownedItem{{ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 64, Count: 1}, {ID: 4, Type: 51018, Template: 160216, Quality: 2, Slot: 6, Count: 1}} - if !slices.Equal(player.inventory.Items, expected) || player.inventory.Credits != 23 || player.stats.ImprovementPoints != 188 || + if !slices.Equal(player.inventory.Items, expected) || player.inventory.Credits != 1003 || player.stats.ImprovementPoints != 188 || player.stats.Melee.TwoHandEdged != 9 || player.attackRating() != 9 || !newTestInventoryServer(t).missionExpiry[0].completed || newTestInventoryServer(t).nextItem != 4 { t.Fatal("native period reward or accounting did not survive", player.inventory) } diff --git a/server/browser_edge_less_katana_test.go b/server/browser_edge_less_katana_test.go @@ -33,6 +33,10 @@ func TestBrowserEdgeLessKatanaQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -68,6 +72,7 @@ func TestBrowserEdgeLessKatanaQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = landedCombatRoll } diff --git a/server/browser_engineer_robot_test.go b/server/browser_engineer_robot_test.go @@ -42,7 +42,10 @@ func TestBrowserEngineerRobot(t *testing.T) { target.level, target.health, target.position = 1, 32, [3]float32{950, 16.5, 511} target.geometry = world.geometry target.walkSurface(target.position, 2) - target.combatProfile = gamedata.NPCCombatProfiles[17655][1] + // Give the robot two full hits and an opportunity for retaliation. + profile := *gamedata.NPCCombatProfiles[17655][1] + profile.Health = 32 + target.combatProfile = &profile target.motion = &npcMotion{home: target.position} world.mobileNPCs = map[uint32][]*character{705: {target}} world.combatRoll = landedCombatRoll diff --git a/server/browser_faction_insurance_test.go b/server/browser_faction_insurance_test.go @@ -43,6 +43,9 @@ func TestBrowserFactionInsuranceCheckpoint(t *testing.T) { world.characters = make(map[uint32]*character) world.mobileNPCs = make(map[uint32][]*character) world.nextNPC = 9000003 + // Keep the encounter alive long enough to deliver fatal retaliation. + profile := *gamedata.NPCCombatProfiles[17655][1] + profile.Health = 100 for index, config := range configs { player := world.newCharacter() player.name, player.level, player.appearance = fmt.Sprint("InsuranceRoute", index), 10, config.appearance @@ -69,7 +72,7 @@ func TestBrowserFactionInsuranceCheckpoint(t *testing.T) { position[0] += 1 enemy := &character{id: 9000001 + uint32(index), name: "Insurance encounter", npc: true, playfield: config.city, position: position, rotation: [4]float32{0, 0, 0, 1}, appearance: 229, - monsterData: 17655, level: 1, health: 100, combatProfile: gamedata.NPCCombatProfiles[17655][1], geometry: world.geometry} + monsterData: 17655, level: 1, health: 100, combatProfile: &profile, geometry: world.geometry} world.characters[enemy.id] = enemy } } diff --git a/server/browser_faction_progression_test.go b/server/browser_faction_progression_test.go @@ -110,6 +110,10 @@ func TestBrowserFactionLevelAndMissionRepeat(t *testing.T) { } delete(world.clients, player.id) + // Persist the cross-zone checkpoint before partitioning owners. + if err := world.flushWorld(); err != nil { + t.Fatal(err) + } shutdown := startTestService(t, world) mux := http.NewServeMux() mux.Handle("/", world.httpHandler()) diff --git a/server/browser_generated_mission_test.go b/server/browser_generated_mission_test.go @@ -37,7 +37,18 @@ func TestBrowserGeneratedMission(t *testing.T) { player := world.characters[1] player.stats.Speed.RunSpeed = 5 player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("generated-mission"))) - player.position, player.rotation = [3]float32{89.3, 115.75, 155}, [4]float32{0, 1, 0, 0} + // Prepare physical mission objects through normal entry before partitioning owners. + player.geometry = world.geometry + player.position, player.rotation = [3]float32{89.30216, 115.75, 152.5}, [4]float32{0, 1, 0, 0} + if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil { + t.Fatal(err) + } + destination := player.userData() + destination.Playfield, destination.Position = 3000, [3]float32{89.3, 115.75, 155} + destination.ReturnDoor = nil + if err := world.updateUser(destination); err != nil { + t.Fatal(err) + } if err := world.saveUser(player); err != nil { t.Fatal(err) } diff --git a/server/browser_gripo_test.go b/server/browser_gripo_test.go @@ -33,6 +33,10 @@ func TestBrowserGripoQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -70,6 +74,7 @@ func TestBrowserGripoQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = func(limit uint32) uint32 { if limit == 100 { diff --git a/server/browser_health_drain_test.go b/server/browser_health_drain_test.go @@ -89,8 +89,8 @@ func TestBrowserHealthDrain(t *testing.T) { t.Fatal(err) } cold := newTestInventoryServer(t) - if players[0].health != 24 || players[0].nano != 15 || enemy.health != 90 || - cold.characters[players[0].id].health != 24 || cold.characters[players[0].id].nano != 15 || cold.characters[enemy.id].health != 90 || + if players[0].health != 24 || players[0].nano != 15 || enemy.health != 10 || + cold.characters[players[0].id].health != 24 || cold.characters[players[0].id].nano != 15 || cold.characters[enemy.id].health != 10 || !slices.Equal(cold.characters[players[0].id].inventory.LearnedNanos, []uint32{76742}) || len(cold.characters[players[0].id].inventory.Items) != 0 || !cold.characters[players[0].id].nanoRechargeUntil.Equal(players[0].nanoRechargeUntil) || diff --git a/server/browser_home_defender_test.go b/server/browser_home_defender_test.go @@ -33,6 +33,10 @@ func TestBrowserHomeDefenderQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -66,6 +70,7 @@ func TestBrowserHomeDefenderQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = func(limit uint32) uint32 { if limit == 100 { diff --git a/server/browser_katana_test.go b/server/browser_katana_test.go @@ -33,6 +33,10 @@ func TestBrowserKatanaQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -73,6 +77,7 @@ func TestBrowserKatanaQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = landedCombatRoll } diff --git a/server/browser_kerans_test.go b/server/browser_kerans_test.go @@ -33,6 +33,10 @@ func TestBrowserKeransQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -71,6 +75,7 @@ func TestBrowserKeransQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = func(limit uint32) uint32 { if limit == 100 { diff --git a/server/browser_kinetic_axe_test.go b/server/browser_kinetic_axe_test.go @@ -33,6 +33,10 @@ func TestBrowserKineticAxeQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -73,6 +77,7 @@ func TestBrowserKineticAxeQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = func(limit uint32) uint32 { if limit == 100 { diff --git a/server/browser_loose_katana_test.go b/server/browser_loose_katana_test.go @@ -33,6 +33,10 @@ func TestBrowserLooseKatanaQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -68,6 +72,7 @@ func TestBrowserLooseKatanaQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} // Keep the isolated hit nonlethal without changing the original Leet. world.combatRoll = func(limit uint32) uint32 { diff --git a/server/browser_loot_refusal_test.go b/server/browser_loot_refusal_test.go @@ -43,10 +43,13 @@ func TestBrowserCorpsePickupRefusal(t *testing.T) { world.clients[player.id] = &worldClient{id: player.id, target: true, ready: true, conn: &combatTestConn{}, npcs: map[uint32]bool{1000000: true}} world.clients[observer.id] = &worldClient{id: observer.id, target: true, ready: true, conn: &combatTestConn{}, npcs: map[uint32]bool{1000000: true}} formTestTeam(t, world, 1, 2) + // Keep transfer fixtures to one known Monster Part. + profile := *gamedata.NPCCombatProfiles[17655][1] + profile.Loot = []gamedata.NPCLoot{{Template: 42640, Quality: [2]uint32{1, 1}, Chance: 50}} world.characters[1000000] = &character{id: 1000000, name: "Loot fixture", npc: true, playfield: 705, position: [3]float32{960, 16.5, 514}, rotation: [4]float32{0, 0, 0, 1}, appearance: 229, monsterData: 17655, level: 1, health: 1, - npcDefinitionID: "950/district/2/group/0/authored_point", combatProfile: gamedata.NPCCombatProfiles[17655][1]} + npcDefinitionID: "950/district/2/group/0/authored_point", combatProfile: &profile} world.combatRoll = func(uint32) uint32 { return 0 } if err := world.handleCombat(world.clients[1], attackPacket(1, 1000000)[20:]); err != nil { t.Fatal(err) diff --git a/server/browser_nova_flow_test.go b/server/browser_nova_flow_test.go @@ -33,6 +33,10 @@ func TestBrowserNovaFlowQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -71,6 +75,7 @@ func TestBrowserNovaFlowQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = func(limit uint32) uint32 { if limit == 100 { diff --git a/server/browser_sledgehammer_test.go b/server/browser_sledgehammer_test.go @@ -33,6 +33,10 @@ func TestBrowserSledgehammerQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -71,6 +75,7 @@ func TestBrowserSledgehammerQualities(t *testing.T) { if err := world.saveInventory(world.characters[1], world.characters[1].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = func(limit uint32) uint32 { if limit == 100 { diff --git a/server/browser_support_beam_test.go b/server/browser_support_beam_test.go @@ -33,6 +33,10 @@ func TestBrowserSupportBeamQualities(t *testing.T) { target = actor } } + // Use a controlled 100-HP target for exact selected-quality damage. + profile := *target.combatProfile + profile.Health = 100 + target.combatProfile = &profile if phase == "warm" { for index := 0; index < 2; index++ { player := world.newCharacter() @@ -81,6 +85,7 @@ func TestBrowserSupportBeamQualities(t *testing.T) { if err := world.saveInventory(world.characters[2], world.characters[2].inventory); err != nil { t.Fatal(err) } + target.health = 100 target.position, target.motion.home = [3]float32{61, 14.75, 51.5}, [3]float32{61, 14.75, 51.5} world.combatRoll = func(limit uint32) uint32 { if limit == 100 { diff --git a/server/browser_team_loot_order_test.go b/server/browser_team_loot_order_test.go @@ -42,13 +42,16 @@ func TestBrowserTeamLootOrders(t *testing.T) { if _, err := world.changeTeam(teamCommand{actor: 1, action: 28, member: 2}, make(map[*worldClient][][]byte)); err != nil { t.Fatal(err) } + // Keep transfer fixtures to one known Monster Part. + profile := *gamedata.NPCCombatProfiles[17655][1] + profile.Loot = []gamedata.NPCLoot{{Template: 42640, Quality: [2]uint32{1, 1}, Chance: 50}} positions := [][3]float32{{960, 16.5, 514}, {958.8, 16.5, 514}, {961.2, 16.5, 514}, {959.4, 16.5, 515.5}, {960.6, 16.5, 515.5}} for index, position := range positions { id := 1000000 + uint32(index) world.characters[id] = &character{id: id, name: "Loot-order Leet", npc: true, level: 1, playfield: 705, position: position, rotation: [4]float32{0, 0, 0, 1}, health: 1, appearance: 229, monsterData: 17655, npcDefinitionID: "950/district/2/group/0/authored_point", - combatProfile: gamedata.NPCCombatProfiles[17655][1]} + combatProfile: &profile} } world.combatRoll = func(uint32) uint32 { return 0 } if err := world.flushWorld(); err != nil { diff --git a/tools/client/test_dimach.mjs b/tools/client/test_dimach.mjs @@ -28,10 +28,12 @@ try { const cell = game.state.grids.flatMap(grid => grid.cells).find(cell => cell.identity[0] === 104 && cell.identity[1] === 51 && !cell.dummy); assert(cell, 'stocked Sledgehammer is visible'); await game.click((cell.bounds[0]+cell.bounds[2])/2, (cell.bounds[1]+cell.bounds[3])/2, 'right'); - await waitServer('Sledgehammer equipped normally', state => state.inventory.Items.some(item => item.ID === 4 && item.Slot === 6)); + await waitServer('Sledgehammer equipped normally', state => state.inventory.Items.some(item => + item.ID === evidence.initial.inventory.Items[3].ID && item.Slot === 6)); await game.wait('native equipped weapon ready', state => game.local(state).weapons.some(weapon => weapon.slot === 6)); } evidence.equipped = await server(); + assert.equal((await page.request.post(url + '/test-hold-attacks')).status(), 204); await game.key('Tab'); await game.wait('original Leet selected', state => state.selected[0] === 50000 && state.selected[1] === evidence.initial.target); await game.key('KeyQ'); diff --git a/tools/client/test_east_wind_cold.mjs b/tools/client/test_east_wind_cold.mjs @@ -19,7 +19,7 @@ try { await game.snapshot(); assert.deepEqual(game.local().inventory.map(item => [item.id,item.slot,item.quality,...item.templates]), [[4,6,2,160216,160217],[1,48,1,209283,209283]]); - for (const [stat, value] of [[60,6],[54,2],[105,9],[104,6],[142,8],[22,9],[53,188],[61,23]]) + for (const [stat, value] of [[60,6],[54,2],[105,9],[104,6],[142,8],[22,9],[53,188],[61,1003]]) assert.equal(game.local().stats[stat], value, 'retained native stat ' + stat); const state = await (await page.request.get(url + '/test-state')).json(); assert.equal(state.completed, true); diff --git a/tools/client/test_east_wind_reward.mjs b/tools/client/test_east_wind_reward.mjs @@ -34,7 +34,7 @@ try { // Return the saved collected book through the original native item-on-booth action. await game.click(789, 45); await game.click(...await game.pick(56001, 3221228472), 'right'); - await game.wait('promised East Wind delivered once', state => game.local(state).stats[61] === 23 && + await game.wait('promised East Wind delivered once', state => game.local(state).stats[61] === 1003 && game.local(state).inventory.some(item => item.templates.includes(160216)) && !game.local(state).inventory.some(item => item.id === 2 || item.id === 3)); evidence.delivered = await server(); diff --git a/tools/client/test_ground_drop.mjs b/tools/client/test_ground_drop.mjs @@ -38,12 +38,14 @@ try { } if (phase === 'stale' || phase === 'stale-contained' || phase === 'refusal') { if (!game.state.camera.firstPerson) await game.key('F8'); - const point = await game.point(500, 400); + const point = await game.point(500, 150); await page.mouse.move(point.x, point.y); + const press = game.sequence; await page.mouse.down({button: 'right'}); try { - await page.mouse.move(point.x, point.y + 150, {steps: 8}); - await game.snapshot(); + await game.waitInput(press, 1025); + await page.mouse.move(point.x, point.y + 400, {steps: 8}); + await game.wait('ground view below the character', state => state.camera.angles[1] >= 0.55); } finally { const release = game.sequence; await page.mouse.up({button: 'right'}); diff --git a/tools/client/test_health_drain.mjs b/tools/client/test_health_drain.mjs @@ -24,6 +24,7 @@ try { const server = async () => (await owner.page.request.get(url + '/test-state')).json(); const actor = (game, id) => game.state.actors.find(actor => actor.type === 50000 && actor.id === id); evidence.before = await server(); + assert.equal(evidence.before.targetHealth, 20); const {owner: id, enemy} = evidence.before; await Promise.all(games.map(game => game.wait('caster and exact Leet visible', () => actor(game, id) && actor(game, enemy)))); await owner.key('KeyI'); @@ -46,11 +47,11 @@ try { event.direction === 'framesent' && event.opcode === '5e477770' && Buffer.from(event.hex, 'hex').readUInt32BE(29) === 19 && Buffer.from(event.hex, 'hex').readUInt32BE(45) === 76742)); await Promise.all(games.map(game => game.wait('both authored effects agree on both native clients', () => - actor(game, id).stats[27] === 24 && actor(game, enemy).stats[27] === 90))); + actor(game, id).stats[27] === 24 && actor(game, enemy).stats[27] === 10))); await owner.wait('native nano cost retained', state => owner.local(state).stats[214] === 15); evidence.after = await server(); assert.equal(evidence.after.health, 24); - assert.equal(evidence.after.targetHealth, 90); + assert.equal(evidence.after.targetHealth, 10); assert.equal(evidence.after.nano, 15); assert.equal(evidence.after.reserved, 0); assert.equal(evidence.after.peerHealth, 20); @@ -73,11 +74,11 @@ try { const flags = packet.readUInt32BE(30); assert((flags & 1) !== 0 && (flags & 0x1000) === 0); const health = 65 + packet[64] + 12 + 1; - assert.equal(packet.readUInt32BE(health), 100); - assert.equal(packet.readUInt32BE(health + 4), 90); + assert.equal(packet.readUInt32BE(health), 20); + assert.equal(packet.readUInt32BE(health + 4), 10); const predicted = actor(game, enemy).stats[27]; - assert(predicted >= 90 && predicted <= 100); - evidence.replayClients.push({owner: actor(game, id).stats[27], targetWire: 90, + assert(predicted >= 10 && predicted <= 20); + evidence.replayClients.push({owner: actor(game, id).stats[27], targetWire: 10, targetPredicted: predicted, targetCounter: actor(game, enemy).stats[58]}); } evidence.replayed = await server(); diff --git a/tools/client/test_inventory_grid.mjs b/tools/client/test_inventory_grid.mjs @@ -5,7 +5,7 @@ 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', headless: false, +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']}); const evidence = {}; @@ -17,6 +17,7 @@ try { game = await GameTest.attach(page); await page.goto(url); await game.ready(); + await page.waitForFunction(() => touchRegion(500, 400)?.world === true); evidence.before = await (await page.request.get(url + '/test-state')).json(); await game.key('i'); console.log('Initial grids:', JSON.stringify(game.state.grids.map(grid => ({...grid, cells: grid.cells.slice(0, 4)})))); diff --git a/tools/client/test_starter_equipment.mjs b/tools/client/test_starter_equipment.mjs @@ -159,7 +159,7 @@ async function fight(game, enemy, label) { } await game.save(output + '/' + label + '/earned-kill'); - // Use the actual remains twice, then take any generated part exactly once. + // Use the actual remains twice, then take every generated item exactly once. const killed = await (await game.page.request.get(url + '/test-state')).json(); await fs.writeFile(output + '/' + label + '/earned-kill/server.json', JSON.stringify(killed, null, 2)); const corpse = killed.corpses.find(corpse => corpse.id === enemy.id); @@ -200,29 +200,36 @@ async function fight(game, enemy, label) { await game.wait('corpse window reopened', state => state.regions.some( ([left, top, right, bottom]) => left === 0 && top === 0 && right === 178 && bottom === 128)); await game.save(output + '/' + label + '/corpse-loot'); - if (corpse.items?.length) { - assert.equal(corpse.items.length, 1); - assert(corpse.items[0].Quality >= 1 && corpse.items[0].Quality <= (healthyEnemy.level === 1 ? 1 : 3)); - assert.deepEqual(corpse.items, [{ID: corpse.items[0].ID, Type: 51005, - Template: 42640, Quality: corpse.items[0].Quality, Slot: 0, Count: 1, Ammo: 0}]); - await game.click(30, 45); - await game.wait('generated part in native inventory', state => - game.local(state).inventory.some(item => item.id === corpse.items[0].ID)); + const templates = new Set(); + for (const [slot, item] of (corpse.items ?? []).entries()) { + assert(item.Template === 42640 || item.Template === 70562); + assert(!templates.has(item.Template)); + templates.add(item.Template); + assert(item.Quality >= 1 && item.Quality <= (healthyEnemy.level === 1 ? 1 : 3)); + assert.deepEqual(item, {ID: item.ID, Type: item.Template === 42640 ? 51005 : 51022, + Template: item.Template, Quality: item.Quality, Slot: slot, Count: 1, Ammo: 0}); + const cell = game.state.grids.flatMap(grid => grid.cells).find(cell => + cell.identity[0] === 106 && cell.identity[1] === item.Slot && !cell.dummy); + assert(cell, 'generated item has a native corpse cell'); + await game.click((cell.bounds[0] + cell.bounds[2]) / 2, (cell.bounds[1] + cell.bounds[3]) / 2); + await game.wait('generated item in native inventory', state => + game.local(state).inventory.some(held => held.id === item.ID)); } await game.click(170, 8); const combatUses = await recover(game, label + '/recovery'); const after = await (await game.page.request.get(url + '/test-state')).json(); assert.equal(after.inventory.Credits, credits + corpse.credits); + const slots = new Set(killed.inventory.Items.map(item => item.Slot)); for (const item of corpse.items ?? []) { - const slots = new Set(killed.inventory.Items.map(item => item.Slot)); let slot = 64; while (slots.has(slot)) ++slot; + slots.add(slot); assert.deepEqual(after.inventory.Items.find(held => held.ID === item.ID), {...item, Slot: slot}); } console.log('PASS: ' + label + ', full-health kill, exact corpse ledger and recovery'); return {fightStart: {health: beforeFight.health, enemy: healthyEnemy}, corpse, combatUses, levelAward, - parts: after.inventory.Items.filter(item => (corpse.items ?? []).some(part => part.ID === item.ID))}; + loot: after.inventory.Items.filter(item => (corpse.items ?? []).some(drop => drop.ID === item.ID))}; } // Approach an ordinary full-health outdoor encounter at the requested starter level. @@ -791,7 +798,7 @@ try { if (item.Template === 116628) return {...item, Count: 25 - trainingUses - combatUses - levelTrainingUses}; return item; }); - for (const fight of fights) expected.push(...fight.parts.filter(item => item.ID !== sale.ID)); + for (const fight of fights) expected.push(...fight.loot.filter(item => item.ID !== sale.ID)); expected.push(wornReward, {...kit, Count: 24}); expected.sort((a, b) => a.ID - b.ID); const final = await (await owner.page.request.get(url + '/test-state')).json();