@blkc-code/mapgen 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/plan.ts ADDED
@@ -0,0 +1,70 @@
1
+ /**
2
+ * What a world grows from a project: which special rooms it has, what goes in them, and what a
3
+ * folder's room looks like. The growing itself is the same for every world.
4
+ */
5
+
6
+ export type RoomRole = "lobby" | "lounge" | "quests" | "vacant" | "hall";
7
+
8
+ export interface Theme { floor: string; items: string[]; decor: string[] }
9
+
10
+ /** One furnishing step, run in order. `top` falls back to anywhere in the room; `center` doesn't. */
11
+ export type FurnishStep = { scatter: string } | { wall: string } | { place: string; at: "center" | "top" };
12
+
13
+ export interface WorldPlan {
14
+ id: string;
15
+ /** Footprint in tiles, and where someone stands to use it. */
16
+ footprint: Record<string, { w: number; h: number; spot?: [number, number]; solid?: boolean }>;
17
+ /** Always there. The first is where the map starts. */
18
+ specials: { id: string; name: string; role: RoomRole; floor: string; w: number; h: number }[];
19
+ furnishing: Partial<Record<RoomRole, FurnishStep[]>>;
20
+ /** What a folder's room is filled with, one for each few files. */
21
+ workstation: string;
22
+ /** Matched against a folder's own name. */
23
+ themes: { match: RegExp; theme: Theme }[];
24
+ fallback: Theme & { floors: string[] };
25
+ /** For the biggest rooms. */
26
+ filler: [string, string];
27
+ }
28
+
29
+ /** The office, and the world used when a map doesn't name one. */
30
+ export const OFFICE_PLAN: WorldPlan = {
31
+ id: "office",
32
+ footprint: {
33
+ desk: { w: 3, h: 2, spot: [1, 2] }, coffee: { w: 2, h: 1, spot: [0, 1] }, water: { w: 1, h: 1, spot: [0, 1] }, sofa: { w: 3, h: 1, spot: [1, 1] },
34
+ plant: { w: 1, h: 1 }, fern: { w: 1, h: 1 }, board: { w: 4, h: 1, spot: [1, 1] }, whiteboard: { w: 3, h: 1, spot: [1, 1] }, shelf: { w: 2, h: 1, spot: [0, 1] },
35
+ server: { w: 1, h: 1 }, table: { w: 3, h: 2, spot: [1, 2] }, rug: { w: 4, h: 3, solid: false }, printer: { w: 1, h: 1, spot: [0, 1] }, lamp: { w: 1, h: 1 },
36
+ beanbag: { w: 1, h: 1, spot: [0, 1] }, vending: { w: 1, h: 1, spot: [0, 1] }, fridge: { w: 1, h: 1, spot: [0, 1] }, arcade: { w: 1, h: 1, spot: [0, 1] },
37
+ },
38
+ specials: [
39
+ { id: "lobby", name: "Lobby", role: "lobby", floor: "stone", w: 9, h: 6 },
40
+ { id: "lounge", name: "Lounge", role: "lounge", floor: "carpet", w: 10, h: 6 },
41
+ { id: "quests", name: "Quests", role: "quests", floor: "tile", w: 9, h: 6 },
42
+ ],
43
+ furnishing: {
44
+ lobby: [{ place: "rug", at: "center" }, { scatter: "plant" }, { scatter: "fern" }, { scatter: "lamp" }, { wall: "clock" }, { wall: "poster" }],
45
+ lounge: [{ scatter: "coffee" }, { scatter: "water" }, { scatter: "sofa" }, { scatter: "fridge" }, { scatter: "plant" }, { scatter: "beanbag" }, { scatter: "lamp" }, { wall: "poster" }],
46
+ quests: [{ place: "board", at: "top" }, { scatter: "table" }, { scatter: "whiteboard" }, { scatter: "plant" }, { wall: "clock" }],
47
+ vacant: [{ scatter: "plant" }, { scatter: "shelf" }],
48
+ },
49
+ workstation: "desk",
50
+ themes: [
51
+ { match: /doc|guide|wiki|spec|readme|manual/, theme: { floor: "carpet", items: ["shelf", "shelf", "lamp"], decor: ["poster", "clock"] } },
52
+ { match: /test|spec|e2e|qa|fixture/, theme: { floor: "tile", items: ["whiteboard", "printer"], decor: ["clock", "poster"] } },
53
+ { match: /api|server|backend|service|worker|core|engine|kernel/, theme: { floor: "concrete", items: ["server", "server", "server", "printer"], decor: ["clock"] } },
54
+ { match: /db|data|migrat|schema|model|store|sql|supabase/, theme: { floor: "stone", items: ["server", "server", "shelf"], decor: ["clock"] } },
55
+ { match: /ui|web|front|client|component|page|view|style|site|app/, theme: { floor: "wood", items: ["fern", "lamp", "beanbag"], decor: ["poster", "poster"] } },
56
+ { match: /asset|public|image|media|static|font|icon/, theme: { floor: "grass", items: ["plant", "fern", "plant"], decor: [] } },
57
+ { match: /script|tool|ci|github|infra|deploy|ops|docker|bin/, theme: { floor: "stone", items: ["server", "printer", "whiteboard"], decor: ["clock"] } },
58
+ { match: /kit|block|circuit|plugin|ext|module|package/, theme: { floor: "carpet", items: ["whiteboard", "shelf"], decor: ["poster"] } },
59
+ ],
60
+ fallback: { floor: "", floors: ["wood", "carpet", "tile", "stone", "concrete"], items: ["plant", "shelf", "lamp"], decor: ["poster"] },
61
+ filler: ["plant", "fern"],
62
+ };
63
+
64
+ const plans = new Map<string, WorldPlan>([[OFFICE_PLAN.id, OFFICE_PLAN]]);
65
+
66
+ export function registerWorldPlan(plan: WorldPlan): void {
67
+ plans.set(plan.id, plan);
68
+ }
69
+
70
+ export const worldPlan = (id: string | undefined): WorldPlan => (id && plans.get(id)) || OFFICE_PLAN;