commit 0098f592910b747fa2a99b7636d6d8de28a0d658
parent 73a1fade94e280f5e572ebf79f7adb56463e8cc7
Author: anon <anon@example.com>
Date: Sun, 8 Nov 2026 19:18:01 +0000
Fix indoor vendor acquisition maps and simplify location navigation
Diffstat:
8 files changed, 259 insertions(+), 57 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -173,6 +173,11 @@ research separately. More screenshots and test cases do not count as new gamepla
November 6: read-only acquisition browsing, original item icons and provisional
30-minute restocking are documented in [shop stock](docs/shop-stock-expansion.md).
Shop changes remain embedded YAML plus a rebuild.
+ November 8: indoor seller locations now resolve to outdoor shop entrances,
+ including shared interiors and nested shops. Acquisition maps use clickable
+ location links without general map controls or live player/NPC feeds. Server
+ regressions cover entrance routing and unchanged outdoor vendors; Chromium
+ verifies link clicks center the entrance marker and general map controls work.
November 5: [the finite terminal inventory](docs/early-shop-stock.md) lists
all 190 placements in training grounds 950/952/954 and basic shops
1180/1183/1186. The four empty training terminals now carry seven original QL1
diff --git a/server/assets/map.js b/server/assets/map.js
@@ -7,7 +7,7 @@ class AOMap {
this.context = this.canvas.getContext("2d");
this.status = element.querySelector("[data-map-status]");
this.location = element.querySelector("[data-map-location]");
- this.view = element.querySelector("[data-map-view]");
+ this.view = "world";
this.form = element.querySelector("[data-map-teleport]");
this.character = Number(element.dataset.character);
this.players = [];
@@ -35,26 +35,30 @@ class AOMap {
this.zones = new Map(this.manifest.zones.map(zone => [zone.id, zone]));
const sourceData = this.element.parentElement.querySelector("[data-item-sources]");
if (sourceData) this.sources = JSON.parse(sourceData.textContent);
- for (const zone of this.manifest.zones.filter(zone => !zone.origin).sort((a, b) => a.name.localeCompare(b.name))) {
- const option = document.createElement("option");
- option.value = zone.id;
- option.textContent = `${zone.name} (${zone.id})`;
- this.view.append(option);
- }
- const find = this.element.querySelector("[data-map-find]");
- for (const zone of this.manifest.zones.filter(zone => zone.origin).sort((a, b) => a.name.localeCompare(b.name))) {
- const option = document.createElement("option");
- option.value = zone.id;
- option.textContent = `${zone.name} (${zone.id})`;
- find.append(option);
- }
- find.addEventListener("change", () => {
- if (find.value) this.focusZone(this.zones.get(Number(find.value)));
- });
- this.view.addEventListener("change", () => {
- find.value = "";
- this.fit(this.bounds());
- });
+ const view = this.element.querySelector("[data-map-view]");
+ if (view) {
+ for (const zone of this.manifest.zones.filter(zone => !zone.origin).sort((a, b) => a.name.localeCompare(b.name))) {
+ const option = document.createElement("option");
+ option.value = zone.id;
+ option.textContent = `${zone.name} (${zone.id})`;
+ view.append(option);
+ }
+ const find = this.element.querySelector("[data-map-find]");
+ for (const zone of this.manifest.zones.filter(zone => zone.origin).sort((a, b) => a.name.localeCompare(b.name))) {
+ const option = document.createElement("option");
+ option.value = zone.id;
+ option.textContent = `${zone.name} (${zone.id})`;
+ find.append(option);
+ }
+ find.addEventListener("change", () => {
+ if (find.value) this.focusZone(this.zones.get(Number(find.value)));
+ });
+ view.addEventListener("change", () => {
+ this.view = view.value;
+ find.value = "";
+ this.fit(this.bounds());
+ });
+ }
if (this.form) {
this.form.elements.playfield.addEventListener("change", () => {
const zone = this.zones.get(Number(this.form.elements.playfield.value));
@@ -62,7 +66,7 @@ class AOMap {
if (zone) this.selectDestination(zone, [this.pendingPoint[0] - zone.origin[0], this.pendingPoint[1] - zone.origin[1]]);
});
}
- this.element.querySelector("[data-map-center]").addEventListener("click", () => this.centerPlayer());
+ this.element.querySelector("[data-map-center]")?.addEventListener("click", () => this.centerPlayer());
for (const button of this.element.querySelectorAll("[data-map-zoom]")) {
button.addEventListener("click", () => this.zoom(1.5 ** Number(button.dataset.mapZoom), this.width / 2, this.height / 2));
}
@@ -83,10 +87,16 @@ class AOMap {
new ResizeObserver(() => this.resize()).observe(this.canvas);
this.resize();
this.fit(this.bounds());
- const sourceChoice = this.element.parentElement.querySelector("[data-map-source]");
- if (sourceChoice) {
- sourceChoice.addEventListener("change", () => this.focusSource(this.sources[Number(sourceChoice.value)]));
+ if (sourceData) {
+ for (const link of this.element.parentElement.querySelectorAll("[data-map-source]")) {
+ link.addEventListener("click", event => {
+ event.preventDefault();
+ this.focusSource(this.sources[Number(link.dataset.mapSource)]);
+ this.canvas.scrollIntoView({block: "nearest"});
+ });
+ }
this.focusSource(this.sources[0]);
+ return;
}
const query = new URLSearchParams(window.location.search);
if (query.has("playfield") && query.has("x") && query.has("z")) {
@@ -144,7 +154,7 @@ class AOMap {
entityQuery() {
const [left, top] = this.toWorld(0, 0), [right, bottom] = this.toWorld(this.width, this.height);
const npcs = this.element.querySelector("[data-map-npcs]").checked && this.detailVisible("npcs");
- return new URLSearchParams({view: this.view.value, left, bottom, right, top,
+ return new URLSearchParams({view: this.view, left, bottom, right, top,
npcs: npcs ? "1" : "0", warps: this.element.querySelector("[data-map-warps]").checked && this.detailVisible() ? "1" : "0"}).toString();
}
@@ -164,8 +174,8 @@ class AOMap {
}
bounds() {
- if (this.view.value === "world") return this.manifest.planet.bounds;
- const zone = this.zones.get(Number(this.view.value));
+ if (this.view === "world") return this.manifest.planet.bounds;
+ const zone = this.zones.get(Number(this.view));
return [0, 0, zone.width, zone.height];
}
@@ -185,7 +195,7 @@ class AOMap {
focusZone(zone) {
// Focus the outdoor boundary while keeping the shared world coordinates.
- this.view.value = "world";
+ this.view = "world";
const boundary = zone.boundary || [[0, 0], [zone.width, zone.height]];
this.fit([zone.origin[0] + Math.min(...boundary.map(point => point[0])),
zone.origin[1] + Math.min(...boundary.map(point => point[1])),
@@ -200,7 +210,7 @@ class AOMap {
return;
}
this.initialized = true;
- this.view.value = zone.origin ? "world" : String(zone.id);
+ this.view = zone.origin ? "world" : String(zone.id);
this.center = this.playerPoint(source);
this.scale = 1;
this.location.textContent = `${source.name}: ${zone.name} (${zone.id}), X ${source.position[0].toFixed(1)}, Z ${source.position[2].toFixed(1)}.`;
@@ -217,12 +227,12 @@ class AOMap {
const player = this.players.find(player => player.id === this.character);
const zone = player && this.zones.get(player.playfield);
if (zone && !zone.origin && zone.levels.length) {
- this.view.value = player.playfield;
+ this.view = player.playfield;
this.fit(this.bounds());
this.center = [player.position[0], player.position[2]];
this.scale = Math.max(this.scale, 0.75);
} else {
- this.view.value = "world";
+ this.view = "world";
this.fit(this.bounds());
if (player) {
const point = this.playerPoint(player);
@@ -284,8 +294,8 @@ class AOMap {
}
playerPoint(player) {
- if (this.view.value !== "world") {
- if (player.playfield === Number(this.view.value)) return [player.position[0], player.position[2]];
+ if (this.view !== "world") {
+ if (player.playfield === Number(this.view)) return [player.position[0], player.position[2]];
return null;
}
const current = this.zones.get(player.playfield);
@@ -422,7 +432,7 @@ class AOMap {
if (!this.form) return;
const point = this.toWorld(x, y);
let zone;
- if (this.view.value === "world") {
+ if (this.view === "world") {
const candidates = this.manifest.zones.filter(zone => zone.origin && this.contains(zone, [point[0] - zone.origin[0], point[1] - zone.origin[1]]));
if (this.form) {
const select = this.form.elements.playfield;
@@ -443,7 +453,7 @@ class AOMap {
point[0] -= zone.origin[0];
point[1] -= zone.origin[1];
} else {
- zone = this.zones.get(Number(this.view.value));
+ zone = this.zones.get(Number(this.view));
if (this.form) this.form.elements.playfield.replaceChildren(new Option(zone.name, zone.id));
}
if (!this.contains(zone, point)) {
@@ -475,11 +485,13 @@ class AOMap {
}
render() {
+ const view = this.element.querySelector("[data-map-view]");
+ if (view) view.value = this.view;
const ctx = this.context;
ctx.fillStyle = "#222";
ctx.fillRect(0, 0, this.width, this.height);
this.visible = new Set();
- if (this.view.value === "world") {
+ if (this.view === "world") {
this.layer(this.manifest.planet.levels, this.manifest.planet.bounds);
for (const zone of [...this.manifest.zones].sort((a, b) => b.width * b.height - a.width * a.height)) {
if (!zone.origin) continue;
@@ -499,7 +511,7 @@ class AOMap {
if (zone.origin && zone.boundary) ctx.stroke(this.boundaryPath(zone, zone.origin));
}
} else {
- const zone = this.zones.get(Number(this.view.value));
+ const zone = this.zones.get(Number(this.view));
this.layer(zone.levels, [0, 0, zone.width, zone.height]);
ctx.strokeStyle = "#aaa";
ctx.lineWidth = 1;
@@ -561,7 +573,7 @@ class AOMap {
ctx.fillStyle = player.id === this.character ? "#ff4040" : "#00cfff";
if (player.connected) ctx.fill();
ctx.stroke();
- const atEntrance = player.entrance && this.view.value === "world" && !this.zones.get(player.playfield)?.origin;
+ const atEntrance = player.entrance && this.view === "world" && !this.zones.get(player.playfield)?.origin;
const label = `${player.title ? player.title + " " : ""}${player.name}${player.connected ? "" : " (offline)"}${atEntrance ? ` [${player.zone} entrance]` : ""}`;
ctx.lineWidth = 3;
ctx.strokeStyle = "#000";
@@ -571,7 +583,7 @@ class AOMap {
}
if (this.selection) {
let [x, z] = this.selection.point;
- if (this.view.value === "world") {
+ if (this.view === "world") {
x += this.selection.zone.origin[0];
z += this.selection.zone.origin[1];
}
@@ -593,10 +605,10 @@ class AOMap {
this.tiles.delete(path);
}
this.loadTiles();
- const zone = this.zones.get(Number(this.view.value));
+ const zone = this.zones.get(Number(this.view));
const detail = zone && (!zone.levels || !zone.levels.length) ? " No extracted imagery for this playfield yet." : "";
const failures = [...this.tiles.values()].filter(tile => tile.failed).length;
- this.status.textContent = `${this.players.filter(player => player.connected).length} connected players. ${this.element.querySelector("[data-map-npcs]")?.checked ? (this.detailVisible("npcs") ? `${this.entities.npcs.length} NPCs in view.` : "Zoom in to see NPCs.") : ""}${this.entities.limited ? " Marker limit reached; zoom in." : ""}${detail}${failures ? ` ${failures} tiles failed to load.` : ""}`;
+ this.status.textContent = `${this.sources.length ? "Drag to pan. Pinch or scroll to zoom." : `${this.players.filter(player => player.connected).length} connected players.`} ${this.element.querySelector("[data-map-npcs]")?.checked ? (this.detailVisible("npcs") ? `${this.entities.npcs.length} NPCs in view.` : "Zoom in to see NPCs.") : ""}${this.entities.limited ? " Marker limit reached; zoom in." : ""}${detail}${failures ? ` ${failures} tiles failed to load.` : ""}`;
}
}
diff --git a/server/item_pages.go b/server/item_pages.go
@@ -117,7 +117,7 @@ func (server *server) itemsPage(w http.ResponseWriter, r *http.Request) {
func (server *server) itemCatalogPage(w http.ResponseWriter, r *http.Request) {
catalog := strings.ToLower(strings.TrimSpace(r.FormValue("catalog")))
- sources := itemSources()
+ sources := server.itemSources()
sourceFilter := r.FormValue("source")
var matches []*gamedata.Item
for _, definition := range gamedata.ItemTemplates {
diff --git a/server/item_source_pages.go b/server/item_source_pages.go
@@ -37,12 +37,12 @@ func sourceMap(w http.ResponseWriter, sources []itemSource) {
if err != nil {
panic(err)
}
- fmt.Fprint(w, "<section><h2>Acquisition locations</h2><label>Source location <select data-map-source>")
+ fmt.Fprint(w, "<section><h2>Acquisition locations</h2><ul style='max-height:16rem;overflow:auto'>")
for index, location := range locations {
- fmt.Fprintf(w, "<option value='%d'>%s - %s (%d), X %.1f Z %.1f</option>", index, html.EscapeString(location.Name), html.EscapeString(gamedata.Playfields[location.Playfield].Name), location.Playfield, location.Position[0], location.Position[2])
+ fmt.Fprintf(w, "<li><a href='admin/map?playfield=%d&x=%g&z=%g' data-map-source='%d'>%s - %s (%d), X %.1f Z %.1f</a></li>", location.Playfield, location.Position[0], location.Position[2], index, html.EscapeString(location.Name), html.EscapeString(gamedata.Playfields[location.Playfield].Name), location.Playfield, location.Position[0], location.Position[2])
}
- fmt.Fprintf(w, "</select></label><script type='application/json' data-item-sources>%s</script>", data)
- controlMap(w, 0)
+ fmt.Fprintf(w, "</ul><script type='application/json' data-item-sources>%s</script>", data)
+ fmt.Fprint(w, "<div data-world-map><p data-map-status>Loading maps...</p><p data-map-location>Drag to pan. Pinch or scroll to zoom.</p><canvas data-map-canvas width='1000' height='480' aria-label='Item acquisition map'></canvas></div><script src='admin/control-map.js' defer></script>")
fmt.Fprint(w, "</section>")
}
@@ -53,7 +53,7 @@ func (server *server) itemTemplatePage(w http.ResponseWriter, r *http.Request) {
http.NotFound(w, r)
return
}
- sources := itemSources()[itemFamily(definition.ID)]
+ sources := server.itemSources()[itemFamily(definition.ID)]
server.adminPageStart(w, adminName(definition.Name), "Items")
fmt.Fprintf(w, "<p><a href='admin/items/catalog'>Item catalog</a></p><h1>%s%s</h1><table><tr><th scope='row'>Description</th><td>%s</td></tr><tr><th scope='row'>Mapped sources (QL family)</th><td>%s</td></tr></table>", itemIcon(definition), html.EscapeString(adminName(definition.Name)), html.EscapeString(definition.Description), html.EscapeString(itemSourceSummary(sources)))
sourceMap(w, sources)
@@ -159,7 +159,7 @@ func (server *server) shopCatalogPage(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "<p><a href='admin/items/catalog'>Item catalog</a></p><h1>%s</h1><table><tr><th scope='row'>Shop template</th><td>%d</td></tr><tr><th scope='row'>Access</th><td>%s</td></tr>", itemIcon(definition)+html.EscapeString(adminName(definition.Name)), template, html.EscapeString(shopAccess(definition)))
fmt.Fprint(w, "<tr><th scope='row'>Stock pool</th><td>Possible stock</td></tr><tr><th scope='row'>Always stocked</th><td>Supplies and QL 1-10 equipment</td></tr><tr><th scope='row'>Rotating stock</th><td>Higher-QL weapons and armor</td></tr><tr><th scope='row'>Rotation interval</th><td>30 minutes</td></tr><tr><th scope='row'>Inclusion chance per rotating row</th><td>75%</td></tr><tr><th scope='row'>QL variation</th><td>Up to 10% within supported range</td></tr><tr><th scope='row'>Open-trade stock and prices</th><td>Fixed</td></tr></table>")
// Each catalog repeats its placements per item; one source supplies the map.
- sources := itemSources()
+ sources := server.itemSources()
for _, family := range slices.Sorted(maps.Keys(sources)) {
found := false
for _, source := range sources[family] {
diff --git a/server/item_sources.go b/server/item_sources.go
@@ -41,22 +41,31 @@ func npcSourcePlayfield(id string) uint32 {
}
// Build one family index per page, never scan all sources separately for each catalog row.
-func itemSources() map[uint32][]itemSource {
+func (server *server) itemSources() map[uint32][]itemSource {
sources := make(map[uint32][]itemSource)
sellers := make(map[uint32][]itemSourceLocation)
+ // Reverse authored doors so shared and nested shops expose every entrance.
+ entrances := make(map[uint32][]itemSourceLocation)
+ for _, playfield := range slices.Sorted(maps.Keys(server.zoneLinks["target"])) {
+ for _, door := range server.zoneLinks["target"][playfield].Doors {
+ if door.Destination != 0 && !door.Return {
+ entrances[door.Destination] = append(entrances[door.Destination], itemSourceLocation{"", playfield, door.Position})
+ }
+ }
+ }
for _, id := range slices.Sorted(maps.Keys(gamedata.ShopMachines)) {
machine := gamedata.ShopMachines[id]
if itemStat(gamedata.ItemTemplates[machine.Template], 30)&8 == 0 {
continue
}
- sellers[machine.Template] = append(sellers[machine.Template], itemSourceLocation{
- fmt.Sprintf("%s (machine %d)", gamedata.ItemTemplates[machine.Template].Name, id), machine.Playfield, machine.Position})
+ sellers[machine.Template] = append(sellers[machine.Template], shopSourceLocations(itemSourceLocation{
+ fmt.Sprintf("%s (machine %d)", gamedata.ItemTemplates[machine.Template].Name, id), machine.Playfield, machine.Position}, entrances)...)
}
for _, id := range slices.Sorted(maps.Keys(gamedata.NPCGroups)) {
group := gamedata.NPCGroups[id]
if group.ShopTemplate != 0 {
for _, position := range group.Positions {
- sellers[group.ShopTemplate] = append(sellers[group.ShopTemplate], itemSourceLocation{group.Name, npcSourcePlayfield(id), position})
+ sellers[group.ShopTemplate] = append(sellers[group.ShopTemplate], shopSourceLocations(itemSourceLocation{group.Name, npcSourcePlayfield(id), position}, entrances)...)
}
}
// Use only profiles admitted for this group at levels it can actually spawn at.
@@ -152,6 +161,37 @@ func itemSources() map[uint32][]itemSource {
return sources
}
+func shopSourceLocations(location itemSourceLocation, entrances map[uint32][]itemSourceLocation) []itemSourceLocation {
+ if gamedata.Playfields[location.playfield].Outdoor {
+ return []itemSourceLocation{location}
+ }
+
+ // Walk outward through nested interiors, stopping at outdoor shop doors.
+ var locations []itemSourceLocation
+ pending := []uint32{location.playfield}
+ visited := make(map[uint32]bool)
+ for len(pending) != 0 {
+ playfield := pending[0]
+ pending = pending[1:]
+ if visited[playfield] {
+ continue
+ }
+ visited[playfield] = true
+ for _, entrance := range entrances[playfield] {
+ if gamedata.Playfields[entrance.playfield].Outdoor {
+ entrance.name = location.name + " - " + gamedata.Playfields[location.playfield].Name + " entrance"
+ locations = append(locations, entrance)
+ } else {
+ pending = append(pending, entrance.playfield)
+ }
+ }
+ }
+ if len(locations) == 0 {
+ return []itemSourceLocation{location}
+ }
+ return locations
+}
+
func itemSourceSummary(sources []itemSource) string {
shops := make(map[uint32]int)
loot := make(map[string]bool)
diff --git a/server/item_sources_test.go b/server/item_sources_test.go
@@ -3,16 +3,23 @@ package main
import (
"ao/server/gamedata"
"bytes"
+ "context"
+ "encoding/json"
"image/png"
"net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "runtime"
"slices"
"strconv"
"strings"
"testing"
+ "time"
)
func TestItemSourcesIncludeShopsLootCraftingAndStarterFamilies(t *testing.T) {
- sources := itemSources()
+ sources := newTestServer(t).itemSources()
armor := sources[itemFamily(85595)]
if !slices.ContainsFunc(armor, func(source itemSource) bool {
return source.kind == "Shop" && source.quality == [2]uint32{5, 5} && len(source.locations) > 0
@@ -57,6 +64,63 @@ func TestItemSourcePagesAreReadOnlyAndFilterFamilies(t *testing.T) {
}
}
+func TestShopSourceMapUsesOutdoorEntrancesAndLocationLinks(t *testing.T) {
+ world := newTestServer(t)
+ machines := gamedata.ShopMachines
+ t.Cleanup(func() { gamedata.ShopMachines = machines })
+ gamedata.ShopMachines = map[uint32]gamedata.ShopMachine{
+ 1: {Template: 99491, Playfield: 1183, Position: [3]float32{180, 5, 135}},
+ 2: {Template: 99491, Playfield: 950, Position: [3]float32{50, 14, 60}},
+ }
+ world.zoneLinks = map[string]map[uint32]zoneLinks{"target": {
+ 705: {Doors: []zoneDoor{
+ {Destination: 1183, Position: [3]float32{100, 20, 200}},
+ {Destination: 1183, Position: [3]float32{300, 20, 400}},
+ }},
+ 710: {Doors: []zoneDoor{{Destination: 1184, Position: [3]float32{500, 20, 600}}}},
+ 1184: {Doors: []zoneDoor{{Destination: 1183}}},
+ 1183: {Doors: []zoneDoor{{Destination: 1184}}},
+ }}
+ handler := adminTestHandler(world)
+
+ for _, path := range []string{"/admin/shops/99491", "/admin/items/catalog/95577"} {
+ page := httptest.NewRecorder()
+ handler.ServeHTTP(page, httptest.NewRequest("GET", path, nil))
+
+ _, data, found := strings.Cut(page.Body.String(), "data-item-sources>")
+ data, _, _ = strings.Cut(data, "</script>")
+ var locations []sourceMapLocation
+ if page.Code != 200 || !found || json.Unmarshal([]byte(data), &locations) != nil {
+ t.Fatal("missing source map", path, page.Code)
+ }
+ var placements []mapEntrance
+ for _, location := range locations {
+ if strings.Contains(location.Name, "machine 1)") || strings.Contains(location.Name, "machine 2)") {
+ placements = append(placements, mapEntrance{location.Playfield, location.Position})
+ }
+ if strings.Contains(location.Name, "machine 1)") && !strings.Contains(location.Name, "entrance") {
+ t.Fatal("indoor vendor link does not identify its shop entrance")
+ }
+ }
+ if !slices.Equal(placements, []mapEntrance{
+ {705, [3]float32{100, 20, 200}},
+ {705, [3]float32{300, 20, 400}},
+ {710, [3]float32{500, 20, 600}},
+ {950, [3]float32{50, 14, 60}},
+ }) {
+ t.Fatal("wrong shared/nested entrances or outdoor vendor position", path, placements)
+ }
+ if !strings.Contains(page.Body.String(), "<a href='admin/map?playfield=705&x=100&z=200' data-map-source='") {
+ t.Fatal("missing clickable location link", path)
+ }
+ for _, control := range []string{"data-map-find", "data-map-view", "data-map-offline", "data-map-npcs", "data-map-warps", "data-map-center"} {
+ if strings.Contains(page.Body.String(), control) {
+ t.Fatal("acquisition map retains general map controls", path, control)
+ }
+ }
+ }
+}
+
func TestAdminItemIconUsesOriginalPNG(t *testing.T) {
world := newTestServer(t)
response := httptest.NewRecorder()
@@ -77,3 +141,26 @@ func TestAdminItemIconUsesOriginalPNG(t *testing.T) {
t.Fatal("original green background is not transparent")
}
}
+
+func TestItemSourceMapBrowser(t *testing.T) {
+ if os.Getenv("AO_GAME_TEST") != "1" {
+ t.Skip("set AO_GAME_TEST=1 for acquisition map browser verification")
+ }
+ world := newTestServer(t)
+ world.baseURL = "/share/test/"
+ host := httptest.NewServer(adminTestHandler(world))
+ defer host.Close()
+ _, source, _, _ := runtime.Caller(0)
+ root := filepath.Dir(filepath.Dir(source))
+ ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
+ defer cancel()
+ command := exec.CommandContext(ctx, "node", filepath.Join(root, "tools/client/test_item_sources.mjs"), host.URL+world.baseURL)
+ command.Dir = root
+
+ output, err := command.CombinedOutput()
+
+ if err != nil {
+ t.Fatalf("%v\n%s", err, output)
+ }
+ t.Log(string(output))
+}
diff --git a/server/map_test.js b/server/map_test.js
@@ -18,6 +18,7 @@ function mapWithTiles(tileSize, count, fetch) {
'[data-map-status]': {}, '[data-map-location]': {}, '[data-map-view]': {value: '950'},
};
const map = new MapClass({dataset: {character: '1'}, querySelector: selector => elements[selector] || null});
+ map.view = '950';
map.width = tileSize;
map.height = tileSize;
map.scale = 1;
@@ -75,7 +76,7 @@ test('finding a zone focuses its boundary within the world map', () => {
map.focusZone(zone);
- assert.equal(map.view.value, 'world');
+ assert.equal(map.view, 'world');
assert.deepEqual(Array.from(map.center), [1300, 2500]);
assert.equal(map.scale, 0.5625);
assert.equal(map.selection, null);
@@ -250,14 +251,14 @@ test('acquisition locations focus outdoor and interior coordinates and label tap
map.sources = [{name: 'Shop: Supplies', playfield: 705, position: [100, 0, 200]}];
map.focusSource(map.sources[0]);
- assert.equal(map.view.value, 'world');
+ assert.equal(map.view, 'world');
assert.deepEqual(Array.from(map.center), [1100, 2200]);
map.pick(500, 500);
assert.match(map.location.textContent, /Shop: Supplies/);
assert.equal(map.selection, null);
map.focusSource({name: 'Shop: Armor', playfield: 1183, position: [180, 5, 135]});
- assert.equal(map.view.value, '1183');
+ assert.equal(map.view, '1183');
assert.deepEqual(Array.from(map.center), [180, 135]);
assert.equal(map.initialized, true);
});
diff --git a/tools/client/test_item_sources.mjs b/tools/client/test_item_sources.mjs
@@ -0,0 +1,57 @@
+import assert from 'node:assert/strict';
+import {createRequire} from 'node:module';
+
+const {chromium} = createRequire(import.meta.url)('playwright');
+const url = process.argv[2];
+const browser = await chromium.launch({executablePath: '/usr/bin/chromium', args: ['--no-sandbox']});
+try {
+ const page = await browser.newPage();
+ const errors = [];
+ const liveFeeds = [];
+ page.on('pageerror', error => errors.push(error.message));
+ page.on('request', request => {
+ if (/admin\/map-(players|entities)/.test(request.url())) liveFeeds.push(request.url());
+ });
+
+ for (const path of ['admin/items/catalog/95577', 'admin/shops/99491']) {
+ await page.goto(url + path);
+ await page.waitForFunction(() => document.querySelector('[data-map-status]').textContent.startsWith('Drag to pan.'));
+ const sources = JSON.parse(await page.locator('[data-item-sources]').textContent());
+ const trade = sources.findIndex(source => source.playfield === 705 && source.name.includes('entrance'));
+ const other = sources.findIndex(source => source.playfield !== 705 && source.name.includes('entrance'));
+ assert(trade >= 0 && other >= 0, 'shared shop interiors must list entrances in multiple cities');
+
+ for (const index of [other, trade]) {
+ await page.locator(`[data-map-source='${index}']`).click();
+
+ const source = sources[index];
+ await page.waitForFunction(({name, playfield, position}) => {
+ const label = document.querySelector('[data-map-location]').textContent;
+ return label.startsWith(name) && label.includes(`(${playfield}), X ${position[0].toFixed(1)}, Z ${position[2].toFixed(1)}.`);
+ }, source);
+ // The selected entrance must render at the canvas center, not just update its label.
+ await page.waitForFunction(() => {
+ const canvas = document.querySelector('canvas');
+ const pixel = canvas.getContext('2d').getImageData(canvas.width / 2, canvas.height / 2, 1, 1).data;
+ return pixel[0] === 33 && pixel[1] === 219 && pixel[2] === 135;
+ });
+ assert.equal(page.url(), url + path);
+ }
+ assert.equal(await page.locator('[data-world-map] select, [data-world-map] button, [data-world-map] input').count(), 0);
+ assert.equal(await page.locator('[data-map-source]').count(), sources.length);
+ }
+ assert.deepEqual(liveFeeds, []);
+ assert.deepEqual(errors, []);
+
+ // General map controls still select and render standalone outdoor playfields.
+ await page.goto(url + 'admin/map');
+ await page.locator('[data-map-view] option[value="950"]').waitFor({state: 'attached'});
+ await page.locator('[data-map-view]').selectOption('950');
+ await page.waitForRequest(request => request.url().includes('admin/map-entities?view=950&'));
+ await page.locator('[data-map-find]').selectOption('705');
+ await page.waitForFunction(() => document.querySelector('[data-map-view]').value === 'world');
+ assert.deepEqual(errors, []);
+ console.log('Acquisition links focus shared shop entrances without map controls or live feeds; general map controls still work.');
+} finally {
+ await browser.close();
+}