Layer-1 CityPlan generator per CITY_SPEC schema v1 — pure data, no THREE, all randomness
through core/prng, deterministic + JSON-serializable + <1ms.
- web/js/citygen/plan.js: generatePlan(citySeed) → CityPlan (spine, cross-streets, market
square + dept anchor, arcade, warehouse fringe, residential collar w/ corner milkbars,
laneways) + chunkIndex (Amanatides–Woo edge supercover) + corner overlap-resolution pass.
- web/js/core/registry.js: SHOP_TYPES (all 9) + district weights + enums (shared vocabulary).
- web/js/citygen/names.js + wordlists.js: seeded 90s-AU shop/town names, 50+ patterns.
- web/js/citygen/index.js: canonical barrel entry (adopts Lane F's integration shim).
- web/map.html: standalone Canvas-2D plan debugger (pan/zoom/hover, layers, export JSON).
- web/js/citygen/selfcheck.js: node acceptance harness — determinism, golden fingerprint,
facing, within- AND cross-block no-overlap, chunk+edge coverage, finiteness, assets. ALL GREEN
(1271/1271) over 6 seeds. web/package.json ({"type":"module"}) lets node run it.
- docs/shots/laneA/: 5 seeds screenshotted, each reads as a town.
Fixes from an adversarial multi-agent review (15 confirmed defects): market facades faced the
wrong way; cross-block corner overlaps; chunkIndex skipped chunks incl. the origin/spine;
stall frontEdge z-band; doubled-possessive names; unparseable map road colour; +others.
CITY_SPEC amendment (treaty, same commit): shop-types table aligned to the registry lanes
import; documented lot.ry/frontEdge, block.kind/district-id, and web/package.json.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
155 lines
7.2 KiB
JavaScript
155 lines
7.2 KiB
JavaScript
// PROCITY shop-type registry — the shared vocabulary (CITY_SPEC §"Shop types v1").
|
|
// Lane A owns this file; EVERY other lane imports it read-only. Keep it flat data:
|
|
// no THREE, no prng, no side effects — just tables + tiny pure helpers.
|
|
//
|
|
// Facade filenames here MUST exist in web/assets/gen/ (Lane A selfcheck asserts this).
|
|
|
|
// ── enumerations (single source of truth for the CityPlan schema strings) ──────────
|
|
export const DISTRICT_KINDS = ['mainstreet', 'arcade', 'backstreets', 'warehouse', 'residential', 'market'];
|
|
export const EDGE_KINDS = ['main', 'side', 'lane', 'arcade'];
|
|
export const USE_KINDS = ['shop', 'anchor', 'house', 'yard', 'stall', 'infill'];
|
|
export const SHOP_TYPE_IDS = ['record', 'opshop', 'toy', 'book', 'video', 'pawn', 'milkbar', 'dept', 'stall'];
|
|
|
|
// ── the registry ──────────────────────────────────────────────────────────────────
|
|
// Per type:
|
|
// label human name (map legend / debug)
|
|
// facades facade-*.jpg skins in web/assets/gen/ (blank signboards; game overlays the name)
|
|
// sign colour/style hints for Lane B's canvas signage
|
|
// interior archetype id Lane C builds the room from
|
|
// fittings parametric fitting kit ids (90sDJsim fittings.js) Lane C fills the room with
|
|
// storeys [min,max] inclusive
|
|
// hours {open,close} default trading hours (24h); plan.js jitters + picks one weirdo
|
|
// weights district-kind -> spawn weight (0/absent = never in that district)
|
|
// footprint {fmin,fmax,dmin,dmax} preferred frontage/depth band in metres (plan.js hint)
|
|
export const SHOP_TYPES = {
|
|
record: {
|
|
label: 'Record Shop',
|
|
facades: ['facade-timber-teal.jpg', 'facade-arcade-tile.jpg', 'facade-djsim-record.jpg'],
|
|
sign: { bg: '#141428', fg: '#ff5470', accent: '#ffd23f', style: 'neon' },
|
|
interior: 'crates_and_bins',
|
|
fittings: ['record_bins', 'crates', 'counter', 'listening_corner'],
|
|
storeys: [1, 2],
|
|
hours: { open: 10, close: 18 },
|
|
weights: { mainstreet: 3, arcade: 4, backstreets: 1 },
|
|
footprint: { fmin: 6, fmax: 9, dmin: 12, dmax: 18 },
|
|
},
|
|
opshop: {
|
|
label: 'Op Shop',
|
|
facades: ['facade-weatherboard.jpg', 'facade-fibro-blue.jpg', 'facade-djsim-opshop.jpg'],
|
|
sign: { bg: '#3d6b4a', fg: '#f6efdc', accent: '#e4573a', style: 'painted' },
|
|
interior: 'racks_and_shelves',
|
|
fittings: ['clothes_racks', 'bricabrac_shelving', 'book_wall', 'counter'],
|
|
storeys: [1, 2],
|
|
hours: { open: 9, close: 17 },
|
|
weights: { mainstreet: 3, arcade: 1, backstreets: 2 },
|
|
footprint: { fmin: 7, fmax: 10, dmin: 12, dmax: 20 },
|
|
},
|
|
toy: {
|
|
label: 'Toy Shop',
|
|
facades: ['facade-stucco-pink.jpg', 'facade-deco-pastel.jpg', 'facade-boutique.jpg'],
|
|
sign: { bg: '#ffd23f', fg: '#d6336c', accent: '#2f9e44', style: 'bubbly' },
|
|
interior: 'shelves_and_case',
|
|
fittings: ['cube_shelves', 'display_tables', 'glass_case', 'counter'],
|
|
storeys: [1, 2],
|
|
hours: { open: 9, close: 17 },
|
|
weights: { mainstreet: 2, arcade: 2, backstreets: 1 },
|
|
footprint: { fmin: 6, fmax: 9, dmin: 12, dmax: 18 },
|
|
},
|
|
book: {
|
|
label: 'Book Barn',
|
|
facades: ['facade-federation.jpg', 'facade-sandstone.jpg', 'facade-redbrick.jpg'],
|
|
sign: { bg: '#2b3a2e', fg: '#e9d8a6', accent: '#bb7a3b', style: 'serif' },
|
|
interior: 'halls_of_shelves',
|
|
fittings: ['bookshelves', 'spinner_racks', 'armchair', 'counter'],
|
|
storeys: [1, 2],
|
|
hours: { open: 9, close: 17 },
|
|
weights: { mainstreet: 2, arcade: 2, backstreets: 1 },
|
|
footprint: { fmin: 7, fmax: 10, dmin: 14, dmax: 20 },
|
|
},
|
|
video: {
|
|
label: 'Video Rental',
|
|
facades: ['facade-stripmall.jpg', 'facade-djsim-video.jpg'],
|
|
sign: { bg: '#111111', fg: '#ffe14d', accent: '#e8412b', style: 'blocky' },
|
|
interior: 'aisle_shelves',
|
|
fittings: ['vhs_shelving', 'returns_slot', 'poster_wall', 'counter'],
|
|
storeys: [1, 1],
|
|
hours: { open: 11, close: 21 }, // rentals trade late
|
|
weights: { mainstreet: 2, arcade: 0, backstreets: 1 },
|
|
footprint: { fmin: 7, fmax: 10, dmin: 14, dmax: 20 },
|
|
},
|
|
pawn: {
|
|
label: 'Pawnbroker',
|
|
facades: ['facade-besser.jpg', 'facade-grimy.jpg', 'facade-djsim-pawn.jpg', 'facade-corrugated.jpg'],
|
|
sign: { bg: '#1c1c1c', fg: '#f4c430', accent: '#a8a8a8', style: 'goldbar' },
|
|
interior: 'counter_forward',
|
|
fittings: ['glass_cabinets', 'wall_hooks', 'barred_window', 'counter'],
|
|
storeys: [1, 2],
|
|
hours: { open: 9, close: 17 },
|
|
weights: { mainstreet: 1, backstreets: 2, warehouse: 1 },
|
|
footprint: { fmin: 6, fmax: 9, dmin: 12, dmax: 18 },
|
|
},
|
|
milkbar: {
|
|
label: 'Milk Bar',
|
|
facades: ['facade-djsim-milkbar.jpg', 'facade-brickveneer.jpg'],
|
|
sign: { bg: '#c92a2a', fg: '#fff5f5', accent: '#ffd23f', style: 'coke' },
|
|
interior: 'counter_and_freezer',
|
|
fittings: ['counter', 'fridge', 'magazine_rack', 'freezer'],
|
|
storeys: [1, 1],
|
|
hours: { open: 6, close: 20 }, // the corner shop opens early, closes late
|
|
weights: { residential: 1 }, // only ever a residential corner shop
|
|
footprint: { fmin: 9, fmax: 12, dmin: 12, dmax: 16 },
|
|
},
|
|
dept: {
|
|
label: 'Department Store',
|
|
facades: ['facade-terrazzo.jpg', 'facade-djsim-dept.jpg'],
|
|
sign: { bg: '#7b1e3a', fg: '#f6e7c1', accent: '#c9a227', style: 'grand' },
|
|
interior: 'grand_hall',
|
|
fittings: ['mixed_sections', 'escalator_prop', 'glass_case', 'counter'],
|
|
storeys: [2, 3],
|
|
hours: { open: 9, close: 17 },
|
|
weights: { market: 1 }, // the anchor on the market square's edge
|
|
footprint: { fmin: 22, fmax: 34, dmin: 24, dmax: 34 },
|
|
},
|
|
stall: {
|
|
label: 'Market Stall',
|
|
facades: ['facade-market.jpg'],
|
|
sign: { bg: '#e8e2d0', fg: '#5c3b1e', accent: '#c0392b', style: 'handpainted' },
|
|
interior: 'open_stall',
|
|
fittings: ['trestle_tables', 'crates'],
|
|
storeys: [1, 1],
|
|
hours: { open: 8, close: 14 }, // market mornings
|
|
weights: { market: 1 },
|
|
footprint: { fmin: 3, fmax: 5, dmin: 3, dmax: 5 },
|
|
},
|
|
};
|
|
|
|
// ── pure helpers (no randomness — plan.js supplies the prng stream) ─────────────────
|
|
|
|
// Types that can spawn in a district, as a flat [{type,weight}] list (weight>0), stable order.
|
|
export function weightedTypes(districtKind) {
|
|
const out = [];
|
|
for (const type of SHOP_TYPE_IDS) {
|
|
const w = SHOP_TYPES[type].weights[districtKind] || 0;
|
|
if (w > 0) out.push({ type, weight: w });
|
|
}
|
|
return out;
|
|
}
|
|
|
|
// Sample one type by weight using a prng stream fn r()->[0,1). Returns null if none for district.
|
|
export function pickWeightedType(r, districtKind, exclude = null) {
|
|
let list = weightedTypes(districtKind);
|
|
if (exclude) { const f = list.filter(t => t.type !== exclude); if (f.length) list = f; }
|
|
if (!list.length) return null;
|
|
let total = 0; for (const t of list) total += t.weight;
|
|
let x = r() * total;
|
|
for (const t of list) { x -= t.weight; if (x < 0) return t.type; }
|
|
return list[list.length - 1].type;
|
|
}
|
|
|
|
// Every facade filename referenced anywhere (Lane A selfcheck asserts each exists on disk).
|
|
export function allFacadeSkins() {
|
|
const set = new Set();
|
|
for (const type of SHOP_TYPE_IDS) for (const f of SHOP_TYPES[type].facades) set.add(f);
|
|
return [...set];
|
|
}
|