From 7b5a212e21561ea6ce3b5ec3ff92a09ff538a30f Mon Sep 17 00:00:00 2001 From: charredUtensil Date: Tue, 13 Aug 2024 09:12:26 -0400 Subject: [PATCH] prettier --- src/core/architects/established_hq.ts | 2 +- src/core/architects/lost_miners.ts | 3 +- src/core/architects/utils/script.ts | 2 + src/core/lore/graphs/completeness.test.ts | 6 +- src/core/lore/graphs/names.ts | 283 +++++------------- src/core/lore/lore.ts | 6 +- .../transformers/04_ephemera/04_serialize.ts | 8 +- src/webui/App.tsx | 4 +- src/webui/components/context_editor/index.tsx | 4 +- src/webui/components/map_preview/stats.tsx | 4 +- src/webui/components/popovers/lore.tsx | 19 +- .../components/popovers/styles.module.scss | 2 +- 12 files changed, 108 insertions(+), 235 deletions(-) diff --git a/src/core/architects/established_hq.ts b/src/core/architects/established_hq.ts index e0f794d..56a143b 100644 --- a/src/core/architects/established_hq.ts +++ b/src/core/architects/established_hq.ts @@ -333,4 +333,4 @@ export const ESTABLISHED_HQ = [ }, ] as const satisfies readonly Architect[]; -export default ESTABLISHED_HQ; \ No newline at end of file +export default ESTABLISHED_HQ; diff --git a/src/core/architects/lost_miners.ts b/src/core/architects/lost_miners.ts index 80b3958..e8d8d0d 100644 --- a/src/core/architects/lost_miners.ts +++ b/src/core/architects/lost_miners.ts @@ -209,7 +209,8 @@ const BASE: PartialArchitect = { const message = cavern.lore.foundAllLostMiners(cavern.dice).text; return scriptFragment( `# Globals: Lost Miners`, - lostMinerCaves > 1 && `int ${gLostMiners.remainingCaves}=${lostMinerCaves}`, + lostMinerCaves > 1 && + `int ${gLostMiners.remainingCaves}=${lostMinerCaves}`, `int ${gLostMiners.done}=0`, `string ${gLostMiners.messageFoundAll}="${escapeString(message)}"`, eventChain( diff --git a/src/core/architects/utils/script.ts b/src/core/architects/utils/script.ts index cb3284c..b8816a0 100644 --- a/src/core/architects/utils/script.ts +++ b/src/core/architects/utils/script.ts @@ -34,3 +34,5 @@ export function eventChain(name: string, ...rest: (`${string};` | Falsy)[]) { export function escapeString(s: string) { return s.replace(/\\/g, "").replace(/"/g, '\\"'); } + +export class ScriptBuilder {} diff --git a/src/core/lore/graphs/completeness.test.ts b/src/core/lore/graphs/completeness.test.ts index 750d7f9..1bd90ce 100644 --- a/src/core/lore/graphs/completeness.test.ts +++ b/src/core/lore/graphs/completeness.test.ts @@ -49,7 +49,7 @@ const EXPECTED = phraseGraph(({ pg, state, start, end, cut, skip }) => { .then(skip, state("spawnHasErosion")) .then(skip, state("treasureCaveOne", "treasureCaveMany")) .then( - skip, + skip, state("spawnIsNomadOne", "spawnIsNomadsTogether"), state("spawnIsHq").then(hasHq).then(cut), ) @@ -62,13 +62,13 @@ const EXPECTED = phraseGraph(({ pg, state, start, end, cut, skip }) => { state("resourceObjective"), ), ) - .then(state('rockBiome', 'iceBiome', 'lavaBiome')) + .then(state("rockBiome", "iceBiome", "lavaBiome")) .then(end); }); test(`Name is complete`, () => { expectCompletion(NAME, EXPECTED); -}) +}); test(`Premise is complete`, () => { expectCompletion(PREMISE, EXPECTED); diff --git a/src/core/lore/graphs/names.ts b/src/core/lore/graphs/names.ts index 4649852..619ffb1 100644 --- a/src/core/lore/graphs/names.ts +++ b/src/core/lore/graphs/names.ts @@ -3,12 +3,24 @@ import { State } from "../lore"; export const NAME = phraseGraph( ({ pg, state, start, end, cut, skip }) => { - function f({rock, ice, lava, mid, last}: {rock: string[], ice?: string[], lava?: string[], mid?: string[], last: string[]}) { + function f({ + rock, + ice, + lava, + mid, + last, + }: { + rock: string[]; + ice?: string[]; + lava?: string[]; + mid?: string[]; + last: string[]; + }) { start .then( - state('rockBiome').then(...rock), - ice ? state('iceBiome').then(...ice) : cut, - lava ? state('lavaBiome').then(...lava) : cut, + state("rockBiome").then(...rock), + ice ? state("iceBiome").then(...ice) : cut, + lava ? state("lavaBiome").then(...lava) : cut, ) .then(skip, ...(mid || [])) .then(...last) @@ -16,251 +28,90 @@ export const NAME = phraseGraph( } f({ - rock: [ - 'Andesite', - 'Anthracite', - 'Argillite', - ], - ice: [ - 'Arctic', - 'Avalanche', - ], - lava: [ - 'Asbestos', - 'Ashen', - ], - last: [ - 'Abyss', - 'Action', - 'Alley', - 'Attack', - ], + rock: ["Andesite", "Anthracite", "Argillite"], + ice: ["Arctic", "Avalanche"], + lava: ["Asbestos", "Ashen"], + last: ["Abyss", "Action", "Alley", "Attack"], }); f({ - rock: [ - 'Basalt', - 'Basanite', - 'Bauxite', - 'Boulder', - 'Breccia', - 'Bullion', - ], - ice: [ - 'Blizzard', - ], - last: [ - 'Balance', - 'Blitz', - 'Breach', - 'Break', - 'Bonanza', - 'Burrow', - ], + rock: ["Basalt", "Basanite", "Bauxite", "Boulder", "Breccia", "Bullion"], + ice: ["Blizzard"], + last: ["Balance", "Blitz", "Breach", "Break", "Bonanza", "Burrow"], }); f({ - rock: [ - 'Chalk', - 'Claystone', - 'Core', - 'Crystal', - ], - lava: [ - 'Caldera', - 'Cinder', - ], - last: [ - 'Calamity', - 'Caper', - 'Cavern', - 'Chaos', - 'Conflict', - 'Conundrum', - ], + rock: ["Chalk", "Claystone", "Core", "Crystal"], + lava: ["Caldera", "Cinder"], + last: ["Calamity", "Caper", "Cavern", "Chaos", "Conflict", "Conundrum"], }); f({ - rock: [ - 'Diamond', - 'Diorite', - 'Dolomite', - 'Dunite', - ], - ice: [ - 'Drift', - ], - last: [ - 'Depths', - 'Dash', - 'Descent', - 'Despair', - 'Drive', - ], + rock: ["Diamond", "Diorite", "Dolomite", "Dunite"], + ice: ["Drift"], + last: ["Depths", "Dash", "Descent", "Despair", "Drive"], }); f({ - rock: [ - 'Emerald', - 'Evaporite', - ], - lava: [ - 'Ember', - ], - last: [ - 'Enigma', - 'Eruption', - 'Excavation', - 'Express', - ], + rock: ["Emerald", "Evaporite"], + lava: ["Ember"], + last: ["Enigma", "Eruption", "Excavation", "Express"], }); f({ - rock: [ - 'Fault Line', - 'Fissure', - 'Flint', - ], - ice: [ - 'Frostbite', - 'Frosty', - ], - last: [ - 'Folly', - 'Frenzy', - 'Fury', - ], + rock: ["Fault Line", "Fissure", "Flint"], + ice: ["Frostbite", "Frosty"], + last: ["Folly", "Frenzy", "Fury"], }); f({ - rock: [ - 'Gneiss', - 'Granite', - 'Gritstone', - 'Gypsum', - ], - ice: [ - 'Glacier', - ], - last: [ - 'Gauntlet', - 'Getaway', - ], + rock: ["Gneiss", "Granite", "Gritstone", "Gypsum"], + ice: ["Glacier"], + last: ["Gauntlet", "Getaway"], }); f({ - rock: [ - 'Lapis Lazuli', - 'Laterite', - 'Lignite', - 'Limestone', - ], - lava: [ - 'Lava', - 'Lava Lake', - ], - last: [ - 'Labyrinth', - 'Lair', - 'Lure', - ], + rock: ["Lapis Lazuli", "Laterite", "Lignite", "Limestone"], + lava: ["Lava", "Lava Lake"], + last: ["Labyrinth", "Lair", "Lure"], }); f({ - rock: [ - 'Marble', - 'Metamorphic', - 'Mineral', - 'Mudstone', - ], - ice: [ - 'Mammoth', - ], - lava: [ - 'Magma', - 'Mantle', - 'Molten', - ], - mid: [ - 'Mine', - 'Moon', - ], - last: [ - 'Mayhem', - 'Maze', - 'Meltdown', - 'Menace', - 'Mishap', - ], + rock: ["Marble", "Metamorphic", "Mineral", "Mudstone"], + ice: ["Mammoth"], + lava: ["Magma", "Mantle", "Molten"], + mid: ["Mine", "Moon"], + last: ["Mayhem", "Maze", "Meltdown", "Menace", "Mishap"], }); f({ - rock: [ - 'Phosphorite', - 'Pumice', - ], - ice: [ - 'Permafrost', - 'Polar', - ], - lava: [ - 'Pyroclastic', - 'Pyrolite', - ], - last: [ - 'Passage', - 'Peril', - 'Pit', - 'Plunge', - 'Puzzle', - ], + rock: ["Phosphorite", "Pumice"], + ice: ["Permafrost", "Polar"], + lava: ["Pyroclastic", "Pyrolite"], + last: ["Passage", "Peril", "Pit", "Plunge", "Puzzle"], }); f({ rock: [ - 'Sandstone', - 'Schist', - 'Sedimentary', - 'Shale', - 'Silica', - 'Silt', - 'Slate', - 'Stalactite', - ], - ice: [ - 'Snowdrift', - 'Subzero', - ], - mid: [ - 'Shaft', - ], - last: [ - 'Scramble', - 'Shock', - 'Showdown', - 'Slide', - ], + "Sandstone", + "Schist", + "Sedimentary", + "Shale", + "Silica", + "Silt", + "Slate", + "Stalactite", + ], + ice: ["Snowdrift", "Subzero"], + mid: ["Shaft"], + last: ["Scramble", "Shock", "Showdown", "Slide"], }); f({ - rock: [ - 'Tuff', - 'Turbidite', - 'Twilight', - ], - ice: [ - 'Taiga', - 'Titanic', - 'Tundra', - ], - mid: [ - 'Tunnel', - ], - last: [ - 'Tempest', - 'Terror', - 'Trouble', - ], + rock: ["Tuff", "Turbidite", "Twilight"], + ice: ["Taiga", "Titanic", "Tundra"], + mid: ["Tunnel"], + last: ["Tempest", "Terror", "Trouble"], }); }, -); \ No newline at end of file +); diff --git a/src/core/lore/lore.ts b/src/core/lore/lore.ts index e29dde2..40d08a1 100644 --- a/src/core/lore/lore.ts +++ b/src/core/lore/lore.ts @@ -212,9 +212,9 @@ export class Lore { spawnIsNomadsTogether: nomads > 1, treasureCaveOne: treasures === 1, treasureCaveMany: treasures > 1, - rockBiome: cavern.context.biome === 'rock', - iceBiome: cavern.context.biome === 'ice', - lavaBiome: cavern.context.biome === 'lava', + rockBiome: cavern.context.biome === "rock", + iceBiome: cavern.context.biome === "ice", + lavaBiome: cavern.context.biome === "lava", }; const enemies = filterTruthy([ diff --git a/src/core/transformers/04_ephemera/04_serialize.ts b/src/core/transformers/04_ephemera/04_serialize.ts index 57edf55..7514c75 100644 --- a/src/core/transformers/04_ephemera/04_serialize.ts +++ b/src/core/transformers/04_ephemera/04_serialize.ts @@ -35,12 +35,12 @@ context = ${JSON.stringify(cavern.context, null, 2)}`; * Coordinate data for anything that uses 'x,y/' or 'y,x/' format. * Unfortunately, MM is inconsistent and uses both. */ -function pointSet(points: Point[], [ox, oy]: Point, mode: 'xy' | 'yx'): string { +function pointSet(points: Point[], [ox, oy]: Point, mode: "xy" | "yx"): string { return points .map(([x, y]) => { const xs = (x + ox).toFixed(); const ys = (y + oy).toFixed(); - return mode === 'xy' ? `${xs},${ys}/` : `${ys},${xs}/`; + return mode === "xy" ? `${xs},${ys}/` : `${ys},${xs}/`; }) .join(); } @@ -76,7 +76,7 @@ export function serializeHazards( }); return Array.from(out.entries()) .sort(([a], [b]) => parseInt(b) - parseInt(a)) - .map(([key, points]) => `${key}:${pointSet(points, offset, 'xy')}`) + .map(([key, points]) => `${key}:${pointSet(points, offset, "xy")}`) .join("\n"); } @@ -108,7 +108,7 @@ levelname:${cavern.levelName} opencaves:${pointSet( cavern.openCaveFlags.map((_, x, y) => [x, y]), offset, - 'yx', + "yx", )} ${cavern.oxygen ? `oxygen:${cavern.oxygen.join("/")}` : ""} spiderrate:10 diff --git a/src/webui/App.tsx b/src/webui/App.tsx index ae7f46b..8602919 100644 --- a/src/webui/App.tsx +++ b/src/webui/App.tsx @@ -157,7 +157,9 @@ function App() { )} {mapOverlay === "about" && } {mapOverlay === "lore" && } - {state.error && } + {state.error && ( + + )} {!autoGenerate && state.name && (
{state.name}
)} diff --git a/src/webui/components/context_editor/index.tsx b/src/webui/components/context_editor/index.tsx index e077285..69fa74b 100644 --- a/src/webui/components/context_editor/index.tsx +++ b/src/webui/components/context_editor/index.tsx @@ -15,7 +15,9 @@ function parseSeed(v: string) { function unparseSeed(v: number, split: boolean) { const s = v.toString(16).padStart(8, "0").toUpperCase(); - return split ? `${s.substring(0, 3)} ${s.substring(3, 6)} ${s.substring(6)}` : s; + return split + ? `${s.substring(0, 3)} ${s.substring(3, 6)} ${s.substring(6)}` + : s; } const expectedTotalPlans = (contextWithDefaults: CavernContext) => { diff --git a/src/webui/components/map_preview/stats.tsx b/src/webui/components/map_preview/stats.tsx index 0b655d0..7430f72 100644 --- a/src/webui/components/map_preview/stats.tsx +++ b/src/webui/components/map_preview/stats.tsx @@ -45,7 +45,9 @@ export default function Stats({ return ( <> {cavern.levelName && ( -

{cavern.fileName} {cavern.levelName}

+

+ {cavern.fileName} {cavern.levelName} +

)} {cavern.briefing?.intro && (

{cavern.briefing.intro.replace(/\n/g, "\u00B6")}

diff --git a/src/webui/components/popovers/lore.tsx b/src/webui/components/popovers/lore.tsx index 5b49289..989dcc1 100644 --- a/src/webui/components/popovers/lore.tsx +++ b/src/webui/components/popovers/lore.tsx @@ -5,15 +5,28 @@ import { Cavern } from "../../../core/models/cavern"; const disp = (value: string | undefined) => value?.split("\n").flatMap((s, i) => (i > 0 ? [
, s] : [s])); -export default function LorePreview({ fileName, levelName, briefing, script }: Pick) { - const scriptStrings = script?.split('\n').map(s => s.match(/^string\s+(?[a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*"(?.*)"$/)); +export default function LorePreview({ + fileName, + levelName, + briefing, + script, +}: Pick) { + const scriptStrings = script + ?.split("\n") + .map((s) => + s.match( + /^string\s+(?[a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*"(?.*)"$/, + ), + ); if (!(briefing || script)) { return null; } return (
-

{levelName} {fileName}

+

+ {levelName} {fileName} +

Briefing

Introduction

{disp(briefing?.intro)}

diff --git a/src/webui/components/popovers/styles.module.scss b/src/webui/components/popovers/styles.module.scss index 6a57b0a..0bf260f 100644 --- a/src/webui/components/popovers/styles.module.scss +++ b/src/webui/components/popovers/styles.module.scss @@ -24,7 +24,7 @@ p { margin: 4px 0; } - + h1, h2, h3,