Skip to content

Commit

Permalink
run prettier (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
charredUtensil authored Jul 6, 2024
1 parent df8af66 commit 839a34c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 52 deletions.
24 changes: 14 additions & 10 deletions src/core/architects/utils/script.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { escapeString } from "./script";

describe('escapeString', () => {
it('handles the empty string', () => {
expect(escapeString('')).toBe('');
describe("escapeString", () => {
it("handles the empty string", () => {
expect(escapeString("")).toBe("");
});
it('handles a normal string', () => {
expect(escapeString('A landslide has occurred!')).toBe('A landslide has occurred!');
it("handles a normal string", () => {
expect(escapeString("A landslide has occurred!")).toBe(
"A landslide has occurred!",
);
});
it('escapes quotes', () => {
expect(escapeString('An "Energy Crystal" has been found!')).toBe('An \\"Energy Crystal\\" has been found!');
it("escapes quotes", () => {
expect(escapeString('An "Energy Crystal" has been found!')).toBe(
'An \\"Energy Crystal\\" has been found!',
);
});
it('removes backslashes', () => {
expect(escapeString('\\n\\n\\n\\')).toBe('nnn');
it("removes backslashes", () => {
expect(escapeString("\\n\\n\\n\\")).toBe("nnn");
});
});
});
2 changes: 1 addition & 1 deletion src/core/transformers/03_plastic/02_strataform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function spread(cavern: DiscoveredCavern, height: Grid<number>) {
const result = new MutableGrid<number>();
for (let x = cavern.left + 1; x < cavern.right; x++) {
for (let y = cavern.top + 1; y < cavern.bottom; y++) {
const ht = height.get(x, y)
const ht = height.get(x, y);
if (ht) {
result.set(x, y, ht);
} else {
Expand Down
7 changes: 5 additions & 2 deletions src/core/transformers/03_plastic/03_strataflux/edges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,11 @@ function getTileSlopes(cavern: StrataformedCavern): Grid<number> {
slope,
cavern.pearlInnerDex
.get(x, y)
?.reduce((r: number | undefined, _, i) => Math.min(r ?? Infinity, maxSlopeForPlan[i]), undefined) ??
planlessSlope
?.reduce(
(r: number | undefined, _, i) =>
Math.min(r ?? Infinity, maxSlopeForPlan[i]),
undefined,
) ?? planlessSlope,
);
result.set(x, y, slope);
}
Expand Down
8 changes: 6 additions & 2 deletions src/core/transformers/03_plastic/03_strataflux/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ function superflat(cavern: StrataformedCavern): Grid<number> {
return result;
}

function getRandomHeight(node: HeightNode, rng: PseudorandomStream, strataplanity: number): number {
function getRandomHeight(
node: HeightNode,
rng: PseudorandomStream,
strataplanity: number,
): number {
if (node.min === node.max) {
return node.min;
}
Expand Down Expand Up @@ -83,7 +87,7 @@ export default function strataflux(
}
}
return collapseQueue.splice(r, 1)[0];
}
};

// Collapsing a node means picking a specific height in range for that node.
const collapse = () => {
Expand Down
36 changes: 12 additions & 24 deletions src/webui/components/context_editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,33 +280,21 @@ export function CavernContextInput({
step={5}
{...rest}
/>
<Slider
of="stratascosity"
min={0}
max={20}
step={1}
{...rest}
/>
<Slider of="stratascosity" min={0} max={20} step={1} {...rest} />
</div>
<div className={styles.subsection}>
<h3>Strataflux</h3>
<Slider
of={"strataplanity"}
min={0}
max={10}
{...rest}
/>
{(["caveMaxSlope", "hallMaxSlope", "voidMaxSlope", "borderMaxSlope"] as const).map(
(of) => (
<Slider
key={of}
of={of}
min={0}
max={300}
{...rest}
/>
),
)}
<Slider of={"strataplanity"} min={0} max={10} {...rest} />
{(
[
"caveMaxSlope",
"hallMaxSlope",
"voidMaxSlope",
"borderMaxSlope",
] as const
).map((of) => (
<Slider key={of} of={of} min={0} max={300} {...rest} />
))}
</div>
<div className={styles.subsection}>
<h3>Populate</h3>
Expand Down
29 changes: 16 additions & 13 deletions src/webui/components/map_preview/height.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import React from "react";
import { Grid } from "../../../core/common/grid";
import styles from "./style.module.scss";
import { HEIGHT_MAX, HEIGHT_MIN } from "../../../core/transformers/03_plastic/03_strataflux/base";
import {
HEIGHT_MAX,
HEIGHT_MIN,
} from "../../../core/transformers/03_plastic/03_strataflux/base";

const SCALE = 6;

const OCTAGON = [
'M0.5,0.125',
'L0.125,0.5',
'L-0.125,0.5',
'L-0.5,0.125',
'L-0.5,-0.125',
'L-0.125,-0.5',
'L0.125,-0.5',
'L0.5, -0.125',
'Z',
].join(' ')
"M0.5,0.125",
"L0.125,0.5",
"L-0.125,0.5",
"L-0.5,0.125",
"L-0.5,-0.125",
"L-0.125,-0.5",
"L0.125,-0.5",
"L0.5, -0.125",
"Z",
].join(" ");

function toColor(h: number) {
const v = (h - HEIGHT_MIN) / (HEIGHT_MAX - HEIGHT_MIN);
Expand All @@ -32,8 +35,8 @@ export default function HeightPreview({ height }: { height: Grid<number> }) {
<rect
key={`${x},${y}`}
fill={toColor(h)}
x={x-0.5}
y={y-0.5}
x={x - 0.5}
y={y - 0.5}
width={1}
height={1}
>
Expand Down

0 comments on commit 839a34c

Please sign in to comment.