Mapwright v0.5.0 — procedural battle map generator for Foundry VTT
Buildings (modern/fantasy, multi-floor, footprint shapes), caves, outdoor biomes, and town/village + city-block settlements. Auto-places Foundry walls, doors, windows, lighting; furniture as locked tiles; live preview. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/** Dev harness — building engine + furniture placement. node dev/render-sample.mjs */
|
||||
import { writeFileSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
import { Rng } from "../module/lib/rng.mjs";
|
||||
import { generateBuilding } from "../module/lib/building.mjs";
|
||||
import { buildWalls } from "../module/lib/walls.mjs";
|
||||
import { computePlacements } from "../module/lib/furniture-layout.mjs";
|
||||
import { renderSVG } from "../module/lib/render-vector.mjs";
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const SAMPLES = [
|
||||
{ name: "modern-rect", subtype: "modern", shape: "rectangle", cols: 26, rows: 18, targetRooms: 11, seed: "office-7" },
|
||||
{ name: "fantasy-u", subtype: "fantasy", shape: "u", cols: 28, rows: 22, targetRooms: 12, seed: "keep-3" },
|
||||
{ name: "modern-plus", subtype: "modern", shape: "plus", cols: 30, rows: 24, targetRooms: 14, seed: "hub-2" }
|
||||
];
|
||||
|
||||
for (const cfg of SAMPLES) {
|
||||
const layout = generateBuilding(cfg);
|
||||
const walls = buildWalls(layout, { rng: new Rng(`${cfg.seed}::walls`) });
|
||||
const placements = computePlacements(layout, walls, 70, cfg.subtype, cfg.seed);
|
||||
const svg = renderSVG({ layout, walls, gridSize: 70, subtype: cfg.subtype, seed: cfg.seed, placements, showFurniture: true });
|
||||
console.log(`${cfg.name.padEnd(14)} rooms:${layout.rooms.length} furniture:${placements.length} doors:${walls.doors.length}`);
|
||||
writeFileSync(join(here, `${cfg.name}.svg`), svg);
|
||||
}
|
||||
console.log("\nWrote building samples to", here);
|
||||
Reference in New Issue
Block a user