From 4b60b12bba0f494edc068a59646b2ceaafb1a251 Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 10 Jun 2024 21:20:03 -0400 Subject: [PATCH] fix(levels): improve hints and incorrect password message --- src/levels/0.ts | 2 +- src/levels/10.ts | 2 ++ src/levels/11.ts | 1 + src/templates/events.ts | 12 ++++++++++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/levels/0.ts b/src/levels/0.ts index bb5ee04..e84dcad 100644 --- a/src/levels/0.ts +++ b/src/levels/0.ts @@ -8,7 +8,7 @@ import { export const level = 0 export const title = 'console.log' -export const hint = 'Reach the exit' +export const hint = 'Press the door' export const prescript = ` ${addPlayer({ pos: '50, center().y' })} diff --git a/src/levels/10.ts b/src/levels/10.ts index d7ec69e..964a335 100644 --- a/src/levels/10.ts +++ b/src/levels/10.ts @@ -13,6 +13,8 @@ export const title = 'Variables' const password = (new Date().getFullYear() + level) * 31337 +export const hint = String(password) + export const prescript = ` ${loadExit()} diff --git a/src/levels/11.ts b/src/levels/11.ts index c797a57..6a9ccdf 100644 --- a/src/levels/11.ts +++ b/src/levels/11.ts @@ -10,6 +10,7 @@ import { export const level = 11 export const title = 'For Loop' +export const hint = "Array(42).fill().map(...).join('')" const password = Array.from(Array(42).keys()) .map(() => 'answer') diff --git a/src/templates/events.ts b/src/templates/events.ts index 11638ec..912c1e9 100644 --- a/src/templates/events.ts +++ b/src/templates/events.ts @@ -73,14 +73,22 @@ ${loadBlip()} ${loadPowerup()} onCollide('key', 'player', (key) => { - if (key.password === ${JSON.stringify(password)}) { + const password = ${JSON.stringify(password)} + + if (key.password === password) { play('powerup', { volume: 0.5 }) key.destroy() add([sprite('exit'), pos(500, 500), area(), 'exit']) + return + } + + if (typeof key.password !== typeof password) { + debug.log('Password should be a ' + typeof password) } else { - play('blip', { volume: 0.5 }) debug.log('Incorrect password') } + + play('blip', { volume: 0.5 }) }) `