commit 66b87639b143d5245c2e3a492bcd4e895f7188c4
parent 324b4dccf928c66adc492b43195db6262d06a6f0
Author: anon <anon@example.com>
Date: Thu, 5 Nov 2026 21:22:38 +0000
Stock supported early nanos in faction basic shops
Diffstat:
6 files changed, 607 insertions(+), 46 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -112,14 +112,19 @@ research separately. More screenshots and test cases do not count as new gamepla
1180/1183/1186. The four empty training terminals now carry seven original QL1
recovery/ammunition packages under an explicit provisional stock policy;
all four pass native buy/sell, cancel, recovery use, bullet reload, reconnect
- and cold recovery checks. 159 placements still have no catalog rows. The three
- basic weapon terminals now add QL5/10 M-10 pistols, E-Beamers, Vektors and
- Sledgehammers alongside ammunition. All three pass native purchase, equip,
+ and cold recovery checks. The three basic weapon terminals now add QL5/10
+ M-10 pistols, E-Beamers, Vektors and Sledgehammers alongside ammunition.
+ All three pass native purchase, equip,
reload/attack, cancellation, reconnect and cold recovery for these families.
- Rifle/SMG upgrades, profession essentials,
- visible specialty-terminal limitations and ordinary-reward affordability
- remain open. Funded fixtures do not establish affordability; the stock ledger
- also records unfinished weapon specials rather than claiming complete combat
+ Thirty-six crystal terminals now carry 19 original early nanos with complete
+ supported contracts; all 36 pass native buy/sell, cancel, upload/cast and
+ reconnect/cold recovery, with every row covered by server regressions.
+ 123 placements remain empty. Meta-Physicist combat nanos and pet attacks,
+ Engineer robots and other unfinished profession essentials
+ remain open alongside rifle/SMG upgrades, visible specialty-terminal
+ limitations and ordinary-reward affordability. Funded fixtures do not establish
+ affordability; the stock ledger also records unfinished weapon specials
+ rather than claiming complete combat
support from a successful ordinary attack.
## P0: playable and releasable
diff --git a/docs/early-shop-stock.md b/docs/early-shop-stock.md
@@ -10,8 +10,10 @@ browse/buy/use behavior.
Baseline: 163 placements had no catalog rows, including all four training-ground
terminals. The training terminals now each carry seven recovery/ammunition rows,
-leaving 159 empty placements. The three basic weapon terminals now contain four
-ammunition packages and eight weapon rows. Profession crystal terminals remain empty.
+leaving 159 empty placements before nano stock. The three basic weapon terminals
+contain four ammunition packages and eight weapon rows. Thirty-six profession and
+general crystal terminals now stock an early subset, leaving 123 empty placements.
+The three Meta-Physicist terminals still lack usable early combat stock.
## Training-ground resupply
@@ -88,7 +90,7 @@ coverage are in [M-10 pistols](catalog-weapons.md), [E-Beamers](e-beamer.md),
[Vektors](vektor-shotguns.md) and [Sledgehammers](sledgehammer.md). All four support
ordinary attacks. M-10/E-Beamer Fling uses the existing handler. Sledgehammer
Brawl/Dimach remain unimplemented shared actions; stock does not complete them.
-Rifle/SMG upgrades and profession nanos remain outstanding. These funded checks
+Rifle/SMG upgrades and unfinished profession essentials remain outstanding. These funded checks
do not establish that ordinary early rewards can pay the listed prices.
### Weapon verification, November 5
@@ -129,6 +131,89 @@ intermittently intercepted camera drag. The passing runs retain the full
purchase/use/recovery assertions. These checks close the missing stock for this
four-family subset, not A5's remaining content, specialty labels or affordability.
+## Basic nano crystals
+
+The eleven stocked profession categories each supply one useful original early
+spell. General terminals add Minor Healing and seven weapon proficiencies. All
+three factions share these fixed selections at their authored qualities; terminal
+membership is provisional alpha policy, not recovered historical stock rotation.
+No spell requirements, effects, prices or casting rules are relaxed by the stock.
+
+| Profession/category | Crystal -> program | QL | Use | Omni price | Clan/Neutral price |
+| --- | --- | --- | --- | --- | --- |
+| Soldier | 75415 -> 75413 | 4 | Minor Combat Barrier: all armor +21 | 831 | 872 |
+| Martial Artist | 75354 -> 75350 | 1 | Toughen Skin: melee armor +16, others +14 | 201 | 211 |
+| Engineer | 70577 -> 70548 | 4 | Greater Armor Megaboost: all armor +23 | 833 | 874 |
+| Fixer | 85273 -> 85215 | 4 | Basic Insurance Hack: periodic healing 2-6 | 820 | 861 |
+| Agent | 81952 -> 81942 | 4 | Lesser Suspicious Death: periodic damage 2 | 830 | 871 |
+| Adventurer | 82082 -> 82064 | 7 | Rough Stitching: healing 41-72 | 1536 | 1612 |
+| Trader | 30764 -> 30713 | 7 | Balanced Striker: ranged initiative +15, projectile/energy damage +4 | 1536 | 1612 |
+| Bureaucrat | 56003 -> 55992 | 4 | Lesser Illusory Paralysis: root | 824 | 865 |
+| Enforcer | 202849 -> 202848 | 8 | Threat of the Bully: 2H Blunt +14 | 1777 | 1865 |
+| Doctor | 43957 -> 43831 | 4 | Inferior Wound Bindings: healing 36-59 | 827 | 868 |
+| Nanotechnician | 28811 -> 28608 | 7 | Fire Stream: fire damage 26-46 | 1510 | 1585 |
+| General | 26681 -> 26465 | 1 | Minor Healing: healing 5-10 | 201 | 211 |
+| General | 27265 -> 27080 | 4 | Pistol Proficiency: +10 | 828 | 869 |
+| General | 27285 -> 27149 | 4 | Rifle Proficiency: +10 | 828 | 869 |
+| General | 27228 -> 27093 | 4 | Submachine Gun Proficiency: +10 | 828 | 869 |
+| General | 27298 -> 27162 | 4 | Shotgun Proficiency: +10 | 828 | 869 |
+| General | 27205 -> 27075 | 4 | 2H Blunt Weapon Proficiency: +10 | 828 | 869 |
+| General | 27232 -> 27097 | 4 | Martial Arts Proficiency: +10 | 828 | 869 |
+| General | 26481 -> 26354 | 4 | Assault Rifle Proficiency: +10 | 828 | 869 |
+
+Prices precede Computer Literacy discounts. These are upgrades or additional
+abilities, not replacement copies of already-issued startup crystals. Existing
+complete-contract audits in `server/testdata/*nanos.json` and runtime admission
+supply their original effects and requirements. The fixture profession field is
+not always an original restriction: general nanos remain available to all
+professions. The new checkpoint caps every trained nano skill at its native
+level-ten maximum. It does not establish earned IP allocation or affordability.
+
+### Nano verification, November 5
+
+`TestBasicShopNanosPurchaseLearnCastAndRecover` passes all 57 combinations of
+19 crystals and three factions. It buys each authored row at an exact expected
+price, repeats Accept, uploads the purchased instance, casts through the ordinary
+handler, checks the resulting buff/root/health effect and restores the database.
+The six-test focused batch also passes the existing stock admission, concurrent
+purchase, rejected-write/retry and rejected crystal-upload regressions.
+
+`TestBrowserBasicShopNanos` and `tools/client/test_basic_shop_nanos.mjs` pass all
+36 newly stocked terminal placements using real right-click/E opening, buy/sell,
+cancellation, crystal upload, native program selection/casting, page reconnect
+and cold database recovery. Every profession row is purchased and used; General
+terminals expose all eight rows and purchase/cast Minor Healing. The seven General
+weapon proficiencies have all-row server coverage rather than separate native
+casts. Armor buffs and healing/damage are compared with native effective armor
+and health; other buffs retain exact original program delivery checks, with
+server effect assertions. The controlled hostile target uses native Tab selection.
+Catalog and program captures were inspected.
+
+The complete browser run is `local/alpha-nanos/browser-verified.log`, with all
+36 placement directories under `local/alpha-nanos/20261105-130924/`. Server checks
+are in `regressions.log`; `go vet ./server`, JavaScript syntax and diff checks
+also pass (`vet.log`). Test servers and browser processes were closed after the
+run. There was no extended progression or historical stock search. These checks
+complete this fixed stock subset, not the remaining A5 profession, specialty-label
+or affordability requirements.
+
+### Remaining profession essentials
+
+Stock is not a claim that each profession has its complete early combat path.
+Engineer Feeble Automaton (43329 -> 43325) is not supported. Meta-Physicist Mind
+Pain (29193 -> 29114) has an additional linked effect and fails complete-contract
+admission; Lesser Anger Manifestation can summon/follow but lacks pet attack
+commands. These are concrete A5/A7 dependencies. Trader Weak Delayed Health
+Payment (43378 -> 43374) is also unsupported, though its separate starter Weak
+Health Funnel is supported. None of those incomplete crystals is sold here.
+
+Symbol Helper (29192 -> 29113) was considered for Meta-Physicist stock but rejected:
+its Psychological Modification/Sensory Improvement requirements exceed the
+unbuffed level-ten checkpoint. It is crafting utility in any case, so stocking it
+would not resolve the missing combat essentials. The three Meta-Physicist
+terminals remain empty pending useful supported content; their visible limitation
+labels are still part of A5's outstanding specialty/unsupported UI work.
+
## Placement census
| Playfield | Terminal identity | Template | Original name | Stock rows | Position X, Y, Z |
@@ -148,19 +233,19 @@ four-family subset, not A5's remaining content, specialty labels or affordabilit
| 1180 | `0xc008049c` | 155308 | Shining Nano Clusters - Basic | 0 | 154.00, 5.01, 183.00 |
| 1180 | `0xc009049c` | 155296 | Melee Weapon Components - Basic | 0 | 159.00, 5.01, 163.00 |
| 1180 | `0xc00a049c` | 155490 | Ranged Weapon Components - Basic | 0 | 165.97, 5.01, 163.00 |
-| 1180 | `0xc00b049c` | 90589 | Basic Clan Adventurer Crystals | 0 | 197.00, 5.01, 207.00 |
-| 1180 | `0xc00c049c` | 90588 | Basic Clan Agent Crystals | 0 | 201.00, 5.01, 209.00 |
-| 1180 | `0xc00d049c` | 90587 | Basic Clan Bureaucrat Crystals | 0 | 205.00, 5.01, 209.00 |
-| 1180 | `0xc00e049c` | 90586 | Basic Clan Doctor Crystals | 0 | 209.00, 5.01, 209.00 |
-| 1180 | `0xc00f049c` | 90585 | Basic Clan Enforcer Crystals | 0 | 213.00, 5.01, 209.00 |
-| 1180 | `0xc010049c` | 90579 | Basic Clan Engineer Crystals | 0 | 217.00, 5.01, 207.00 |
-| 1180 | `0xc011049c` | 90576 | Basic Clan Fixer Crystals | 0 | 217.00, 5.01, 203.00 |
-| 1180 | `0xc012049c` | 90574 | Basic Clan General Crystals | 0 | 209.00, 5.01, 193.00 |
-| 1180 | `0xc013049c` | 90571 | Basic Clan Martial Artist Crystals | 0 | 217.00, 5.01, 195.00 |
+| 1180 | `0xc00b049c` | 90589 | Basic Clan Adventurer Crystals | 1 | 197.00, 5.01, 207.00 |
+| 1180 | `0xc00c049c` | 90588 | Basic Clan Agent Crystals | 1 | 201.00, 5.01, 209.00 |
+| 1180 | `0xc00d049c` | 90587 | Basic Clan Bureaucrat Crystals | 1 | 205.00, 5.01, 209.00 |
+| 1180 | `0xc00e049c` | 90586 | Basic Clan Doctor Crystals | 1 | 209.00, 5.01, 209.00 |
+| 1180 | `0xc00f049c` | 90585 | Basic Clan Enforcer Crystals | 1 | 213.00, 5.01, 209.00 |
+| 1180 | `0xc010049c` | 90579 | Basic Clan Engineer Crystals | 1 | 217.00, 5.01, 207.00 |
+| 1180 | `0xc011049c` | 90576 | Basic Clan Fixer Crystals | 1 | 217.00, 5.01, 203.00 |
+| 1180 | `0xc012049c` | 90574 | Basic Clan General Crystals | 8 | 209.00, 5.01, 193.00 |
+| 1180 | `0xc013049c` | 90571 | Basic Clan Martial Artist Crystals | 1 | 217.00, 5.01, 195.00 |
| 1180 | `0xc014049c` | 90569 | Basic Clan Meta-Physicist Crystals | 0 | 213.00, 5.01, 193.00 |
-| 1180 | `0xc015049c` | 90567 | Basic Clan Nanotechnician Crystals | 0 | 217.00, 5.01, 199.00 |
-| 1180 | `0xc016049c` | 90564 | Basic Clan Soldier Crystals | 0 | 197.00, 5.01, 199.00 |
-| 1180 | `0xc017049c` | 90562 | Basic Clan Trader Crystals | 0 | 197.00, 5.01, 203.00 |
+| 1180 | `0xc015049c` | 90567 | Basic Clan Nanotechnician Crystals | 1 | 217.00, 5.01, 199.00 |
+| 1180 | `0xc016049c` | 90564 | Basic Clan Soldier Crystals | 1 | 197.00, 5.01, 199.00 |
+| 1180 | `0xc017049c` | 90562 | Basic Clan Trader Crystals | 1 | 197.00, 5.01, 203.00 |
| 1180 | `0xc018049c` | 155493 | Mechanical and Electrical Engineering Components - Basic | 0 | 149.00, 5.01, 163.00 |
| 1180 | `0xc019049c` | 155314 | Pharmacy and Chemistry Components - Basic | 0 | 153.99, 5.01, 163.00 |
| 1180 | `0xc01a049c` | 155496 | Armour and Clothing Components - Basic | 0 | 143.00, 5.01, 163.00 |
@@ -202,19 +287,19 @@ four-family subset, not A5's remaining content, specialty labels or affordabilit
| 1183 | `0xc007049f` | 117649 | OT Maps | 5 | 196.70, 5.00, 129.00 |
| 1183 | `0xc008049f` | 155599 | Basic Bookstore | 0 | 192.00, 5.00, 131.00 |
| 1183 | `0xc009049f` | 155603 | Omni Basic Devices | 1 | 196.70, 5.00, 133.00 |
-| 1183 | `0xc00a049f` | 90590 | Basic Omni-Tek Adventurer Crystals | 0 | 183.20, 5.00, 169.00 |
-| 1183 | `0xc00b049f` | 90580 | Basic Omni-Tek Agent Crystals | 0 | 187.00, 5.00, 170.80 |
-| 1183 | `0xc00c049f` | 90581 | Basic Omni-Tek Bureaucrat Crystals | 0 | 191.00, 5.00, 170.80 |
-| 1183 | `0xc00d049f` | 90582 | Basic Omni-Tek Doctor Crystals | 0 | 195.00, 5.00, 170.80 |
-| 1183 | `0xc00e049f` | 90583 | Basic Omni-Tek Enforcer Crystals | 0 | 199.00, 5.00, 170.80 |
-| 1183 | `0xc00f049f` | 90577 | Basic Omni-Tek Engineer Crystals | 0 | 202.80, 5.00, 169.00 |
-| 1183 | `0xc010049f` | 90575 | Basic Omni-Tek Fixer Crystals | 0 | 202.80, 5.00, 165.00 |
-| 1183 | `0xc011049f` | 90573 | Basic Omni-Tek General Crystals | 0 | 195.00, 5.00, 155.20 |
-| 1183 | `0xc012049f` | 90570 | Basic Omni-Tek Martial Artist Crystals | 0 | 202.80, 5.00, 157.00 |
+| 1183 | `0xc00a049f` | 90590 | Basic Omni-Tek Adventurer Crystals | 1 | 183.20, 5.00, 169.00 |
+| 1183 | `0xc00b049f` | 90580 | Basic Omni-Tek Agent Crystals | 1 | 187.00, 5.00, 170.80 |
+| 1183 | `0xc00c049f` | 90581 | Basic Omni-Tek Bureaucrat Crystals | 1 | 191.00, 5.00, 170.80 |
+| 1183 | `0xc00d049f` | 90582 | Basic Omni-Tek Doctor Crystals | 1 | 195.00, 5.00, 170.80 |
+| 1183 | `0xc00e049f` | 90583 | Basic Omni-Tek Enforcer Crystals | 1 | 199.00, 5.00, 170.80 |
+| 1183 | `0xc00f049f` | 90577 | Basic Omni-Tek Engineer Crystals | 1 | 202.80, 5.00, 169.00 |
+| 1183 | `0xc010049f` | 90575 | Basic Omni-Tek Fixer Crystals | 1 | 202.80, 5.00, 165.00 |
+| 1183 | `0xc011049f` | 90573 | Basic Omni-Tek General Crystals | 8 | 195.00, 5.00, 155.20 |
+| 1183 | `0xc012049f` | 90570 | Basic Omni-Tek Martial Artist Crystals | 1 | 202.80, 5.00, 157.00 |
| 1183 | `0xc013049f` | 90568 | Basic Omni-Tek Meta-Physicist Crystals | 0 | 199.00, 5.00, 155.20 |
-| 1183 | `0xc014049f` | 90565 | Basic Omni-Tek Nanotechnician Crystals | 0 | 202.80, 5.00, 161.00 |
-| 1183 | `0xc015049f` | 90563 | Basic Omni-Tek Soldier Crystals | 0 | 183.20, 5.00, 161.00 |
-| 1183 | `0xc016049f` | 90561 | Basic Omni-Tek Trader Crystals | 0 | 183.20, 5.00, 165.00 |
+| 1183 | `0xc014049f` | 90565 | Basic Omni-Tek Nanotechnician Crystals | 1 | 202.80, 5.00, 161.00 |
+| 1183 | `0xc015049f` | 90563 | Basic Omni-Tek Soldier Crystals | 1 | 183.20, 5.00, 161.00 |
+| 1183 | `0xc016049f` | 90561 | Basic Omni-Tek Trader Crystals | 1 | 183.20, 5.00, 165.00 |
| 1183 | `0xc017049f` | 155508 | General Recipes - Basic | 0 | 119.00, 5.00, 123.00 |
| 1183 | `0xc018049f` | 155502 | Melee Weapon Recipes - Basic | 0 | 117.00, 5.00, 123.00 |
| 1183 | `0xc019049f` | 155505 | Ranged Weapon Recipes - Basic | 0 | 115.00, 5.00, 123.00 |
@@ -268,19 +353,19 @@ four-family subset, not A5's remaining content, specialty labels or affordabilit
| 1183 | `0xc04d049f` | 162185 | Basic Omni-Tek Nanotechnician Specific Implants | 0 | 212.60, 5.01, 106.40 |
| 1183 | `0xc04e049f` | 162188 | Basic Omni-Tek Soldier Specific Implants | 0 | 204.00, 5.01, 126.00 |
| 1183 | `0xc04f049f` | 162191 | Basic Omni-Tek Trader Specific Implants | 0 | 209.00, 5.01, 136.00 |
-| 1186 | `0xc00004a2` | 43580 | Basic Adventurer Crystals | 0 | 171.00, 5.00, 161.00 |
-| 1186 | `0xc00104a2` | 43579 | Basic Agent Crystals | 0 | 175.00, 5.00, 163.00 |
-| 1186 | `0xc00204a2` | 43578 | Basic Bureaucrat Crystals | 0 | 179.00, 5.00, 163.00 |
-| 1186 | `0xc00304a2` | 43577 | Basic Doctor Crystals | 0 | 183.00, 5.00, 163.00 |
-| 1186 | `0xc00404a2` | 43581 | Basic Enforcer Crystals | 0 | 187.00, 5.00, 163.00 |
-| 1186 | `0xc00504a2` | 43576 | Basic Engineer Crystals | 0 | 191.00, 5.00, 161.00 |
-| 1186 | `0xc00604a2` | 43571 | Basic Fixer Crystals | 0 | 191.00, 5.00, 157.00 |
-| 1186 | `0xc00704a2` | 43569 | Basic General Crystals | 0 | 183.00, 5.00, 147.00 |
-| 1186 | `0xc00804a2` | 43575 | Basic Martial Artist Crystals | 0 | 191.00, 5.00, 149.00 |
+| 1186 | `0xc00004a2` | 43580 | Basic Adventurer Crystals | 1 | 171.00, 5.00, 161.00 |
+| 1186 | `0xc00104a2` | 43579 | Basic Agent Crystals | 1 | 175.00, 5.00, 163.00 |
+| 1186 | `0xc00204a2` | 43578 | Basic Bureaucrat Crystals | 1 | 179.00, 5.00, 163.00 |
+| 1186 | `0xc00304a2` | 43577 | Basic Doctor Crystals | 1 | 183.00, 5.00, 163.00 |
+| 1186 | `0xc00404a2` | 43581 | Basic Enforcer Crystals | 1 | 187.00, 5.00, 163.00 |
+| 1186 | `0xc00504a2` | 43576 | Basic Engineer Crystals | 1 | 191.00, 5.00, 161.00 |
+| 1186 | `0xc00604a2` | 43571 | Basic Fixer Crystals | 1 | 191.00, 5.00, 157.00 |
+| 1186 | `0xc00704a2` | 43569 | Basic General Crystals | 8 | 183.00, 5.00, 147.00 |
+| 1186 | `0xc00804a2` | 43575 | Basic Martial Artist Crystals | 1 | 191.00, 5.00, 149.00 |
| 1186 | `0xc00904a2` | 43574 | Basic Meta-Physicist Crystals | 0 | 187.00, 5.00, 147.00 |
-| 1186 | `0xc00a04a2` | 43573 | Basic Nanotechnician Crystals | 0 | 191.00, 5.00, 153.00 |
-| 1186 | `0xc00b04a2` | 43572 | Basic Soldier Crystals | 0 | 171.00, 5.00, 153.00 |
-| 1186 | `0xc00c04a2` | 43570 | Basic Trader Crystals | 0 | 171.00, 5.00, 157.00 |
+| 1186 | `0xc00a04a2` | 43573 | Basic Nanotechnician Crystals | 1 | 191.00, 5.00, 153.00 |
+| 1186 | `0xc00b04a2` | 43572 | Basic Soldier Crystals | 1 | 171.00, 5.00, 153.00 |
+| 1186 | `0xc00c04a2` | 43570 | Basic Trader Crystals | 1 | 171.00, 5.00, 157.00 |
| 1186 | `0xc00d04a2` | 99570 | Basic Armor | 22 | 182.63, 5.00, 132.61 |
| 1186 | `0xc00e04a2` | 99602 | Basic Attacks | 0 | 169.41, 5.00, 116.65 |
| 1186 | `0xc00f04a2` | 99598 | Basic Augmentations | 0 | 166.67, 5.00, 119.51 |
diff --git a/server/basic_shop_nanos_test.go b/server/basic_shop_nanos_test.go
@@ -0,0 +1,160 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "encoding/binary"
+ "fmt"
+ "reflect"
+ "slices"
+ "testing"
+ "time"
+)
+
+type basicShopNanoFixture struct {
+ prices [2]uint32
+ profession uint32
+ machines [3]uint32
+ crystal, program, quality uint32
+ stat uint32
+ bonus int32
+ minimum, maximum uint32
+ hostile bool
+}
+
+func basicShopNanoFixtures() []basicShopNanoFixture {
+ return []basicShopNanoFixture{
+ {[2]uint32{831, 872}, 1, [3]uint32{0xc015049f, 0xc016049c, 0xc00b04a2}, 75415, 75413, 4, 90, 21, 0, 0, false},
+ {[2]uint32{201, 211}, 2, [3]uint32{0xc012049f, 0xc013049c, 0xc00804a2}, 75354, 75350, 1, 91, 16, 0, 0, false},
+ {[2]uint32{833, 874}, 3, [3]uint32{0xc00f049f, 0xc010049c, 0xc00504a2}, 70577, 70548, 4, 90, 23, 0, 0, false},
+ {[2]uint32{820, 861}, 4, [3]uint32{0xc010049f, 0xc011049c, 0xc00604a2}, 85273, 85215, 4, 0, 0, 2, 6, false},
+ {[2]uint32{830, 871}, 5, [3]uint32{0xc00b049f, 0xc00c049c, 0xc00104a2}, 81952, 81942, 4, 0, 0, 2, 2, true},
+ {[2]uint32{1536, 1612}, 6, [3]uint32{0xc00a049f, 0xc00b049c, 0xc00004a2}, 82082, 82064, 7, 0, 0, 41, 72, false},
+ {[2]uint32{1536, 1612}, 7, [3]uint32{0xc016049f, 0xc017049c, 0xc00c04a2}, 30764, 30713, 7, 119, 15, 0, 0, false},
+ {[2]uint32{824, 865}, 8, [3]uint32{0xc00c049f, 0xc00d049c, 0xc00204a2}, 56003, 55992, 4, 0, 0, 0, 0, true},
+ {[2]uint32{1777, 1865}, 9, [3]uint32{0xc00e049f, 0xc00f049c, 0xc00404a2}, 202849, 202848, 8, 107, 14, 0, 0, false},
+ {[2]uint32{827, 868}, 10, [3]uint32{0xc00d049f, 0xc00e049c, 0xc00304a2}, 43957, 43831, 4, 0, 0, 36, 59, false},
+ {[2]uint32{1510, 1585}, 11, [3]uint32{0xc014049f, 0xc015049c, 0xc00a04a2}, 28811, 28608, 7, 0, 0, 26, 46, true},
+ {[2]uint32{201, 211}, 1, [3]uint32{0xc011049f, 0xc012049c, 0xc00704a2}, 26681, 26465, 1, 0, 0, 5, 10, false},
+ {[2]uint32{828, 869}, 1, [3]uint32{0xc011049f, 0xc012049c, 0xc00704a2}, 27265, 27080, 4, 112, 10, 0, 0, false},
+ {[2]uint32{828, 869}, 1, [3]uint32{0xc011049f, 0xc012049c, 0xc00704a2}, 27285, 27149, 4, 113, 10, 0, 0, false},
+ {[2]uint32{828, 869}, 1, [3]uint32{0xc011049f, 0xc012049c, 0xc00704a2}, 27228, 27093, 4, 114, 10, 0, 0, false},
+ {[2]uint32{828, 869}, 1, [3]uint32{0xc011049f, 0xc012049c, 0xc00704a2}, 27298, 27162, 4, 115, 10, 0, 0, false},
+ {[2]uint32{828, 869}, 1, [3]uint32{0xc011049f, 0xc012049c, 0xc00704a2}, 27205, 27075, 4, 107, 10, 0, 0, false},
+ {[2]uint32{828, 869}, 1, [3]uint32{0xc011049f, 0xc012049c, 0xc00704a2}, 27232, 27097, 4, 100, 10, 0, 0, false},
+ {[2]uint32{828, 869}, 1, [3]uint32{0xc011049f, 0xc012049c, 0xc00704a2}, 26481, 26354, 4, 116, 10, 0, 0, false},
+ }
+}
+
+func trainBasicShopNanoFixture(player *character, profession uint32) {
+ // A funded level-ten checkpoint; no claim of earned IP or affordability.
+ player.level, player.profession = 10, uint16(profession)
+ player.stats.Abilities = characterAbilitiesStats{36, 36, 36, 36, 36, 36}
+ for _, field := range player.stats.trainingStats() {
+ if field.stat == 122 || field.stat >= 127 && field.stat <= 132 {
+ *field.value = uint16(player.trainingMaximum(field.stat))
+ }
+ }
+ player.stats.TradeRepair.ComputerLiteracy = 0
+ player.health, player.nano = 20, player.maximumNano()
+}
+
+func TestBasicShopNanosPurchaseLearnCastAndRecover(t *testing.T) {
+ for _, fixture := range basicShopNanoFixtures() {
+ for _, machineID := range fixture.machines {
+ t.Run(fmt.Sprintf("%x/%d", machineID, fixture.crystal), func(t *testing.T) {
+ world, _ := newPurchaseWorld(t)
+ player, client, target := world.characters[1], world.clients[1], world.characters[1000000]
+ machine := gamedata.ShopMachines[machineID]
+ player.playfield, player.position = machine.Playfield, machine.Position
+ player.appearance = map[uint32]uint16{1183: 0x515, 1180: 0x315, 1186: 0x115}[machine.Playfield]
+ trainBasicShopNanoFixture(player, fixture.profession)
+ player.inventory.Credits = 10000
+ target.playfield, target.position, target.health = player.playfield, player.position, 100
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ if err := world.saveInventory_locked(player, player.inventory); err != nil {
+ t.Fatal(err)
+ }
+ request := shopUseRequest(2)
+ binary.BigEndian.PutUint32(request[44:48], machineID)
+
+ // Buy the exact authored row; repeated Accept must not duplicate it.
+ if err := world.handleShopUse(client, request); err != nil {
+ t.Fatal(err)
+ }
+ row := gamedata.ShopItem{Template: fixture.crystal, Quality: fixture.quality}
+ index := slices.Index(client.shop.stock, row)
+ if index < 0 || nanoCrystalProgram(fixture.crystal) != fixture.program {
+ t.Fatal("missing complete supported crystal", row)
+ }
+ if err := world.handleTrade(client, shopTradePacket([2]uint32{50000, 1}, 4, [2]uint32{51035, machineID}, [2]uint32{111, uint32(index)})[20:]); err != nil {
+ t.Fatal(err)
+ }
+ accept := shopTradePacket([2]uint32{50000, 1}, 1, [2]uint32{}, [2]uint32{})[20:]
+ for range 2 {
+ if err := world.handleTrade(client, accept); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if len(player.inventory.Items) != 2 || player.inventory.Items[1] != (ownedItem{ID: 2, Type: 51005, Template: fixture.crystal, Quality: fixture.quality, Slot: 65, Count: 1}) {
+ t.Fatal("crystal purchase changed identity or quality", player.inventory)
+ }
+ credits := player.inventory.Credits
+ price := fixture.prices[0]
+ if machine.Playfield != 1183 {
+ price = fixture.prices[1]
+ }
+ if credits != 10000-price {
+ t.Fatal("crystal purchase charged wrong price", credits, price)
+ }
+
+ // Upload the purchase and cast it through the ordinary public handlers.
+ if err := world.handleOwnedItemUse(client, backpackUseRequest(1, 65, 3)[20:]); err != nil {
+ t.Fatal(err)
+ }
+ if !slices.Equal(player.inventory.LearnedNanos, []uint32{fixture.program}) || len(player.inventory.Items) != 1 {
+ t.Fatal("purchased crystal cannot be learned at level ten", player.inventory, player.stats.NanoAiding)
+ }
+ recipient := player
+ if fixture.hostile {
+ recipient = target
+ }
+ beforeHealth, beforeNano := recipient.health, player.nano
+ at := castTestBuff(t, world, 1, recipient.id, fixture.program)
+ if fixture.program == 85215 || fixture.program == 81942 {
+ world.advanceNanos(recipient.activeNanos[0].nextTick.Add(time.Nanosecond))
+ }
+
+ if player.nano >= beforeNano || player.nanoReserved != 0 {
+ t.Fatal("cast did not spend nano once")
+ }
+ if fixture.stat != 0 && player.nanoBonus(fixture.stat) != fixture.bonus {
+ t.Fatal("purchased buff did not apply", player.activeNanos)
+ }
+ if fixture.minimum != 0 {
+ amount := recipient.health - beforeHealth
+ if fixture.hostile {
+ amount = beforeHealth - recipient.health
+ }
+ if amount < fixture.minimum || amount > fixture.maximum {
+ t.Fatal("purchased nano has wrong health effect", amount, at)
+ }
+ }
+ if fixture.program == 55992 && (len(target.activeNanos) != 1 || !target.movementRestricted()) {
+ t.Fatal("purchased root did not stop target")
+ }
+
+ // Credits, consumed crystal, learned program and effects survive restart.
+ cold := newTestInventoryServer(t).characters[1]
+ if !reflect.DeepEqual(cold.inventory, player.inventory) || cold.inventory.Credits != credits || world.nextItem != 2 || cold.nano != player.nano {
+ t.Fatal("purchase/upload/cast changed during cold recovery")
+ }
+ if fixture.stat != 0 && cold.nanoBonus(fixture.stat) != fixture.bonus {
+ t.Fatal("buff did not recover")
+ }
+ t.Logf("price=%d", 10000-credits)
+ })
+ }
+ }
+}
diff --git a/server/browser_basic_shop_nanos_test.go b/server/browser_basic_shop_nanos_test.go
@@ -0,0 +1,132 @@
+package main
+
+import (
+ "ao/server/gamedata"
+ "context"
+ "crypto/sha256"
+ "encoding/json"
+ "fmt"
+ "math"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
+ "slices"
+ "testing"
+ "time"
+)
+
+func TestBrowserBasicShopNanos(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for the basic crystal terminals")
+ }
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ output := filepath.Join(root, "local/alpha-nanos", time.Now().Format("20060102-150405"))
+ // Every terminal is visited; the general terminal uses its healing row here.
+ // The server regression purchases and casts every general weapon proficiency.
+ for _, fixture := range basicShopNanoFixtures()[:12] {
+ for _, identity := range fixture.machines {
+ t.Run(fmt.Sprintf("%x", identity), func(t *testing.T) {
+ world := newTestServer(t)
+ machine := gamedata.ShopMachines[identity]
+ player := world.newCharacter()
+ player.playfield, player.position = machine.Playfield, machine.Position
+ player.appearance = map[uint32]uint16{1183: 0x515, 1180: 0x315, 1186: 0x115}[machine.Playfield]
+ forward, _ := bodyAxes(machine.Rotation)
+ player.position[0] += 3 * forward[0]
+ player.position[2] += 3 * forward[2]
+ player.position[1] += .5
+ yaw := math.Atan2(float64(machine.Position[0]-player.position[0]), float64(machine.Position[2]-player.position[2]))
+ player.rotation = [4]float32{0, float32(math.Sin(yaw / 2)), 0, float32(math.Cos(yaw / 2))}
+ trainBasicShopNanoFixture(player, fixture.profession)
+ player.browserTokenHash = fmt.Sprintf("%x", sha256.Sum256([]byte("basic-shop-nanos")))
+ if err := world.saveUser_locked(player); err != nil {
+ t.Fatal(err)
+ }
+ inventory := playerInventory{Credits: 10000, LastID: 1, Items: []ownedItem{
+ {ID: 1, Type: 51018, Template: 209283, Quality: 1, Slot: 64, Count: 1},
+ }}
+ if err := world.saveInventory_locked(player, inventory); err != nil {
+ t.Fatal(err)
+ }
+ var target *character
+ for _, actor := range world.characters {
+ if actor.npc && actor.playfield == 950 && actor.monsterData == 17655 && actor.level == 1 && actor.combatProfile != nil && (target == nil || actor.id < target.id) {
+ target = actor
+ }
+ }
+ if target == nil {
+ t.Fatal("missing original Leet fixture")
+ }
+ target.playfield, target.position, target.health = player.playfield, player.position, 1000
+ target.position[0] -= 1.5 * forward[0]
+ target.position[2] -= 1.5 * forward[2]
+ world.combatRoll = landedCombatRoll
+ creditsAfterPurchase := uint32(10000 - fixture.prices[0] + 605)
+ if machine.Playfield != 1183 {
+ creditsAfterPurchase = 10000 - fixture.prices[1] + 484
+ }
+ mux := http.NewServeMux()
+ mux.Handle("/", world.httpHandler())
+ mux.HandleFunc("GET /test-state", func(w http.ResponseWriter, r *http.Request) {
+ world.mutex.Lock()
+ defer world.mutex.Unlock()
+ open, purchases, sales := false, 0, 0
+ if client := world.clients[1]; client != nil && client.shop != nil {
+ open, sales = true, len(client.shop.items)
+ for _, count := range client.shop.purchases {
+ purchases += int(count)
+ }
+ }
+ recipient := player
+ if fixture.hostile {
+ recipient = target
+ }
+ var effects []uint32
+ for _, effect := range recipient.activeNanos {
+ effects = append(effects, effect.program)
+ }
+ json.NewEncoder(w).Encode(map[string]any{"machine": identity, "playfield": machine.Playfield,
+ "creditsAfterPurchase": creditsAfterPurchase, "rows": len(gamedata.ShopStock[machine.Template]), "crystal": fixture.crystal, "program": fixture.program, "quality": fixture.quality,
+ "stat": fixture.stat, "bonus": fixture.bonus, "minimum": fixture.minimum, "maximum": fixture.maximum, "hostile": fixture.hostile,
+ "open": open, "purchases": purchases, "sales": sales, "inventory": player.inventory, "target": recipient.id, "health": recipient.health,
+ "nano": player.nano, "reserved": player.nanoReserved, "effects": effects, "appliedBonus": player.nanoBonus(fixture.stat), "rooted": target.movementRestricted()})
+ })
+ host := httptest.NewServer(mux)
+ defer host.Close()
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
+ stopped := make(chan struct{})
+ go func() {
+ defer close(stopped)
+ clock := time.NewTicker(time.Second / 60)
+ defer clock.Stop()
+ for {
+ select {
+ case now := <-clock.C:
+ world.advancePlayerMovement(now)
+ world.advanceNanos(now)
+ case <-ctx.Done():
+ return
+ }
+ }
+ }()
+ defer func() { cancel(); <-stopped }()
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_basic_shop_nanos.mjs"), host.URL, filepath.Join(output, fmt.Sprintf("%x", identity)))
+ command.Dir, command.Stdout, command.Stderr = root, os.Stdout, os.Stderr
+ err := command.Run()
+ t.Logf("Browser artifacts: %s", filepath.Join(output, fmt.Sprintf("%x", identity)))
+ if err != nil {
+ t.Fatal(err)
+ }
+ cold := newTestInventoryServer(t).characters[1]
+ if cold.inventory.Credits != creditsAfterPurchase || cold.inventory.LastID != 2 || len(cold.inventory.Items) != 0 ||
+ !slices.Equal(cold.inventory.LearnedNanos, []uint32{fixture.program}) || fixture.stat != 0 && cold.nanoBonus(fixture.stat) != fixture.bonus {
+ t.Fatal("purchased nano changed during cold recovery", cold.inventory, cold.activeNanos)
+ }
+ })
+ }
+ }
+}
diff --git a/server/gamedata/shop_stock.yaml b/server/gamedata/shop_stock.yaml
@@ -121,3 +121,61 @@
100035: *starter_supplies
100034: *starter_supplies
99643: *starter_supplies
+
+# Basic nano crystals: a fixed early subset with complete supported contracts.
+# Membership is provisional alpha policy; docs/early-shop-stock.md.
+90563: &basic_soldier_nanos
+ - {template: 75415, quality: 4}
+90564: *basic_soldier_nanos
+43572: *basic_soldier_nanos
+90570: &basic_martial_artist_nanos
+ - {template: 75354, quality: 1}
+90571: *basic_martial_artist_nanos
+43575: *basic_martial_artist_nanos
+90577: &basic_engineer_nanos
+ - {template: 70577, quality: 4}
+90579: *basic_engineer_nanos
+43576: *basic_engineer_nanos
+90575: &basic_fixer_nanos
+ - {template: 85273, quality: 4}
+90576: *basic_fixer_nanos
+43571: *basic_fixer_nanos
+90580: &basic_agent_nanos
+ - {template: 81952, quality: 4}
+90588: *basic_agent_nanos
+43579: *basic_agent_nanos
+90590: &basic_adventurer_nanos
+ - {template: 82082, quality: 7}
+90589: *basic_adventurer_nanos
+43580: *basic_adventurer_nanos
+90561: &basic_trader_nanos
+ - {template: 30764, quality: 7}
+90562: *basic_trader_nanos
+43570: *basic_trader_nanos
+90581: &basic_bureaucrat_nanos
+ - {template: 56003, quality: 4}
+90587: *basic_bureaucrat_nanos
+43578: *basic_bureaucrat_nanos
+90583: &basic_enforcer_nanos
+ - {template: 202849, quality: 8}
+90585: *basic_enforcer_nanos
+43581: *basic_enforcer_nanos
+90582: &basic_doctor_nanos
+ - {template: 43957, quality: 4}
+90586: *basic_doctor_nanos
+43577: *basic_doctor_nanos
+90565: &basic_nanotechnician_nanos
+ - {template: 28811, quality: 7}
+90567: *basic_nanotechnician_nanos
+43573: *basic_nanotechnician_nanos
+90573: &basic_general_nanos
+ - {template: 26681, quality: 1}
+ - {template: 27265, quality: 4}
+ - {template: 27285, quality: 4}
+ - {template: 27228, quality: 4}
+ - {template: 27298, quality: 4}
+ - {template: 27205, quality: 4}
+ - {template: 27232, quality: 4}
+ - {template: 26481, quality: 4}
+90574: *basic_general_nanos
+43569: *basic_general_nanos
diff --git a/tools/client/test_basic_shop_nanos.mjs b/tools/client/test_basic_shop_nanos.mjs
@@ -0,0 +1,121 @@
+import assert from 'node:assert/strict';
+import fs from 'node:fs/promises';
+import {createRequire} from 'node:module';
+import {GameTest} from './game_test.mjs';
+
+const {chromium} = createRequire(import.meta.url)('playwright');
+const [url, output] = process.argv.slice(2);
+const browser = await chromium.launch({executablePath: '/usr/bin/chromium', args: [
+ '--enable-gpu', '--use-gl=angle', '--use-angle=gl', '--no-sandbox', '--disable-dev-shm-usage',
+ '--disable-background-timer-throttling', '--disable-renderer-backgrounding']});
+let game;
+const evidence = {};
+try {
+ const context = await browser.newContext({viewport: {width: 1024, height: 768}});
+ await context.addCookies([{name: 'ao_client', value: 'basic-shop-nanos', url}]);
+ const page = await context.newPage();
+ game = await GameTest.attach(page);
+ const server = async () => (await page.request.get(url + '/test-state')).json();
+ const waitServer = (label, predicate) => game.waitFor(label, async () => predicate(await server()));
+ const cell = (type, slot) => game.state.grids.flatMap(grid => grid.cells).find(cell =>
+ cell.identity[0] === type && cell.identity[1] === slot && !cell.dummy);
+ const click = async (source, button = 'left') => {
+ assert(source, 'expected native cell is present');
+ await game.click((source.bounds[0] + source.bounds[2]) / 2, (source.bounds[1] + source.bounds[3]) / 2, button);
+ };
+ await page.goto(url);
+ await game.ready();
+ if (!game.state.camera.firstPerson) await game.key('F8');
+ await game.key('KeyI');
+ const initial = evidence.initial = await server();
+ const open = async keyboard => {
+ await game.click(...await game.pick(51035, initial.machine), keyboard ? 'left' : 'right');
+ if (keyboard) await game.key('KeyE');
+ await game.wait('original crystal catalog visible', () =>
+ Array.from({length: initial.rows}, (_, index) => cell(111, index)).every(Boolean));
+ };
+ await open(false);
+ await game.save(output + '/catalog');
+ await click(cell(111, 0));
+ await waitServer('crystal in purchase basket', state => state.purchases === 1);
+ await click(cell(104, 48));
+ await game.wait('sale loot picked', state => state.dragged[0] === 104);
+ await game.click(860, 412);
+ await waitServer('loot in sale basket', state => state.sales === 1);
+ await game.click(873, 475);
+ await waitServer('crystal purchase committed', state => !state.open && state.inventory.Items.length === 1 && state.inventory.Items[0].Template === initial.crystal);
+ const bought = evidence.bought = await server();
+ assert.equal(bought.inventory.Credits, initial.creditsAfterPurchase);
+ assert.deepEqual(bought.inventory.Items.map(item => [item.ID, item.Type, item.Template, item.Quality, item.Count]),
+ [[2, 51005, initial.crystal, initial.quality, 1]]);
+ await game.wait("native purchase cash and crystal arrived", state => game.local(state).stats[61] === bought.inventory.Credits && game.local(state).inventory.some(item => item.quality === initial.quality));
+
+ // Cancel and reopen the same terminal before consuming the exact purchase.
+ await open(true);
+ await click(cell(111, 0));
+ await waitServer('cancel basket selected', state => state.purchases === 1);
+ await game.click(945, 475);
+ await waitServer('cancel completed', state => !state.open);
+ assert.deepEqual((await server()).inventory, bought.inventory);
+ await click(cell(104, bought.inventory.Items[0].Slot - 16), 'right');
+ await waitServer('purchased crystal uploaded once', state =>
+ state.inventory.Items.length === 0 && state.inventory.LearnedNanos?.includes(initial.program));
+ await page.keyboard.press('Control+8');
+ // Find the uploaded program among the five native school tabs.
+ for (const [x, y] of [[865, 76], [974, 76], [865, 96], [927, 96], [987, 96]]) {
+ if (cell(53019, initial.program)) break;
+ await game.click(x, y);
+ await game.snapshot();
+ }
+ assert(cell(53019, initial.program), 'purchased program visible in its native school');
+ if (initial.hostile) {
+ await game.key('Tab');
+ await game.wait('native Tab selects controlled target', state => state.selected[0] === 50000 && state.selected[1] === initial.target);
+ } else {
+ await game.key('F1');
+ }
+ const beforeCast = evidence.beforeCast = await server();
+ const nativeArmor = initial.stat >= 90 && initial.stat <= 97 ? game.local().effectiveArmor[initial.stat - 90] : null;
+ const castSequence = game.sequence;
+ await click(cell(53019, initial.program), 'right');
+ await waitServer('purchased nano cast completed', state => state.nano < beforeCast.nano && state.reserved === 0);
+ if (initial.minimum) {
+ await waitServer('purchased nano changes target health', state => state.health !== beforeCast.health);
+ }
+ const cast = evidence.cast = await server();
+ if (initial.stat) {
+ assert.equal(cast.appliedBonus, initial.bonus);
+ await game.wait('original buff delivered to the client', () => game.events.some(event => {
+ if (event.sequence <= castSequence || event.direction !== 'framereceived' || event.opcode !== '5e477770') return false;
+ const packet = Buffer.from(event.hex, 'hex');
+ return packet.readUInt32BE(29) === 177 && packet.readUInt32BE(37) === initial.program;
+ }));
+ if (nativeArmor !== null) await game.wait('native armor agrees with server', state =>
+ game.local(state).effectiveArmor[initial.stat - 90] === nativeArmor + initial.bonus);
+ }
+ if (initial.program === 55992) assert(cast.rooted);
+ if (initial.minimum) {
+ const amount = initial.hostile ? beforeCast.health - cast.health : cast.health - beforeCast.health;
+ assert(amount >= initial.minimum && amount <= initial.maximum, 'authored health effect');
+ await game.wait('native health agrees with server result', state =>
+ state.actors.find(actor => actor.type === 50000 && actor.id === initial.target)?.stats[27] === cast.health);
+ }
+ await game.save(output + '/cast');
+ await page.reload();
+ await game.ready();
+ evidence.reconnected = await server();
+ assert.deepEqual(evidence.reconnected.inventory, cast.inventory);
+ if (initial.stat) {
+ assert.equal(evidence.reconnected.appliedBonus, initial.bonus);
+ if (nativeArmor !== null) assert.equal(game.local().effectiveArmor[initial.stat - 90], nativeArmor + initial.bonus);
+ }
+ assert.equal(game.local().stats[61], cast.inventory.Credits);
+ assert.deepEqual(game.errors, []);
+ console.log('PASS:', initial.machine, 'crystal', initial.crystal, 'native buy/sell, cancel, learn/cast and reconnect');
+} finally {
+ try {
+ await fs.mkdir(output, {recursive: true});
+ await fs.writeFile(output + '/verification.json', JSON.stringify(evidence, null, 2) + '\n');
+ if (game) await game.save(output + '/final');
+ } finally { await browser.close(); }
+}