Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.

Commit ffad87d

Browse files
committed
chore: use a list
Using an object with number keys is the same thing.
1 parent 142f104 commit ffad87d

File tree

4 files changed

+18
-42
lines changed

4 files changed

+18
-42
lines changed

src/data/data-types.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ type Lvl2 = 2;
2121
/**
2222
* Represent the stairs.
2323
*/
24-
type StairList = Record<NumberIndex, Coords2D>;
25-
26-
type NumberIndex = `${number}`;
24+
type StairList = Coords2D[];
2725

2826
/**
2927
* Represent coordinates for stairs.
@@ -109,13 +107,4 @@ type GWing = "G";
109107
*/
110108
type HWing = "H";
111109

112-
export type {
113-
Coords,
114-
Coords2D,
115-
Level,
116-
Lvl,
117-
NumberIndex,
118-
Rooms,
119-
StairList,
120-
Wing,
121-
};
110+
export type { Coords, Coords2D, Level, Lvl, Rooms, StairList, Wing };

src/data/schemas.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { z } from "zod";
2-
import type { NumberIndex } from "./data-types.ts";
32
import { rooms } from "./rooms.ts";
43

54
type ProfilesList = z.infer<typeof profilesListSchema>;
@@ -86,15 +85,4 @@ const profilesListSchema = z.union([
8685
z.tuple([]),
8786
]);
8887

89-
const numberIndexSchema = z.custom<NumberIndex>((val) =>
90-
z.string().regex(/^\d+$/).safeParse(val),
91-
);
92-
93-
export {
94-
isKey,
95-
numberIndexSchema,
96-
profilesListSchema,
97-
roomSchema,
98-
type ProfilesList,
99-
type Room,
100-
};
88+
export { isKey, profilesListSchema, roomSchema, type ProfilesList, type Room };

src/data/stairs.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import type { StairList } from "./data-types.ts";
22

3-
const stairs = {
4-
"0": [23, 13],
5-
"1": [63, 16],
6-
"2": [103, 16],
7-
"3": [65, 61],
8-
"4": [96, 61],
9-
"5": [129, 119],
10-
"6": [68, 121],
11-
"7": [92, 121],
12-
} as const satisfies StairList;
3+
const stairs = [
4+
[23, 13],
5+
[63, 16],
6+
[103, 16],
7+
[65, 61],
8+
[96, 61],
9+
[129, 119],
10+
[68, 121],
11+
[92, 121],
12+
] as const satisfies StairList;
1313

14-
const btmStairs = {
15-
"0": [90, 154],
16-
"1": [71, 154],
17-
} as const satisfies StairList;
14+
const btmStairs = [
15+
[90, 154],
16+
[71, 154],
17+
] as const satisfies StairList;
1818

1919
export { btmStairs, stairs };

src/script.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { level0, level1, level2 } from "./data/levels.ts";
2424
import { rooms } from "./data/rooms.ts";
2525
import {
2626
isKey,
27-
numberIndexSchema,
2827
profilesListSchema,
2928
roomSchema,
3029
type ProfilesList,
@@ -413,7 +412,7 @@ function pathCalculationInternals(
413412
}
414413
}
415414

416-
return stairs[numberIndexSchema.parse(minData.minIndex.toString())];
415+
return stairs[minData.minIndex];
417416
}
418417

419418
function stairPath(

0 commit comments

Comments
 (0)