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

Commit

Permalink
chore: use a list
Browse files Browse the repository at this point in the history
Using an object with number keys is the same thing.
  • Loading branch information
lishaduck committed Jan 29, 2024
1 parent 142f104 commit ffad87d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 42 deletions.
15 changes: 2 additions & 13 deletions src/data/data-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ type Lvl2 = 2;
/**
* Represent the stairs.
*/
type StairList = Record<NumberIndex, Coords2D>;

type NumberIndex = `${number}`;
type StairList = Coords2D[];

/**
* Represent coordinates for stairs.
Expand Down Expand Up @@ -109,13 +107,4 @@ type GWing = "G";
*/
type HWing = "H";

export type {
Coords,
Coords2D,
Level,
Lvl,
NumberIndex,
Rooms,
StairList,
Wing,
};
export type { Coords, Coords2D, Level, Lvl, Rooms, StairList, Wing };
14 changes: 1 addition & 13 deletions src/data/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { z } from "zod";
import type { NumberIndex } from "./data-types.ts";
import { rooms } from "./rooms.ts";

type ProfilesList = z.infer<typeof profilesListSchema>;
Expand Down Expand Up @@ -86,15 +85,4 @@ const profilesListSchema = z.union([
z.tuple([]),
]);

const numberIndexSchema = z.custom<NumberIndex>((val) =>
z.string().regex(/^\d+$/).safeParse(val),
);

export {
isKey,
numberIndexSchema,
profilesListSchema,
roomSchema,
type ProfilesList,
type Room,
};
export { isKey, profilesListSchema, roomSchema, type ProfilesList, type Room };
28 changes: 14 additions & 14 deletions src/data/stairs.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import type { StairList } from "./data-types.ts";

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

const btmStairs = {
"0": [90, 154],
"1": [71, 154],
} as const satisfies StairList;
const btmStairs = [
[90, 154],
[71, 154],
] as const satisfies StairList;

export { btmStairs, stairs };
3 changes: 1 addition & 2 deletions src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { level0, level1, level2 } from "./data/levels.ts";
import { rooms } from "./data/rooms.ts";
import {
isKey,
numberIndexSchema,
profilesListSchema,
roomSchema,
type ProfilesList,
Expand Down Expand Up @@ -413,7 +412,7 @@ function pathCalculationInternals(
}
}

return stairs[numberIndexSchema.parse(minData.minIndex.toString())];
return stairs[minData.minIndex];
}

function stairPath(
Expand Down

0 comments on commit ffad87d

Please sign in to comment.