Skip to content

Commit

Permalink
Merge branch 'names' into 0.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
charredUtensil committed Aug 12, 2024
2 parents e6681b6 + dfd32dd commit 546940f
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 39 deletions.
6 changes: 6 additions & 0 deletions src/core/lore/graphs/completeness.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
FOUND_LOST_MINERS,
FOUND_SLUG_NEST,
} from "./events";
import { NAME } from "./names";
import ORDERS from "./orders";
import PREMISE from "./premise";
import { SEISMIC_FORESHADOW } from "./seismic";
Expand Down Expand Up @@ -61,9 +62,14 @@ const EXPECTED = phraseGraph<State>(({ pg, state, start, end, cut, skip }) => {
state("resourceObjective"),
),
)
.then(state('rockBiome', 'iceBiome', 'lavaBiome'))
.then(end);
});

test(`Name is complete`, () => {
expectCompletion(NAME, EXPECTED);
})

test(`Premise is complete`, () => {
expectCompletion(PREMISE, EXPECTED);
});
Expand Down
266 changes: 266 additions & 0 deletions src/core/lore/graphs/names.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
import phraseGraph from "../builder";
import { State } from "../lore";

export const NAME = phraseGraph<State>(
({ pg, state, start, end, cut, skip }) => {
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,
)
.then(skip, ...(mid || []))
.then(...last)
.then(end);
}

f({
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',
],
});

f({
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',
],
});

f({
rock: [
'Emerald',
'Evaporite',
],
lava: [
'Ember',
],
last: [
'Enigma',
'Eruption',
'Excavation',
'Express',
],
});

f({
rock: [
'Fault Line',
'Fissure',
'Flint',
],
ice: [
'Frostbite',
'Frosty',
],
last: [
'Folly',
'Frenzy',
'Fury',
],
});

f({
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',
],
});

f({
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',
],
});

f({
rock: [
'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',
],
});
},
);
9 changes: 9 additions & 0 deletions src/core/lore/lore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
FOUND_SLUG_NEST,
NOMADS_SETTLED,
} from "./graphs/events";
import { NAME } from "./graphs/names";
import ORDERS from "./graphs/orders";
import PREMISE from "./graphs/premise";
import { SEISMIC_FORESHADOW } from "./graphs/seismic";
Expand All @@ -35,6 +36,9 @@ export type State = {
readonly hqIsRuin: boolean;
readonly treasureCaveOne: boolean;
readonly treasureCaveMany: boolean;
readonly rockBiome: boolean;
readonly iceBiome: boolean;
readonly lavaBiome: boolean;
};

export type FoundLostMinersState = State & {
Expand All @@ -60,6 +64,7 @@ enum Die {
foundAllLostMiners,
nomadsSettled,
foundSlugNest,
name,
}

function floodedWith(cavern: AdjuredCavern): FluidType {
Expand Down Expand Up @@ -207,6 +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',
};

const enemies = filterTruthy([
Expand All @@ -229,6 +237,7 @@ export class Lore {

briefings(dice: DiceBox) {
return {
name: NAME.generate(dice.lore(Die.name), this.state, this.vars),
premise: PREMISE.generate(dice.lore(Die.premise), this.state, this.vars),
orders: ORDERS.generate(dice.lore(Die.orders), this.state, this.vars),
success: SUCCESS.generate(
Expand Down
10 changes: 7 additions & 3 deletions src/core/transformers/04_ephemera/02_enscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Lore } from "../../lore/lore";
import { AdjuredCavern } from "./01_adjure";

export type EnscribedCavern = AdjuredCavern & {
fileName: string;
lore: Lore;
levelName: string;
briefing: {
Expand All @@ -12,7 +13,7 @@ export type EnscribedCavern = AdjuredCavern & {
};

export default function enscribe(cavern: AdjuredCavern): EnscribedCavern {
const levelName = (() => {
const fileName = (() => {
const seed = cavern.context.seed.toString(16).padStart(8, "0");
return [
"gh",
Expand All @@ -27,11 +28,14 @@ export default function enscribe(cavern: AdjuredCavern): EnscribedCavern {
})();

const lore = new Lore(cavern);
const { premise, orders, success, failure } = lore.briefings(cavern.dice);
const { name, premise, orders, success, failure } = lore.briefings(
cavern.dice,
);
const levelName = name.text;
const briefing = {
intro: `${premise.text}\n\n${orders.text}`,
success: success.text,
failure: failure.text,
};
return { ...cavern, lore, levelName, briefing };
return { ...cavern, fileName, lore, levelName, briefing };
}
13 changes: 3 additions & 10 deletions src/webui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,8 @@ function App() {
/>
)}
{mapOverlay === "about" && <About />}
{mapOverlay === "lore" && (
<LorePreview
briefing={state.cavern?.briefing}
script={state.cavern?.script}
/>
)}
{state.error && (
<ErrorPreview error={state.error} context={state.cavern?.context} />
)}
{mapOverlay === "lore" && <LorePreview {...state.cavern} />}
{state.error && <ErrorPreview error={state.error} context={state.cavern?.context} />}
{!autoGenerate && state.name && (
<div className={styles.stepName}>{state.name}</div>
)}
Expand All @@ -183,7 +176,7 @@ function App() {
<a
className={styles.button}
href={getDownloadLink(state.cavern.serialized)}
download={`${state.cavern.levelName ?? "groundhog"}.dat`}
download={`${state.cavern.fileName ?? state.cavern.levelName ?? "groundhog"}.dat`}
>
download
</a>
Expand Down
Loading

0 comments on commit 546940f

Please sign in to comment.