Skip to content

Commit f19d4b6

Browse files
committed
Formatting and such
1 parent ddeab72 commit f19d4b6

4 files changed

Lines changed: 73 additions & 26 deletions

File tree

easter/src/controllers/GameController.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import type { Map } from "ol";
22
import { HexGrid, GridConfig } from "../game/grid/HexGrid";
33
import { GameLogic } from "../game/state/GameState";
4-
import { LOCALITIES, LocalityConfig, GAME_OF_LIFE_CONFIG } from "../config/levels";
4+
import {
5+
LOCALITIES,
6+
LocalityConfig,
7+
GAME_OF_LIFE_CONFIG,
8+
} from "../config/levels";
59
import { GamePanel, GameType } from "../game/ui/GamePanel";
610
import { ProgressManager } from "../game/state/Progress";
711
import { GameOfLifeLogic } from "../game/state/GameOfLifeState";
@@ -49,7 +53,7 @@ export class GameController {
4953
() => this.clearLife(),
5054
() => this.toggleLife(),
5155
(pattern: PatternName) => this.selectPattern(pattern),
52-
this.currentGameType
56+
this.currentGameType,
5357
);
5458

5559
// Start with Game of Life by default
@@ -98,7 +102,7 @@ export class GameController {
98102
};
99103

100104
this.grid = new HexGrid(this.map, gridConfig, this.gameLogic, () =>
101-
this.handleGameOver()
105+
this.handleGameOver(),
102106
);
103107
}
104108

@@ -183,7 +187,7 @@ export class GameController {
183187
this.gameLogic = new GameLogic(
184188
level.rings,
185189
level.minePercentage,
186-
levelIndex + 1
190+
levelIndex + 1,
187191
);
188192

189193
const gridConfig: GridConfig = {
@@ -195,7 +199,7 @@ export class GameController {
195199

196200
// Create new grid with new game logic
197201
this.grid = new HexGrid(this.map, gridConfig, this.gameLogic, () =>
198-
this.handleGameOver()
202+
this.handleGameOver(),
199203
);
200204

201205
// Update UI

easter/src/game/grid/GameOfLifeGrid.ts

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import {
88
stringToCoord,
99
} from "../state/GameOfLifeState";
1010

11-
export type PatternName = "glider" | "diagonal" | "hexagon" | "triangle" | "line" | "spark";
11+
export type PatternName =
12+
| "glider"
13+
| "diagonal"
14+
| "hexagon"
15+
| "triangle"
16+
| "line"
17+
| "spark";
1218

1319
export const PATTERNS: Record<PatternName, Coordinate[]> = {
1420
glider: [
@@ -25,32 +31,57 @@ export const PATTERNS: Record<PatternName, Coordinate[]> = {
2531
],
2632
diagonal: [
2733
// Diagonal stripe (10 cells)
28-
{ q: -2, r: 2 }, { q: -1, r: 1 }, { q: 0, r: 0 }, { q: 1, r: -1 }, { q: 2, r: -2 },
29-
{ q: -1, r: 2 }, { q: 0, r: 1 }, { q: 1, r: 0 }, { q: 2, r: -1 }, { q: 3, r: -2 },
34+
{ q: -2, r: 2 },
35+
{ q: -1, r: 1 },
36+
{ q: 0, r: 0 },
37+
{ q: 1, r: -1 },
38+
{ q: 2, r: -2 },
39+
{ q: -1, r: 2 },
40+
{ q: 0, r: 1 },
41+
{ q: 1, r: 0 },
42+
{ q: 2, r: -1 },
43+
{ q: 3, r: -2 },
3044
],
3145
hexagon: [
3246
// Hexagon ring (6 cells)
33-
{ q: 1, r: 0 }, { q: 0, r: 1 }, { q: -1, r: 1 },
34-
{ q: -1, r: 0 }, { q: 0, r: -1 }, { q: 1, r: -1 },
47+
{ q: 1, r: 0 },
48+
{ q: 0, r: 1 },
49+
{ q: -1, r: 1 },
50+
{ q: -1, r: 0 },
51+
{ q: 0, r: -1 },
52+
{ q: 1, r: -1 },
3553
],
3654
triangle: [
3755
// Filled triangle (10 cells)
3856
{ q: 0, r: 0 },
39-
{ q: -1, r: 1 }, { q: 0, r: 1 },
40-
{ q: -2, r: 2 }, { q: -1, r: 2 }, { q: 0, r: 2 },
41-
{ q: -3, r: 3 }, { q: -2, r: 3 }, { q: -1, r: 3 }, { q: 0, r: 3 },
57+
{ q: -1, r: 1 },
58+
{ q: 0, r: 1 },
59+
{ q: -2, r: 2 },
60+
{ q: -1, r: 2 },
61+
{ q: 0, r: 2 },
62+
{ q: -3, r: 3 },
63+
{ q: -2, r: 3 },
64+
{ q: -1, r: 3 },
65+
{ q: 0, r: 3 },
4266
],
4367
line: [
4468
// Straight line (6 cells)
45-
{ q: -2, r: 0 }, { q: -1, r: 0 }, { q: 0, r: 0 },
46-
{ q: 1, r: 0 }, { q: 2, r: 0 }, { q: 3, r: 0 },
69+
{ q: -2, r: 0 },
70+
{ q: -1, r: 0 },
71+
{ q: 0, r: 0 },
72+
{ q: 1, r: 0 },
73+
{ q: 2, r: 0 },
74+
{ q: 3, r: 0 },
4775
],
4876
spark: [
4977
// Sparse pattern - each cell has ~2-3 neighbors
5078
{ q: 0, r: 0 },
51-
{ q: 2, r: 0 }, { q: -2, r: 0 },
52-
{ q: 1, r: 1 }, { q: -1, r: -1 },
53-
{ q: 1, r: -1 }, { q: -1, r: 1 },
79+
{ q: 2, r: 0 },
80+
{ q: -2, r: 0 },
81+
{ q: 1, r: 1 },
82+
{ q: -1, r: -1 },
83+
{ q: 1, r: -1 },
84+
{ q: -1, r: 1 },
5485
],
5586
};
5687

@@ -84,7 +115,11 @@ export class GameOfLifeGrid {
84115
private drawMode: boolean = true; // true = draw alive, false = erase
85116
private selectedPattern: PatternName = "glider";
86117

87-
constructor(map: OLMap, config: GameOfLifeGridConfig, gameLogic: GameOfLifeLogic) {
118+
constructor(
119+
map: OLMap,
120+
config: GameOfLifeGridConfig,
121+
gameLogic: GameOfLifeLogic,
122+
) {
88123
this.map = map;
89124
this.config = config;
90125
this.gameLogic = gameLogic;

easter/src/game/state/GameOfLifeState.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class GameOfLifeLogic {
4242

4343
private countAliveNeighbors(coord: Coordinate): number {
4444
return this.getNeighbors(coord).filter((n) =>
45-
this.aliveCells.has(coordToString(n))
45+
this.aliveCells.has(coordToString(n)),
4646
).length;
4747
}
4848

@@ -158,11 +158,15 @@ export class GameOfLifeLogic {
158158
private addCellsInRadius(
159159
center: Coordinate,
160160
radius: number,
161-
cells: Set<string>
161+
cells: Set<string>,
162162
): void {
163163
// Add all cells within 'radius' rings of center
164164
for (let q = -radius; q <= radius; q++) {
165-
for (let r = Math.max(-radius, -q - radius); r <= Math.min(radius, -q + radius); r++) {
165+
for (
166+
let r = Math.max(-radius, -q - radius);
167+
r <= Math.min(radius, -q + radius);
168+
r++
169+
) {
166170
const coord = { q: center.q + q, r: center.r + r };
167171
cells.add(coordToString(coord));
168172
}

easter/src/game/ui/GamePanel.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class GamePanel {
2828
onClear: () => void,
2929
onTogglePlay: () => void,
3030
onSelectPattern: (pattern: PatternName) => void,
31-
currentGame: GameType = "life"
31+
currentGame: GameType = "life",
3232
) {
3333
this.onExit = onExit;
3434
this.numLevels = numLevels;
@@ -273,7 +273,7 @@ export class GamePanel {
273273
if (!this.playButton) return;
274274
this.playButton.textContent = this.isPlaying ? "Pause" : "Play";
275275
this.playButton.style.cssText = this.getButtonStyle(
276-
this.isPlaying ? "#ff9800" : "#4CAF50"
276+
this.isPlaying ? "#ff9800" : "#4CAF50",
277277
);
278278
}
279279

@@ -301,7 +301,7 @@ export class GamePanel {
301301
? level === this.currentLevel
302302
? "#3392e0"
303303
: "#84bff0"
304-
: "#cccccc"
304+
: "#cccccc",
305305
);
306306

307307
button.dataset.level = level.toString();
@@ -334,7 +334,11 @@ export class GamePanel {
334334
const buttonLevel = parseInt(button.dataset.level || "1");
335335
const isUnlocked = button.dataset.unlocked === "true";
336336
button.style.cssText = this.getButtonStyle(
337-
isUnlocked ? (buttonLevel === level ? "#3392e0" : "#84bff0") : "#cccccc"
337+
isUnlocked
338+
? buttonLevel === level
339+
? "#3392e0"
340+
: "#84bff0"
341+
: "#cccccc",
338342
);
339343
});
340344
}

0 commit comments

Comments
 (0)