Skip to content

Commit 898841d

Browse files
committed
fix pre-commit
1 parent 49acc10 commit 898841d

6 files changed

Lines changed: 146 additions & 113 deletions

File tree

biome.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.4.10/schema.json",
33
"files": {
4-
"includes": ["**/*.json", "**/*.njk", "**/*.yaml", "**/*.yml", "src/assets/js/**/*.js"]
4+
"includes": [
5+
"**/*.json",
6+
"**/*.njk",
7+
"**/*.yaml",
8+
"**/*.yml",
9+
"src/assets/js/**/*.js"
10+
]
511
},
612
"linter": {
713
"enabled": true,

src/assets/js/eggs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Trigger: 5 clicks on the footer ❤️ → SpaceInvaders.launch()
88
*/
99

10-
(function () {
10+
(() => {
1111
let heartClickCount = 0;
1212
let phaserStarted = false;
1313

@@ -17,7 +17,7 @@
1717
heart.style.cursor = "pointer";
1818
heart.style.display = "inline-block";
1919

20-
heart.addEventListener("click", function () {
20+
heart.addEventListener("click", () => {
2121
if (phaserStarted) return;
2222

2323
heartClickCount++;
@@ -33,7 +33,7 @@
3333
heart.innerHTML = "🎮";
3434
heart.style.transform = "scale(1.5)";
3535

36-
setTimeout(function () {
36+
setTimeout(() => {
3737
heart.style.opacity = "0";
3838
SpaceInvaders.launch();
3939
}, 300);

src/assets/js/games/code-breaker.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Theme-aware: reads the current dark/light mode at startup.
1414
*/
1515

16-
const CodeBreaker = (function () {
16+
const CodeBreaker = (() => {
1717
const GAME_ID = "code-breaker";
1818
const TILE_SPEED_BASE = 180;
1919
const TILE_SPEED_INC = 8; // extra px/s per collected tile
@@ -25,7 +25,7 @@ const CodeBreaker = (function () {
2525
// ─── Public entry-point ──────────────────────────────────────────────────
2626

2727
function launch(skills, devName) {
28-
GameManager.loadPhaser(function () {
28+
GameManager.loadPhaser(() => {
2929
_init(skills, devName);
3030
});
3131
}
@@ -52,8 +52,7 @@ const CodeBreaker = (function () {
5252
titleBar.style.cssText =
5353
"color:#fff;font-size:0.85rem;font-weight:900;text-transform:uppercase;" +
5454
"letter-spacing:0.15em;margin-bottom:0.5rem;opacity:0.8;";
55-
titleBar.textContent =
56-
"⌨️ CODE BREAKER" + (devName ? " — " + devName : "");
55+
titleBar.textContent = "⌨️ CODE BREAKER" + (devName ? " — " + devName : "");
5756
overlay.appendChild(titleBar);
5857

5958
// Canvas container — intentionally has NO id matching "game-canvas-{GAME_ID}"
@@ -112,23 +111,21 @@ const CodeBreaker = (function () {
112111
catcherGfx.generateTexture("catcher", CATCHER_WIDTH, CATCHER_HEIGHT);
113112
catcherGfx.destroy();
114113

115-
scene.cb_catcher = scene.physics.add.image(
116-
W / 2,
117-
H - 40,
118-
"catcher",
119-
);
114+
scene.cb_catcher = scene.physics.add.image(W / 2, H - 40, "catcher");
120115
scene.cb_catcher.setCollideWorldBounds(true);
121116
scene.cb_catcher.setImmovable(true);
122117

123118
// HUD
124119
scene.cb_livesText = scene.add.text(10, 10, "❤️".repeat(LIVES), {
125120
fontSize: "18px",
126121
});
127-
scene.cb_scoreText = scene.add.text(W - 10, 10, "Score: 0", {
128-
fontSize: "14px",
129-
fill: theme.accent,
130-
fontStyle: "bold",
131-
}).setOrigin(1, 0);
122+
scene.cb_scoreText = scene.add
123+
.text(W - 10, 10, "Score: 0", {
124+
fontSize: "14px",
125+
fill: theme.accent,
126+
fontStyle: "bold",
127+
})
128+
.setOrigin(1, 0);
132129

133130
scene.cb_infoText = scene.add
134131
.text(W / 2, H - 12, "← → to move • catch your skills!", {
@@ -141,7 +138,7 @@ const CodeBreaker = (function () {
141138
scene.physics.add.overlap(
142139
scene.cb_catcher,
143140
scene.cb_tiles,
144-
function (catcher, tile) {
141+
(catcher, tile) => {
145142
_collectTile(scene, tile, theme, W, H);
146143
},
147144
);
@@ -150,7 +147,7 @@ const CodeBreaker = (function () {
150147
scene.cb_cursors = scene.input.keyboard.createCursorKeys();
151148

152149
// Mouse / touch drag
153-
scene.input.on("pointermove", function (ptr) {
150+
scene.input.on("pointermove", (ptr) => {
154151
if (!scene.cb_active) return;
155152
scene.cb_catcher.x = Phaser.Math.Clamp(
156153
ptr.x,
@@ -160,12 +157,12 @@ const CodeBreaker = (function () {
160157
});
161158

162159
// ESC to quit
163-
scene.input.keyboard.once("keydown-ESC", function () {
160+
scene.input.keyboard.once("keydown-ESC", () => {
164161
_cleanup();
165162
});
166163

167164
// Spawn first tile after a short delay
168-
scene.time.delayedCall(500, function () {
165+
scene.time.delayedCall(500, () => {
169166
_spawnTile(scene, theme, W);
170167
});
171168
}
@@ -193,12 +190,15 @@ const CodeBreaker = (function () {
193190
// Check if any tile fell off the bottom.
194191
// Use .slice() to iterate over a copy — destroying tiles inside forEach
195192
// mutates the live getChildren() array and causes tiles to be skipped.
196-
scene.cb_tiles.getChildren().slice().forEach(function (tile) {
197-
if (tile.y > scene.scale.height + 40) {
198-
tile.destroy();
199-
_loseLife(scene);
200-
}
201-
});
193+
scene.cb_tiles
194+
.getChildren()
195+
.slice()
196+
.forEach((tile) => {
197+
if (tile.y > scene.scale.height + 40) {
198+
tile.destroy();
199+
_loseLife(scene);
200+
}
201+
});
202202
}
203203

204204
// ─── Game logic ──────────────────────────────────────────────────────────
@@ -240,11 +240,13 @@ const CodeBreaker = (function () {
240240
tile.setData("color", color);
241241

242242
// Skill label on top of the pill
243-
const label = scene.add.text(x, -20, skill, {
244-
fontSize: TILE_FONT_SIZE,
245-
fill: color,
246-
fontStyle: "bold",
247-
}).setOrigin(0.5);
243+
const label = scene.add
244+
.text(x, -20, skill, {
245+
fontSize: TILE_FONT_SIZE,
246+
fill: color,
247+
fontStyle: "bold",
248+
})
249+
.setOrigin(0.5);
248250

249251
// Keep label synced with the physics body each frame
250252
function syncLabel() {
@@ -294,7 +296,7 @@ const CodeBreaker = (function () {
294296
y: H - 120,
295297
alpha: 0,
296298
duration: 900,
297-
onComplete: function () {
299+
onComplete: () => {
298300
popup.destroy();
299301
},
300302
});

src/assets/js/games/dev-duel.js

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Theme-aware: reads the current dark/light mode at startup.
1313
*/
1414

15-
const DevDuel = (function () {
15+
const DevDuel = (() => {
1616
const GAME_ID = "dev-duel";
1717

1818
// ─── Public entry-point ──────────────────────────────────────────────────
@@ -22,7 +22,7 @@ const DevDuel = (function () {
2222
* @param {{ name:string, role:string, skills:string[] }} opponent
2323
*/
2424
function launch(challenger, opponent) {
25-
GameManager.loadPhaser(function () {
25+
GameManager.loadPhaser(() => {
2626
_init(challenger, opponent);
2727
});
2828
}
@@ -106,11 +106,27 @@ const DevDuel = (function () {
106106
.setOrigin(0.5);
107107

108108
// Power bars
109-
_drawPowerBar(scene, challenger.name, cPower, W * 0.02, H - 90, W * 0.44, theme);
110-
_drawPowerBar(scene, opponent.name, oPower, W * 0.54, H - 90, W * 0.44, theme);
109+
_drawPowerBar(
110+
scene,
111+
challenger.name,
112+
cPower,
113+
W * 0.02,
114+
H - 90,
115+
W * 0.44,
116+
theme,
117+
);
118+
_drawPowerBar(
119+
scene,
120+
opponent.name,
121+
oPower,
122+
W * 0.54,
123+
H - 90,
124+
W * 0.44,
125+
theme,
126+
);
111127

112128
// Animate the battle after a short delay
113-
scene.time.delayedCall(800, function () {
129+
scene.time.delayedCall(800, () => {
114130
_animateBattle(scene, challenger, opponent, cPower, oPower, W, H, theme);
115131
});
116132
}
@@ -160,7 +176,7 @@ const DevDuel = (function () {
160176

161177
// Top skills (up to 5)
162178
const skills = (dev.skills || []).slice(0, 5);
163-
skills.forEach(function (skill, i) {
179+
skills.forEach((skill, i) => {
164180
const rarity = skillRarity(skill);
165181
const color = RARITY_COLORS[rarity] || "#94a3b8";
166182
scene.add
@@ -199,7 +215,7 @@ const DevDuel = (function () {
199215
w: barW,
200216
duration: 800,
201217
ease: "Power2",
202-
onUpdate: function (tween, target) {
218+
onUpdate: (tween, target) => {
203219
fillGfx.clear();
204220
fillGfx.fillStyle(0x38bdf8, 1);
205221
fillGfx.fillRoundedRect(x, y + 14, target.w, 10, 3);
@@ -215,14 +231,23 @@ const DevDuel = (function () {
215231

216232
// ─── Battle animation ─────────────────────────────────────────────────────
217233

218-
function _animateBattle(scene, challenger, opponent, cPower, oPower, W, H, theme) {
234+
function _animateBattle(
235+
scene,
236+
challenger,
237+
opponent,
238+
cPower,
239+
oPower,
240+
W,
241+
H,
242+
theme,
243+
) {
219244
// Flash attacks back and forth
220245
let round = 0;
221246
const maxRounds = 5;
222247

223-
const attackFlash = function () {
248+
const attackFlash = () => {
224249
if (round >= maxRounds) {
225-
scene.time.delayedCall(400, function () {
250+
scene.time.delayedCall(400, () => {
226251
_showResult(scene, challenger, opponent, cPower, oPower, W, H, theme);
227252
});
228253
return;
@@ -242,7 +267,7 @@ const DevDuel = (function () {
242267
x: endX,
243268
duration: 350,
244269
ease: "Power2",
245-
onComplete: function () {
270+
onComplete: () => {
246271
bolt.destroy();
247272
scene.cameras.main.shake(120, 0.008);
248273
scene.time.delayedCall(200, attackFlash);
@@ -255,7 +280,16 @@ const DevDuel = (function () {
255280

256281
// ─── Result screen ────────────────────────────────────────────────────────
257282

258-
function _showResult(scene, challenger, opponent, cPower, oPower, W, H, theme) {
283+
function _showResult(
284+
scene,
285+
challenger,
286+
opponent,
287+
cPower,
288+
oPower,
289+
W,
290+
H,
291+
theme,
292+
) {
259293
const challengerWins = cPower >= oPower;
260294
const winner = challengerWins ? challenger : opponent;
261295

@@ -291,12 +325,10 @@ const DevDuel = (function () {
291325

292326
const powerDiff = Math.abs(cPower - oPower);
293327
scene.add
294-
.text(
295-
W / 2,
296-
H / 2 + 5,
297-
"Power advantage: +" + powerDiff + " pts",
298-
{ fontSize: "14px", fill: "#94a3b8" },
299-
)
328+
.text(W / 2, H / 2 + 5, "Power advantage: +" + powerDiff + " pts", {
329+
fontSize: "14px",
330+
fill: "#94a3b8",
331+
})
300332
.setOrigin(0.5);
301333

302334
scene.add
@@ -326,7 +358,7 @@ const DevDuel = (function () {
326358
*/
327359
function _calcPower(skills) {
328360
if (!skills || skills.length === 0) return 1;
329-
return skills.reduce(function (total, skill) {
361+
return skills.reduce((total, skill) => {
330362
const rarity = skillRarity(skill);
331363
return total + (RARITY_WEIGHTS[rarity] || 1);
332364
}, 0);
@@ -355,10 +387,7 @@ function getCardData(cardEl) {
355387
return {
356388
name: (cardEl.dataset.name || "").trim(),
357389
role: (cardEl.dataset.role || "").trim(),
358-
skills: (cardEl.dataset.skills || "")
359-
.trim()
360-
.split(/\s+/)
361-
.filter(Boolean),
390+
skills: (cardEl.dataset.skills || "").trim().split(/\s+/).filter(Boolean),
362391
};
363392
}
364393

@@ -369,10 +398,10 @@ function getCardData(cardEl) {
369398
* @param {HTMLElement} challengerCard The card element that was clicked.
370399
*/
371400
function startDuelFromCard(challengerCard) {
372-
const allCards = Array.from(document.querySelectorAll(".user-card[data-name]"));
373-
const others = allCards.filter(function (c) {
374-
return c !== challengerCard;
375-
});
401+
const allCards = Array.from(
402+
document.querySelectorAll(".user-card[data-name]"),
403+
);
404+
const others = allCards.filter((c) => c !== challengerCard);
376405

377406
if (others.length === 0) return;
378407

0 commit comments

Comments
 (0)