This repository has been archived by the owner on Sep 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
smaghetti.d.ts
201 lines (172 loc) · 4.02 KB
/
smaghetti.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
type Point = {
x: number;
y: number;
};
type Bounds = {
upperLeft: Point;
lowerRight: Point;
};
type EntityType = import('./src/entities/entityMap').EntityType;
type IDable = { id: number };
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type EditorEntitySettings = Record<string, any>;
type NewEditorEntity = {
x: number;
y: number;
type: EntityType;
disableDrag?: boolean;
settings?: EditorEntitySettings;
};
type EditorEntity = NewEditorEntity & IDable;
type EditorTransport = {
x: number;
y: number;
room: number;
destX: number;
destY: number;
destRoom: number;
exitType:
| 'door'
| 'up-from-pipe'
| 'down-from-pipe'
| 'horizontal-travel-left-pipe'
| 'horizontal-travel-right-pipe';
};
type EditorEntityRow = Array<EditorEntity | null | undefined>;
type EditorEntityMatrix = Array<EditorEntityRow | null | undefined>;
// the string is the short id for the entity type, ie "Brick" -> "Br"
type SerializedEditorEntityMatrix = Array<string | Array<string>>;
type BackgroundGraphic =
| 'blank'
| 'underground'
| 'underground-cave'
| 'fortress'
| 'plains'
| 'desert'
| 'ghost-house'
| 'basic-ghost-house'
| 'basic-castle'
| 'tall-hills'
| 'tall-hills-but-shorter'
| 'tetris-room'
| 'underground-double-cave'
| 'metal-brick'
| 'underwater-more-terrain'
| 'winter'
| 'underwater'
| 'long-clouds'
| 'crystal-underground'
| 'hills-at-night'
| 'night-sky'
| 'bonus-room'
| 'stormy-clouds'
| 'stone-wall'
| 'large-pulsating-bricks'
| 'basement-dungeon'
| 'pyramids'
| 'inside-airship'
| 'mountains'
| 'high-up-in-the-clouds'
| 'waterfalls'
| 'bowser-castle'
| 'pipes'
| 'green-mountains'
| 'hills-in-clouds'
| 'far-away-hills-in-clouds'
| 'jungle'
| 'jungle-no-sky'
| 'toad-house'
| 'pyramid-split-inside-and-out'
| 'desert-brick-wall'
| 'colorful-brick-wall'
| 'blue-and-green-stars';
type BackgroundExtraColorAndEffect =
| 'none'
| 'fortress-parallax'
| 'underwater-ripple-purple'
| 'stormy-clouds-lightning'
| 'lava-shimmer';
type RoomBackgroundSettings = {
bgGraphic: number;
bgColor: number;
bgExtraColorAndEffect: number;
unknownThirdHeaderByte?: number;
};
type RoomSettings = RoomBackgroundSettings & {
music: number;
wrapAround?: boolean;
};
type RoomLayer = {
entities: EditorEntity[];
matrix: EditorEntityMatrix;
};
type RoomData = {
settings: RoomSettings;
actors: RoomLayer;
stage: RoomLayer;
roomTileWidth: number;
roomTileHeight: number;
// not really room data, but these need to be persisted
paletteEntries: EntityType[];
};
type SerializedMatrixEntitySettings = {
x: number;
y: number;
s: EditorEntitySettings;
};
type SerializedRoomLayer = {
entities: EditorEntity[];
matrix: SerializedEditorEntityMatrix;
matrixSettings: SerializedMatrixEntitySettings[];
};
type SerializedRoomData = Omit<RoomData, 'actors' | 'stage'> & {
actors: SerializedRoomLayer;
stage: SerializedRoomLayer;
};
type LevelSettings = {
timer: number;
tag0?: string;
tag1?: string;
description?: string;
};
type LevelData = {
settings: LevelSettings;
rooms: RoomData[];
};
type NewLevel = {
name: string;
username?: string;
data: LevelData;
created_at: string;
updated_at?: string;
published?: boolean;
user?: {
username: string;
role?: string;
};
};
type SerializedLevelData = {
settings: LevelSettings;
rooms: SerializedRoomData[];
};
type Level = NewLevel & { id: string };
type SerializedLevel = Omit<Level, 'data'> & {
data: SerializedLevelData;
version: string;
};
type LevelVote = {
userId: string;
levelId: string;
};
type LocalStorageSerializedLevel = Omit<
SerializedLevel,
'created_at' | 'updated_at'
>;
type LevelToLoadInGBA = Omit<NewLevel, 'created_at' | 'updated_at'>;
type User = { id: string; username: string; role?: string };
// TODO: these types don't fully work, for example when used as the return type of a function
type Tuple<T, N extends number> = N extends N ? T[] : _TupleOf<T, N, []>;
type _TupleOf<T, N extends number, R extends unknown[]> = R['length'] extends N
? R
: _TupleOf<T, N, [T, ...R]>;
type PlayAsCharacter = 'mario' | 'luigi';