aorecomp

Anarchy Online classic in the browser

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


commit dfdcb0d6b9ac741f2681f55cbc2e7af127bec558
parent 66167a92a1641f9616321eca7259db41f94ad879
Author: anon <anon@example.com>
Date:   Tue,  3 Nov 2026 22:22:10 +0000

Admit period-documented East Wind mission rewards

Diffstat:
MTODO.md | 9+++++++++
Adocs/east-wind.md | 121+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mdocs/mission-levels.md | 18++++++++++--------
Mdocs/mission-objectives.md | 9+++++----
Mdocs/period-acquisition-evidence.md | 6++++++
Aserver/browser_east_wind_test.go | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/east_wind_contracts_test.go | 163+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/east_wind_damage_test.go | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/east_wind_mission_test.go | 139+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aserver/east_wind_test.go | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Mserver/gamedata/item_families.yaml | 2++
Mserver/gamedata/item_quality_test.go | 1+
Mserver/gamedata/mission_booths_test.go | 2+-
Mserver/gamedata/missions.yaml | 6++++--
Mserver/mission_reward_pool_test.go | 4++--
Atools/client/test_east_wind_cold.mjs | 35+++++++++++++++++++++++++++++++++++
Atools/client/test_east_wind_reward.mjs | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 files changed, 783 insertions(+), 17 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -456,6 +456,15 @@ unverified mass/deletion/reclaim policies are in [backpacks](docs/backpacks.md). fixture verifies both body styles, all six worn pieces, independent sleeves, QL100/101 native training, cancelled/accepted sale and nine retained identities across page/cold recovery; see [Kevlar contracts](docs/kevlar-armor.md). + The original East Wind Katana160216/160217 now admits QL1..199, with a + November2002 report naming its mission-terminal availability and exact ID. + It joins the production reward pool through the existing selected-quality + path. Complete original contracts preserve Adventurer, 2h Edged/Melee Energy/ + Brawling gates, weighted rating, Energy damage, timing and unlimited ammunition. + A controlled native hand-in verifies QL2 delivery, equality refusal, normal + 12-IP training, wear/remove/re-wear and exact page/cold ownership. Probability, + original reward-QL arithmetic and the other pool members remain provisional; + see [period-backed East Wind reward](docs/east-wind.md). The reviewed Dull Katana pair now admits QL1..20 through the shared path, fixing qualified QL2 wear rejection. Original descriptor audits and focused public-handler checks cover all three strict skill gates, both anchors, diff --git a/docs/east-wind.md b/docs/east-wind.md @@ -0,0 +1,121 @@ +# East Wind Katana and mission acquisition + +The original East Wind Katana pair160216/160217 now admits QL1..199 through the +shared weapon consumers and appears in the starter mission reward pool. This +fixes two focused failures: qualified QL2 wear refused the intermediate item, +and the production pool could not advertise this documented mission weapon. +The source and failing checks are retained under `local/east-wind/`. + +## Period acquisition evidence + +JeanFrancis's November14,2002 reply2559291 in +[question sur arme ADV](https://archives.jeuxonline.info/fils/136791.html) +explicitly identifies East Wind Katana, links the contemporary database record +`AOID=160217`, and reports mission-terminal availability at all qualities, +including low qualities. The same reply distinguishes it from the other compass +katanas then reported unavailable. This is a named period acquisition report, +not an inference from the presence of an item in the client database. + +Both endpoints of that family remain in the original14.9.1 database. Their full +contracts match apart from the reviewed quality/value/damage and skill amounts. +The report supports admitting the named family to mission selection. It does +not recover original probability, terminal-specific tables or reward-QL +arithmetic. The eight-member starter pool, uniform choice and existing +mission-level/QL policy remain reconstruction choices. No profession filter +was added to reward generation; the original Adventurer restriction applies +when wearing the weapon. + +The initial SOL Fire search recovered only family-level acquisition language +and a discussion distinguishing its variants. It did not establish a precise +SOL variant reward binding, so no SOL family was admitted. Raw HTML, source +SHA256, author/date text and parsed messages are retained in +`local/sol-fire-research/136791.messages.json` and its companion original HTML. +Malformed legacy bytes are replaced only in the parsed view; original bytes +remain unchanged. Follow-up searches found no additional period corroboration. + +## Complete original item contracts + +Fresh parsing of records1000020:160216 and1000020:160217 matches every catalog +field, including record offsets. Both have header `[51018,7,15,23]`, the same +name/description, no undecoded data and identical complete sections after only +the three strict skill amounts are normalized. Their rating entries, OnActivate +53076 descriptor, presentation entries, profession predicate and Boolean +requirements structure are identical. There is no OnWear modifier section. + +| Property | Original contract | +| --- | --- | +| Endpoint QLs | 1 and199 | +| Profession | Adventurer6 | +| Attack skills | 2h Edged105 at67%, Melee Energy104 at33% | +| Defense | Evade Close155 at100% | +| Damage type | EnergyAC92 | +| Placement | Two-handed, right hand6 | +| Attack/recharge/equip delay | 250/250/250 centiseconds | +| Range / initiative | 3 metres / Melee Initiative118 | +| Ammunition | Unlimited; no ammunition consumption | + +| QL | Minimum..maximum (critical bonus) | 2h Edged must exceed | Melee Energy must exceed | Brawling must exceed | Value74 | +| --- | --- | --- | --- | --- | --- | +| 1 | 18..22 (12) | 5 | 4 | 6 | 4204 | +| 2 | 18..24 (13) | 10 | 7 | 9 | 4225 | +| 100 | 54..230 (66) | 496 | 331 | 332 | 211261 | +| 199 | 90..438 (119) | 987 | 658 | 658 | 832434 | + +The QL200 Strong East Wind Katana160218 is a separate descriptor and is not an +interpolation endpoint for this family. Brawling execution, broader mission +selection and original combat balance remain separate work. + +The original index SHA256 is +`46e5dc54af9358cc9bff05f4358e86af630e497bc677f361c133c88073b84d71`. +Payload hashes are +`817684d5bbcf5e79939c0cb7e0fb7057ae0f548a88c0a5416e778ecf7d5399b5` and +`201e44b932f1e68ef443500814bd62e06d36b192ff1ad8f1079729c36ac1a338`. +Original bytes and the complete audit are in `local/east-wind/original.json` +and its companion `.bin` files. + +## Focused verification + +Public-handler contract checks cover both stored anchors, QL1/2/5/99/100/198/ +199, profession mismatch, each strict skill threshold, left-hand refusal, +unchanged pending state before the real equip deadline, exact endpoint delivery, +damage/value/rating properties, removal and cold ownership. Cancelled/accepted +sales at QL2/100/199 preserve selected value and exactly-once ownership. + +The production-pool regression now advertises and accepts every one of its +eight families at selected QL8, retaining the chosen promise and encounters on +cold load. A separate period-reward fixture uses the actual production recipe +to advertise and accept QL2. Public entry and pickup prepare its saved hand-in +checkpoint. The fixture then submits twice, rejects threshold equality, trains +2h Edged8to9 for12 IP and equips the same delivered instance. It checks the +original weapon1, reward4, wallet23, IP188, weighted attack rating9 and item +counter4 after cold loading. + +The accepted WASM run is `local/east-wind/20261103-141200/`: reward20.46seconds, +cold6.60seconds. Native journal delivery contains160216/160217QL2. Ordinary +book-on-booth Use consumes book3/key2 and adds reward4; the client refuses +unqualified wear, performs the same12-IP training, and wears/removes/re-wears +that instance. Page and fresh-server recovery retain exact item identities, +selected endpoints, stats, cash and completed state. Visual review confirms the +usable weapon icon and cold held blade. The checkpoint's level, skills, IP and +collected book are controlled fixture state, not earned-progression evidence; +no leveling or established mission traversal was repeated. + +Final Go checks pass23 roots/367 results across server and gamedata, including +all eight production promises, selected weapon contracts, settlement faults, +duplicate submissions and shared reward/quality handling. Vet and both Node +syntax checks pass. A synthetic combat fixture checks rating334 from raw +2h Edged401/Melee Energy202, normal/critical damage44/67 and the original +2.5-second attack/recharge cadence without consuming ammunition. Nonlethal HP +retains the normal periodic checkpoint policy. + +Four period-reward fault cases cover ignored item/completion writes, a late +valid-quality rewrite and COMMIT failure. They preserve book/key, wallet, +promise and counter without publishing success; a new authenticated request +sequence retries once and duplicate submission cannot allocate again. Earlier +fixture failures are retained separately: completed contracts leave the active +journal, request sequences advance on failed Use, and nonlethal HP does not +persist immediately. None required a production compatibility branch. + +`local/east-wind/verification.json` checks the raw period HTML hash, full item +payloads, production selection, complete final Go logs, exact native return-item +source/target, seven clean traces and cold item/stat/cash conservation. diff --git a/docs/mission-levels.md b/docs/mission-levels.md @@ -14,19 +14,21 @@ pool produces an empty offer without charging, allocating persistent identities, or modifying the recipe. Existing mission persistence already stores the concrete values. Outdoor populations still use their authored level ranges. -The provisional starter pool contains the six reviewed Metaplast families and -the Baseballbat. This provides rewards for head, chest, arms, hands, legs and -feet through the same selected-quality item rules. The exact historical pool -and selection probabilities remain unresolved. All 130 starter bindings share +The starter pool contains the six reviewed Metaplast families, the Baseballbat +and the period-documented East Wind Katana. This provides armor and weapon +choices through the same selected-quality item rules. The Katana has named +period mission-terminal evidence; other membership, the exact historical pool +and selection probabilities remain unresolved. All130 starter bindings share this recipe; changing it cannot replace an already advertised or accepted item. -The production-pool regression selects each of its seven entries for a level-5 +The production-pool regression selects each of its eight entries for a level-5 character at the hardest setting. Every offer advertises QL8 with its reviewed endpoint pair. Acceptance retains that promise after a pool edit; cold loading retains all five level-8 encounters. Settlement checks cover the additional -Metaplast pieces at QL8, duplicate returns and exact cold ownership. The related -reward and quality selection passes 23 test roots / 169 results both normally -and under the race detector, plus `go vet ./server/...`. +Metaplast pieces at QL8, duplicate returns and exact cold ownership. Earlier +reward/quality verification covered23 test roots/169 results normally +and under the race detector. The period-backed expansion, current checks and +native training/retention are recorded in [East Wind Katana](east-wind.md). An existing native contract also retained its promised QL8 bat across deployment of this larger pool. Both GPU WASM clients reconstructed all 34 owned instances; diff --git a/docs/mission-objectives.md b/docs/mission-objectives.md @@ -344,10 +344,11 @@ mission-generated progression remains incomplete. ## Selected-quality item rewards -The fixed contract advertises one QL2 Metaplast glove, using original reviewed -endpoints85596/85595. Its pool membership, fixed quality and guaranteed selection -are authored reconstruction policy, rather than a recovered historical mission -reward table or player-level/difficulty formula. The item itself retains original +Starter contracts advertise one concrete item from the +[selected-quality pool](mission-levels.md), including the period-documented +[East Wind Katana](east-wind.md). The original focused glove fixture uses QL2 +endpoints85596/85595. Its guaranteed choice is reconstruction policy, rather +than a recovered historical reward table or difficulty formula. The item retains original requirements, value, wear effects and interpolation: Strength10, Agility11 and ACs2/2/2/2/1/1/1/1 in stat90..97 order. It can be kept for wear or sold through the existing inventory/shop consumers. XP and tokens remain separately conditional. diff --git a/docs/period-acquisition-evidence.md b/docs/period-acquisition-evidence.md @@ -62,3 +62,9 @@ bytes and hashes remain intact. Parsed text is not byte-exact transcription. The artifact audit covers 36 index pages, 3592 unique links, 12 source threads and six catalog NCU anchors. It verifies the research records, not game behavior. No server/client source changed and no gameplay rerun was warranted. + +A later targeted read of the forum's November2002 Adventurer discussion names +East Wind Katana, links its exact original template160217 and reports low-QL +mission-terminal availability. The resulting audited family and production +mission admission are recorded separately in [East Wind Katana](east-wind.md). +The shop-stock and NCU gaps from this earlier bounded pass remain unresolved. diff --git a/server/browser_east_wind_test.go b/server/browser_east_wind_test.go @@ -0,0 +1,91 @@ +package main + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "os" + "os/exec" + "path/filepath" + "runtime" + "slices" + "testing" + "time" +) + +func TestBrowserEastWindMissionReward(t *testing.T) { + if os.Getenv("AO_GAME_TEST") != "1" { + t.Skip("set AO_GAME_TEST=1 for the focused period-reward check") + } + _, source, _, _ := runtime.Caller(0) + root := filepath.Dir(filepath.Dir(source)) + output := filepath.Join(root, "local/east-wind", time.Now().Format("20060102-150405")) + world, _, _ := newEastWindMissionWorld(t) + world.characters[1].browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("east-wind"))) + if err := world.saveUser_locked(world.characters[1]); err != nil { + t.Fatal(err) + } + if err := world.savePosition_locked(world.characters[1]); err != nil { + t.Fatal(err) + } + if err := world.db.Close(); err != nil { + t.Fatal(err) + } + for _, phase := range []string{"reward", "cold"} { + t.Run(phase, func(t *testing.T) { + world := newServerForTest(t) + 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() + player := world.characters[1] + json.NewEncoder(w).Encode(map[string]any{"inventory": player.inventory, "stats": player.baseStats(), + "completed": world.missionExpiry[0].completed, "rating": player.attackRating(), + "pending": world.clients[1].equipment != nil, "lastID": world.nextItem}) + }) + host := httptest.NewServer(mux) + t.Cleanup(host.Close) + closeTestBrowserStreams(t, world) + ctx, cancel := context.WithTimeout(context.Background(), 2*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.advanceEquipment(now) + case <-ctx.Done(): + return + } + } + }() + defer func() { cancel(); <-stopped }() + + command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_east_wind_"+phase+".mjs"), host.URL, filepath.Join(output, phase)) + command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr + err := command.Run() + + t.Logf("Browser artifacts: %s", output) + if err != nil { + t.Fatal(err) + } + 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}} + player := world.characters[1] + if !slices.Equal(player.inventory.Items, expected) || player.inventory.Credits != 23 || player.stats.ImprovementPoints != 188 || + player.stats.Melee.TwoHandEdged != 9 || player.attackRating() != 9 || !world.missionExpiry[0].completed || world.nextItem != 4 { + t.Fatal("native period reward or accounting did not survive", player.inventory) + } + }) + if t.Failed() { + return + } + } +} diff --git a/server/east_wind_contracts_test.go b/server/east_wind_contracts_test.go @@ -0,0 +1,163 @@ +package main + +import ( + "encoding/binary" + "fmt" + "slices" + "testing" + "time" +) + +func TestEastWindQualitiesEnforceWearBoundariesAndRecover(t *testing.T) { + for _, template := range []uint32{160216, 160217} { + for _, row := range []struct { + quality, minimum, maximum, critical, value, rating uint32 + edged, energy, brawling uint16 + }{ + {1, 18, 22, 12, 4204, 5, 6, 5, 7}, + {2, 18, 24, 13, 4225, 9, 11, 8, 10}, + {5, 19, 30, 14, 4542, 22, 26, 18, 20}, + {99, 54, 228, 65, 207099, 437, 492, 329, 330}, + {100, 54, 230, 66, 211261, 441, 497, 332, 333}, + {198, 90, 436, 118, 824089, 874, 983, 656, 656}, + {199, 90, 438, 119, 832434, 878, 988, 659, 659}, + } { + for _, failed := range []uint32{0, 60, 105, 104, 142, 8} { + t.Run(fmt.Sprintf("%d/QL%d/below%d", template, row.quality, failed), func(t *testing.T) { + world, output := newEquipmentWorld(t) + player, client := world.characters[1], world.clients[1] + player.stats.Abilities = characterAbilitiesStats{1, 1, 1, 1, 1, 1} + player.profession = 6 + player.stats.Melee.TwoHandEdged = row.edged + player.stats.Melee.MeleeEnergy, player.stats.Body.Brawling = row.energy, row.brawling + destination := uint32(6) + switch failed { + case 60: + player.profession = 7 + case 105: + player.stats.Melee.TwoHandEdged-- + case 104: + player.stats.Melee.MeleeEnergy-- + case 142: + player.stats.Body.Brawling-- + case 8: + destination = 8 + } + player.inventory.Items[0].Template, player.inventory.Items[0].Quality = template, row.quality + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + if err := world.saveInventory_locked(player, player.inventory); err != nil { + t.Fatal(err) + } + + started := time.Now() + if err := world.handleInventory(client, inventoryMovePacket(1, 64, destination)[20:]); err != nil { + t.Fatal(err) + } + if client.equipment != nil { + finish := client.equipment.readyAt + if finish.Before(started.Add(2500*time.Millisecond)) || finish.After(time.Now().Add(2500*time.Millisecond)) { + t.Fatal("EastWind did not retain its original equip delay") + } + world.advanceEquipment(finish.Add(-time.Nanosecond)) + if player.inventory.Items[0].Slot != 64 { + t.Fatal("weapon moved before its equip deadline") + } + world.advanceEquipment(finish) + } + cold := newTestInventoryServer(t).characters[1] + + expected := ownedItem{ID: 1, Type: 51018, Template: template, Quality: row.quality, Slot: 64, Count: 1} + if failed == 0 { + expected.Slot = 6 + } + if !slices.Equal(player.inventory.Items, []ownedItem{expected}) || !slices.Equal(cold.inventory.Items, []ownedItem{expected}) { + t.Fatal("wear boundary lost the selected instance or placement", player.inventory.Items, cold.inventory.Items) + } + if failed != 0 { + return + } + weapon := cold.attackWeapon() + if weapon == nil || itemStat(weapon, 286) != row.minimum || itemStat(weapon, 285) != row.maximum || itemStat(weapon, 284) != row.critical || + itemStat(weapon, 294) != 250 || itemStat(weapon, 210) != 250 || itemStat(weapon, 211) != 250 || itemStat(weapon, 287) != 3 || + itemStat(weapon, 440) != 118 || cold.attackRating() != int32(row.rating) || itemStat(weapon, 353) != 2 || itemStat(weapon, 436) != 92 || expected.usesAmmo() || expected.shopPrice() != row.value { + t.Fatal("selected quality lost damage, timing, ammo, range, damage type or value", weapon) + } + low, high := uint32(160216), uint32(160217) + if row.quality == 1 { + high = low + } else if row.quality == 199 { + low = high + } + var delivered []byte + for _, packet := range output.packets { + if binary.BigEndian.Uint32(packet[16:20]) == 0x3b1d2268 { + delivered = packet + } + } + if len(delivered) < 91 || binary.BigEndian.Uint32(delivered[71:75]) != row.quality || + binary.BigEndian.Uint32(delivered[79:83]) != low || binary.BigEndian.Uint32(delivered[87:91]) != high { + t.Fatal("native weapon delivery lost the selected endpoints") + } + if err := world.handleInventory(client, itemMovePacket(1, 6, 111)[20:]); err != nil || client.equipment == nil { + t.Fatal("selected weapon did not start removal", err) + } + world.advanceEquipment(client.equipment.readyAt) + removed := newTestInventoryServer(t) + expected.Slot = 64 + if !slices.Equal(removed.characters[1].inventory.Items, []ownedItem{expected}) || removed.nextItem != 1 { + t.Fatal("removal changed selected ownership or properties") + } + }) + } + } + } +} + +func TestEastWindSaleCancellationAndReplayKeepSelectedQuality(t *testing.T) { + for _, scenario := range []struct{ quality, sale uint32 }{ + {2, 211}, {100, 10563}, {199, 41621}, + } { + t.Run(fmt.Sprint(scenario.quality), func(t *testing.T) { + world, _ := newShopWorld(t) + player, client := world.characters[1], world.clients[1] + if granted, err := world.grantItem_locked(player, 160216); err != nil || !granted { + t.Fatal(granted, err) + } + player.inventory.Items[1].Quality = scenario.quality + if err := world.saveInventory_locked(player, player.inventory); err != nil { + t.Fatal(err) + } + before := append([]ownedItem(nil), player.inventory.Items...) + offer := shopTradePacket([2]uint32{50000, 1}, 4, [2]uint32{50000, 1}, [2]uint32{104, 65})[20:] + + if err := world.handleTrade(client, offer); err != nil { + t.Fatal(err) + } + if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 2, [2]uint32{}, [2]uint32{})[20:]); err != nil { + t.Fatal(err) + } + cancelled := newTestInventoryServer(t).characters[1].inventory + if err := world.handleShopUse(client, shopUseRequest(2)); err != nil { + t.Fatal(err) + } + if err := world.handleTrade(client, offer); err != nil { + t.Fatal(err) + } + for range 2 { + if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 1, [2]uint32{}, [2]uint32{})[20:]); err != nil { + t.Fatal(err) + } + } + sold := newTestInventoryServer(t).characters[1].inventory + + if !slices.Equal(cancelled.Items, before) || cancelled.Credits != 100 { + t.Fatal("cancelled sale changed the selected instance or wallet", cancelled) + } + if !slices.Equal(sold.Items, before[:1]) || sold.Credits != 100+scenario.sale { + t.Fatal("accepted or repeated sale changed another item or its selected-quality price", sold) + } + }) + } +} diff --git a/server/east_wind_damage_test.go b/server/east_wind_damage_test.go @@ -0,0 +1,54 @@ +package main + +import ( + "testing" + "time" +) + +func TestEastWindWeightedDamageAndCadenceWithoutAmmunition(t *testing.T) { + for _, critical := range []bool{false, true} { + t.Run(map[bool]string{false: "normal", true: "critical"}[critical], func(t *testing.T) { + world, _ := newRangedWorld(t) + player, target := world.characters[1], world.characters[1000000] + player.profession = 6 + player.stats.Abilities = characterAbilitiesStats{1, 1, 1, 1, 1, 1} + player.stats.Melee.TwoHandEdged, player.stats.Melee.MeleeEnergy, player.stats.Body.Brawling = 401, 202, 20 + player.stats.Speed.MeleeInitiative, player.aggDef = 0, 75 + player.inventory.Items[0].Template, player.inventory.Items[0].Quality, player.inventory.Items[0].Ammo = 160216, 2, 0 + target.position = [3]float32{1, 0, 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) + } + world.combatRoll = func(limit uint32) uint32 { + if limit == 10000 || limit == 100 && critical { + return 0 + } + return limit - 1 + } + + if err := world.handleCombat(world.clients[1], attackPacket(1, target.id)[20:]); err != nil { + t.Fatal(err) + } + hit := player.nextAttack + world.advanceCombat(hit) + cold := newTestInventoryServer(t) + + expectedHealth := uint32(956) + if critical { + expectedHealth = 933 + } + // Nonlethal HP waits for the normal checkpoint; item state stays durable. + if player.attackRating() != 334 || target.health != expectedHealth || cold.characters[1000000].health != 1000 || + player.rechargeUntil.Sub(hit) != 2500*time.Millisecond || player.nextAttack.Sub(hit) != 5*time.Second || + player.inventory.Items[0].Ammo != 0 || cold.characters[1].inventory.Items[0].Ammo != 0 || + cold.characters[1].inventory.Items[1].Count != 100 { + t.Fatalf("rating=%d health=%d coldHealth=%d recharge=%v next=%v ammo=%d coldAmmo=%d stack=%d", + player.attackRating(), target.health, cold.characters[1000000].health, player.rechargeUntil.Sub(hit), player.nextAttack.Sub(hit), + player.inventory.Items[0].Ammo, cold.characters[1].inventory.Items[0].Ammo, cold.characters[1].inventory.Items[1].Count) + } + }) + } +} diff --git a/server/east_wind_mission_test.go b/server/east_wind_mission_test.go @@ -0,0 +1,139 @@ +package main + +import ( + "ao/server/gamedata" + "bytes" + "testing" +) + +func newEastWindMissionWorld(t *testing.T) (*server, *worldClient, *combatTestConn) { + t.Helper() + definition := gamedata.MissionTemplates[3221228472] + world, output := newMissionOfferWorld(t) + gamedata.MissionTemplates[3221228472] = definition + world.nextNPC = 2000000 + player, client := world.characters[1], world.clients[1] + player.level, player.profession = 2, 6 + player.stats.Melee.TwoHandEdged, player.stats.Melee.MeleeEnergy, player.stats.Body.Brawling = 8, 6, 8 + player.stats.ImprovementPoints = 200 + player.health, player.nano = player.maximumHealth(), player.maximumNano() + for stat, raw := range map[uint32]uint16{105: 8, 104: 6, 142: 8} { + if uint32(raw) > player.trainingMaximum(stat) { + t.Fatal("controlled raw skill exceeds its native cap", stat) + } + } + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + world.combatRoll = func(uint32) uint32 { return 7 } + if err := world.handleMissionOffers(client, missionOffersRequest()); err != nil { + t.Fatal(err) + } + if client.missionOffer == nil || client.missionOffer.definition.RewardItem != 160216 || client.missionOffer.definition.RewardQuality != 2 { + t.Fatal("production pool did not advertise the selected period reward") + } + client.missionOffer.seed = 2 + if err := world.handleMissionAcceptance(client, missionAcceptanceRequest(*client.missionOffer)); err != nil { + t.Fatal(err) + } + + // Public entry/pickup prepare a saved hand-in checkpoint without a playthrough. + 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.savePosition_locked(player); err != nil { + t.Fatal(err) + } + if err := world.handleMovement(client, playerMovementRequest(player, 1)); err != nil { + t.Fatal(err) + } + client.ready, world.clients[1] = true, client + player.position, player.movement = world.worldItems[3].position, playerMovement{} + if err := world.handleInventory(client, worldPickupRequest(1, 3)); err != nil { + t.Fatal(err) + } + destination := player.userData() + destination.Playfield, destination.Position = 3000, [3]float32{99.8, 115.75, 151.4} + if err := world.updateUser_locked(destination); err != nil { + t.Fatal(err) + } + world.clients[1], client.ready, client.loading = client, true, false + output.packets = nil + return world, client, output +} + +func TestEastWindMissionRewardFailuresPreserveThePromiseAndRetry(t *testing.T) { + for _, scenario := range []struct{ name, sql string }{ + {"ignored item", "CREATE TRIGGER fail_reward BEFORE INSERT ON items WHEN NEW.id=4 BEGIN SELECT RAISE(IGNORE); END"}, + {"ignored completion", "CREATE TRIGGER fail_reward BEFORE UPDATE OF completed ON missions BEGIN SELECT RAISE(IGNORE); END"}, + {"rewritten reward", "CREATE TRIGGER fail_reward AFTER UPDATE OF last_item_id ON world BEGIN UPDATE items SET quality=1 WHERE id=4; END"}, + {"commit", "CREATE TABLE pending_reward (id INTEGER REFERENCES players(id) DEFERRABLE INITIALLY DEFERRED); CREATE TRIGGER fail_reward AFTER INSERT ON items WHEN NEW.id=4 BEGIN INSERT INTO pending_reward VALUES(999999); END"}, + } { + t.Run(scenario.name, func(t *testing.T) { + world, client, output := newEastWindMissionWorld(t) + before, err := readTestItemStore(world) + if err != nil { + t.Fatal(err) + } + if _, err := world.db.Exec(scenario.sql); err != nil { + t.Fatal(err) + } + + failure := world.handleMissionReturn(client, missionReturnRequest(1)) + after, err := readTestItemStore(world) + cold := reloadMissionEntranceWorld(t) + + if failure == nil || err != nil || !bytes.Equal(before, after) || len(output.packets) != 0 || + world.missionExpiry[0].completed || cold.missionExpiry[0].completed || cold.nextItem != 3 || + len(cold.characters[1].inventory.Items) != 3 || cold.characters[1].inventory.Credits != 3 { + t.Fatal("failed period reward changed its promise, book/key, wallet, instance counter or output", failure, err) + } + + if _, err := world.db.Exec("DROP TRIGGER fail_reward"); err != nil { + t.Fatal(err) + } + for range 2 { + if err := world.handleMissionReturn(client, missionReturnRequest(2)); err != nil { + t.Fatal(err) + } + } + cold = reloadMissionEntranceWorld(t) + + if !cold.missionExpiry[0].completed || cold.nextItem != 4 || len(cold.characters[1].inventory.Items) != 2 || + cold.characters[1].inventory.Credits != 23 || cold.characters[1].inventory.Items[1] != + (ownedItem{ID: 4, Type: 51018, Template: 160216, Quality: 2, Slot: 65, Count: 1}) { + t.Fatal("period reward retry duplicated or changed its selected instance or payment") + } + }) + } +} + +func TestEastWindMissionRewardSurvivesHandInTrainingAndColdRecovery(t *testing.T) { + world, client, _ := newEastWindMissionWorld(t) + player := world.characters[1] + trained := player.baseStats() + trained.Melee.TwoHandEdged = 9 + + for range 2 { + if err := world.handleMissionReturn(client, missionReturnRequest(1)); err != nil { + t.Fatal(err) + } + } + if err := world.handleInventory(client, inventoryMovePacket(1, 65, 6)[20:]); err != nil || client.equipment != nil { + t.Fatal("equality admitted the promised weapon", err) + } + if err := world.handleSkillTraining(client, skillTrainingRequest(trained)[20:]); err != nil { + t.Fatal(err) + } + if err := world.handleInventory(client, inventoryMovePacket(1, 65, 6)[20:]); err != nil || client.equipment == nil { + t.Fatal("normally trained promised weapon did not start wear", err) + } + world.advanceEquipment(client.equipment.readyAt) + cold := reloadMissionEntranceWorld(t) + + if len(player.inventory.Items) != 2 || player.inventory.Items[1] != (ownedItem{ID: 4, Type: 51018, Template: 160216, Quality: 2, Slot: 6, Count: 1}) || + player.inventory.Credits != 23 || player.stats.ImprovementPoints != 188 || player.attackRating() != 9 || + cold.characters[1].inventory.Items[1] != player.inventory.Items[1] || cold.characters[1].attackRating() != 9 || + cold.characters[1].stats != player.stats || !cold.missionExpiry[0].completed || cold.nextItem != 4 { + t.Fatal("mission hand-in, training or cold replay changed the period reward or its accounting") + } +} diff --git a/server/east_wind_test.go b/server/east_wind_test.go @@ -0,0 +1,52 @@ +package main + +import ( + "ao/server/gamedata" + "slices" + "testing" +) + +func TestEastWindQualifiedIntermediateWear(t *testing.T) { + world, _ := newEquipmentWorld(t) + player, client := world.characters[1], world.clients[1] + player.profession = 6 + player.stats.Melee.TwoHandEdged, player.stats.Melee.MeleeEnergy, player.stats.Body.Brawling = 9, 6, 8 + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + if granted, err := world.grantItem_locked(player, 160216); err != nil || !granted { + t.Fatal(granted, err) + } + player.inventory.Items[1].Quality = 2 + if err := world.saveInventory_locked(player, player.inventory); err != nil { + t.Fatal(err) + } + + err := world.handleInventory(client, inventoryMovePacket(1, 65, 6)[20:]) + + if err != nil || client.equipment == nil { + t.Fatal("qualified Adventurer's QL2 East Wind Katana did not start wear", err) + } +} + +func TestEastWindPeriodRewardCanBeAdvertised(t *testing.T) { + definition := gamedata.MissionTemplates[3221228472] + world, _ := newMissionOfferWorld(t) + gamedata.MissionTemplates[3221228472] = definition + player, client := world.characters[1], world.clients[1] + player.level, player.profession = 2, 6 + if err := world.saveUser_locked(player); err != nil { + t.Fatal(err) + } + index := slices.Index(definition.RewardItems, uint32(160216)) + if index < 0 { + t.Fatal("period-documented East Wind Katana is missing from mission rewards") + } + world.combatRoll = func(uint32) uint32 { return uint32(index) } + + err := world.handleMissionOffers(client, missionOffersRequest()) + + if err != nil || client.missionOffer == nil || client.missionOffer.definition.RewardItem != 160216 || client.missionOffer.definition.RewardQuality != 2 { + t.Fatal("selected-quality period reward was not advertised", err) + } +} diff --git a/server/gamedata/item_families.yaml b/server/gamedata/item_families.yaml @@ -132,3 +132,5 @@ - [85691, 22004] - [85692, 22026] - [85745, 21929] +# East Wind Katana: original complete descriptors and period acquisition; docs/east-wind.md. +- [160216, 160217] diff --git a/server/gamedata/item_quality_test.go b/server/gamedata/item_quality_test.go @@ -48,6 +48,7 @@ func TestReviewedItemFamilyQualityRanges(t *testing.T) { {150274, 150273, 1, 255}, {85516, 22301, 1, 200}, {85598, 22178, 1, 200}, {85641, 22116, 1, 200}, {85691, 22004, 1, 200}, {85692, 22026, 1, 200}, {85745, 21929, 1, 200}, + {160216, 160217, 1, 199}, } { for _, template := range [2]uint32{family.lowTemplate, family.highTemplate} { t.Run(fmt.Sprint(template), func(t *testing.T) { diff --git a/server/gamedata/mission_booths_test.go b/server/gamedata/mission_booths_test.go @@ -88,7 +88,7 @@ func TestStarterMissionTemplateReferencesOriginalAssets(t *testing.T) { item := ItemTemplates[definition.ObjectiveItem] if definition.Playfield != booth.Playfield || definition.Playfield != 3000 || definition.Entrance != 3221228472 || - !slices.Equal(definition.RewardItems, []uint32{85596, 85742, 85638, 85512, 85557, 85686, 122691}) || definition.RewardQuality != 0 || + !slices.Equal(definition.RewardItems, []uint32{85596, 85742, 85638, 85512, 85557, 85686, 122691, 160216}) || definition.RewardQuality != 0 || !ItemQualitySupported(85596, 2) || !ItemQualitySupported(122691, 2) || definition.PassageDoor != 41565 || definition.Position != [3]float32{89.30216217041016, 115.14443969726562, 151.16087341308594} || item == nil || item.ID != 40822 || item.Quality == nil || *item.Quality != 1 || diff --git a/server/gamedata/missions.yaml b/server/gamedata/missions.yaml @@ -17,8 +17,10 @@ credits: 20 experience: 100 - # Reconstruction pool at mission QL; original membership and probabilities are unresolved. - reward_items: [85596, 85742, 85638, 85512, 85557, 85686, 122691] + # Reconstruction pool at mission QL; original probabilities are unresolved. + # East Wind Katana160216/160217 has period mission-terminal evidence; docs/east-wind.md. + # Other membership and the mission-level/QL selection remain provisional. + reward_items: [85596, 85742, 85638, 85512, 85557, 85686, 122691, 160216] # Native-tested open passage; historical mission-style selection is unresolved. passage_door: 41565 diff --git a/server/mission_reward_pool_test.go b/server/mission_reward_pool_test.go @@ -12,7 +12,7 @@ import ( func TestStarterMissionRewardPoolRetainsEveryFamilyAtTheSelectedMissionQuality(t *testing.T) { for choice, endpoints := range [][2]uint32{ {85596, 85595}, {85742, 85741}, {85638, 85637}, {85512, 85511}, - {85557, 85556}, {85686, 85685}, {122691, 122692}, + {85557, 85556}, {85686, 85685}, {122691, 122692}, {160216, 160217}, } { t.Run(fmt.Sprint(endpoints[0]), func(t *testing.T) { definition := gamedata.MissionTemplates[3221228472] @@ -26,7 +26,7 @@ func TestStarterMissionRewardPoolRetainsEveryFamilyAtTheSelectedMissionQuality(t } draws := 0 world.combatRoll = func(bound uint32) uint32 { - if bound != 7 { + if bound != 8 { t.Fatal("production reward pool lost a reviewed family", bound) } draws++ diff --git a/tools/client/test_east_wind_cold.mjs b/tools/client/test_east_wind_cold.mjs @@ -0,0 +1,35 @@ +import assert from 'node:assert/strict'; +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; +try { + const context = await browser.newContext({viewport: {width: 1024, height: 768}}); + await context.addCookies([{name: 'ao_client', value: 'east-wind', url}]); + const page = await context.newPage(); + game = await GameTest.attach(page); + await page.goto(url); + await game.ready(); + await page.waitForFunction(() => touchRegion(500, 400)?.world === true); + 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]]) + 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); + assert.equal(state.lastID, 4); + assert.equal(state.inventory.Items.length, 2); + await game.key('KeyI'); + await page.keyboard.press('Control+1'); + assert.deepEqual(game.errors, []); + console.log('PASS: cold period reward retains exact identities, QL, training, weighted rating and wallet without replay'); +} finally { + try { if (game) await game.save(output + '/final'); } + finally { await browser.close(); } +} diff --git a/tools/client/test_east_wind_reward.mjs b/tools/client/test_east_wind_reward.mjs @@ -0,0 +1,88 @@ +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: 'east-wind', url}]); + const page = await context.newPage(); + game = await GameTest.attach(page); + const server = async () => (await page.request.get(url + '/test-state')).json(); + await page.goto(url); + await game.ready(); + await page.waitForFunction(() => touchRegion(500, 400)?.world === true); + await game.snapshot(); + evidence.before = await server(); + assert.equal(evidence.before.completed, false); + assert.equal(evidence.before.inventory.Credits, 3); + assert.equal(game.local().stats[60], 6); + const selection = Buffer.alloc(20); + [2018, 160216, 160217, 2, 0].forEach((value, index) => selection.writeUInt32BE(value, index * 4)); + assert(game.events.some(event => event.direction === 'framereceived' && Buffer.from(event.hex, 'hex').includes(selection))); + await game.key('KeyI'); + await game.page.keyboard.press('Control+1'); + await game.save(output + '/promised'); + + // 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 && + 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(); + assert.equal(evidence.delivered.completed, true); + assert.deepEqual(evidence.delivered.inventory.Items, [evidence.before.inventory.Items[0], + {ID: 4, Type: 51018, Template: 160216, Quality: 2, Slot: 65, Count: 1, Ammo: 0}]); + await game.save(output + '/delivered'); + + // Equality refuses wear locally; one normal raw skill point qualifies the same reward. + const sequence = game.sequence; + await game.click(738, 45, 'right'); + await game.save(output + '/wear-rejected'); + assert(!game.events.some(event => event.sequence > sequence && event.direction === 'framesent' && event.opcode === '47537a24')); + assert.deepEqual((await server()).inventory, evidence.delivered.inventory); + await game.key('KeyU'); + await game.click(300, 272); + await game.save(output + '/skill-before'); + await game.click(835, 286); + await game.click(445, 622); + await game.wait('normally trained 2h Edged', state => game.local(state).stats[105] === 9 && game.local(state).stats[53] === 188); + await game.click(738, 45, 'right'); + await game.wait('same rewarded Katana worn', state => game.local(state).inventory.some(item => item.id === 4 && item.slot === 6)); + assert.equal((await server()).rating, 9); + assert.equal(game.local().stats[22], 9); + await game.save(output + '/worn'); + await game.click(867, 206, 'right'); + await game.wait('same reward removed', state => game.local(state).inventory.some(item => item.id === 4 && item.slot === 49)); + await game.wait('removal action finished', state => !game.local(state).actions.includes(3)); + await game.click(738, 45, 'right'); + await game.wait('same reward re-worn', state => game.local(state).inventory.some(item => item.id === 4 && item.slot === 6)); + evidence.worn = await server(); + await fs.writeFile(output + '/ledger.json', JSON.stringify(evidence.worn, null, 2) + '\n'); + + await page.reload(); + await game.ready(); + await page.waitForFunction(() => touchRegion(500, 400)?.world === true); + 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]]); + assert.equal(game.local().stats[22], 9); + evidence.reloaded = await server(); + assert.deepEqual(evidence.reloaded, evidence.worn); + assert.deepEqual(game.errors, []); + console.log('PASS: period reward advertisement, native hand-in, equality refusal, 12-IP training and same-instance wear/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(); } +}