From ea98b346d759fd0e8c705a406ee52d2e4dcf7946 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 05:45:58 +0000 Subject: [PATCH] Bring early players back: day-2 warm-up puzzle and one come-back nudge Players who stop after Floor 1 or 2 never reach the daily (Floor 11) or its reminder. From their second day they now get a small warm-up puzzle that uses only the blocks they know and pays a hint, and after the first Floor 1 clear phones ask once whether to send a single reminder tomorrow. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01HnC1czwUeTw3xbSy3yFKGu --- src/App.tsx | 86 +++++++++++++- src/ReminderRows.tsx | 30 +++++ src/TitleScreen.tsx | 6 +- src/TowerMap.tsx | 6 +- src/comeback.test.ts | 81 +++++++++++++ src/comeback.ts | 237 +++++++++++++++++++++++++++++++++++++ src/daily/DailyButton.tsx | 38 +++++- src/daily/index.ts | 2 +- src/daily/warmup.test.ts | 45 +++++++ src/daily/warmup.ts | 188 +++++++++++++++++++++++++++++ src/editor/FloorScreen.tsx | 10 +- src/editor/ResultsCard.tsx | 31 ++++- src/i18n/fr/ui.json | 25 +++- src/styles.css | 27 +++++ 14 files changed, 797 insertions(+), 15 deletions(-) create mode 100644 src/comeback.test.ts create mode 100644 src/comeback.ts create mode 100644 src/daily/warmup.test.ts create mode 100644 src/daily/warmup.ts diff --git a/src/App.tsx b/src/App.tsx index f6ab791..f8b3d0b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -37,9 +37,12 @@ import { OverflowScreen, TerraceBanner } from './overflow/OverflowScreen'; import { climbOn, earnsBrick, endClimb, loadOverflow, markCleared, overflowLevel, pruneOverflow, saveOverflow, skipFloor, startClimb } from './overflow'; import type { OverflowState } from './overflow'; import { packUnlocked } from './store/purchases'; +import { loadComeback, noteFirstDay, onNudgeTapped, recordWarmupClear, refreshNudge, saveComeback, warmupOpen, warmupTierFor } from './comeback'; +import type { ComebackState } from './comeback'; +import { warmupLevel } from './daily/warmup'; /** How deep each screen sits, for the direction of the slide between them. */ -const SCREEN_DEPTH = { title: 0, map: 1, maker: 1, overflow: 2, floor: 2, daily: 2, custom: 2, climb: 3 } as const; +const SCREEN_DEPTH = { title: 0, map: 1, maker: 1, overflow: 2, floor: 2, daily: 2, warmup: 2, custom: 2, climb: 3 } as const; /** Each tower remembers its own floor: Tower 1 keeps the original key so old saves carry over. */ const floorKey = (tower: number) => (tower === 1 ? 'loopbot.floor' : `loopbot.floor.t${tower}`); @@ -82,7 +85,7 @@ export default function App() { }, []); // Every launch opens on the title screen, whose intro plays once per session; its Play button // goes to the next floor (Floor 1 for a new player), and the tower map is one tap further. - const [screen, setScreen] = useState<'title' | 'map' | 'floor' | 'daily' | 'maker' | 'custom' | 'overflow' | 'climb'>('title'); + const [screen, setScreen] = useState<'title' | 'map' | 'floor' | 'daily' | 'warmup' | 'maker' | 'custom' | 'overflow' | 'climb'>('title'); // Screens slide in from the side you're heading: deeper (title, map, floor) from the right, // back up from the left. styles.css keys the move off ; Reduce motion turns it off. const lastScreen = useRef(screen); @@ -179,6 +182,54 @@ export default function App() { ); const dailyRef = useRef(daily); dailyRef.current = daily; + // Players who haven't reached the daily yet: the warm-up from day 2, and the one come-back nudge (src/comeback.ts). + const [comeback, setComebackState] = useState(() => { + const before = loadComeback(); + const s = noteFirstDay(before, loadProgress()); + if (s !== before) saveComeback(s); + return s; + }); + const comebackRef = useRef(comeback); + comebackRef.current = comeback; + const [warmFloor, setWarmFloor] = useState<{ date: string; level: LevelFile } | null>(null); + const warmFrom = useRef<'title' | 'map'>('title'); + const progressRef = useRef(progress); + progressRef.current = progress; + const openWarmup = useCallback( + (from: 'title' | 'map') => { + const date = dateKey(); + warmFrom.current = from; + setProgress((p) => pruneOldDailies(date, p, date)); + const level = warmupLevel(date, warmupTierFor(progressRef.current)); + ride(() => { + setWarmFloor({ date, level }); + setScreen('warmup'); + }); + }, + [ride, setProgress], + ); + const clearWarmup = useCallback( + (date: string, stars: number) => { + const { state, hints } = recordWarmupClear(comebackRef.current, date, stars); + saveComeback(state); + comebackRef.current = state; + setComebackState(state); + if (hints) setProgress((p) => ({ ...p, hints: p.hints + hints })); + return hints; + }, + [setProgress], + ); + // The come-back nudge moves to tomorrow on every launch and every new clear (or is used up). + const clearedCount = Object.keys(progress.stars).length; + useEffect(() => void refreshNudge(progressRef.current), [clearedCount, language]); + // Tapping the nudge opens the warm-up, when there is one today. + useEffect( + () => + onNudgeTapped(() => { + if (warmupOpen(loadComeback(), progressRef.current)) openWarmup('title'); + }), + [openWarmup], + ); const clearDaily = useCallback( (date: string, stars: number, boss = false) => { const before = dailyRef.current; @@ -282,7 +333,7 @@ export default function App() { listenForBack(() => { if (screenRef.current === 'title') return false; const s = screenRef.current; - setScreen(s === 'floor' || s === 'overflow' ? 'map' : s === 'daily' ? dailyFrom.current : s === 'custom' ? 'maker' : s === 'climb' ? 'overflow' : 'title'); + setScreen(s === 'floor' || s === 'overflow' ? 'map' : s === 'daily' ? dailyFrom.current : s === 'warmup' ? warmFrom.current : s === 'custom' ? 'maker' : s === 'climb' ? 'overflow' : 'title'); return true; }), [], @@ -335,7 +386,7 @@ export default function App() { ? themeForFloor(safeIndex + 1, tower) : screen === 'climb' || screen === 'overflow' ? themeForOverflow(overflow.run ? overflow.run.floor : 1) - : screen === 'daily' || screen === 'custom' + : screen === 'daily' || screen === 'warmup' || screen === 'custom' ? 'daily' : 'title', ); @@ -355,6 +406,7 @@ export default function App() { onSettings={() => setSettings(true)} daily={daily} onDaily={(boss) => openDaily('title', dateKey(), boss)} + warmup={warmupOpen(comeback, progress) ? { best: comeback.warm[dateKey()] ?? 0, onOpen: () => openWarmup('title') } : undefined} onLocker={openLocker} lockerNew={rewards.hasNew} onMaker={MAKER ? () => setScreen('maker') : undefined} @@ -420,6 +472,7 @@ export default function App() { onHome={() => setScreen('title')} daily={daily} onDaily={(boss) => openDaily('map', dateKey(), boss)} + warmup={warmupOpen(comeback, progress) ? { best: comeback.warm[dateKey()] ?? 0, onOpen: () => openWarmup('map') } : undefined} onArchive={() => setArchive(true)} onLocker={openLocker} lockerNew={rewards.hasNew} @@ -470,6 +523,31 @@ export default function App() { ); } + if (screen === 'warmup' && warmFloor) { + const { date, level: warm } = warmFloor; + return ( + <> + setScreen(warmFrom.current)} + custom={{ + back: t('Warm-up'), + title: t('Warm-up'), + onClear: (_c, _s, stars) => + clearWarmup(date, stars) ? t('+1 hint for the tower. A new warm-up arrives tomorrow.') : t('A new warm-up arrives tomorrow.'), + }} + /> + {overlays} + {elevator} + + ); + } if (screen === 'daily' && dailyFloor) { const { date, level: today, boss } = dailyFloor; return ( diff --git a/src/ReminderRows.tsx b/src/ReminderRows.tsx index 6a464a3..4810f6e 100644 --- a/src/ReminderRows.tsx +++ b/src/ReminderRows.tsx @@ -4,6 +4,7 @@ import { useState } from 'react'; import { fx } from './audio/feedback'; import { hourLabel, loadReminder, remindersAvailable, setReminder } from './reminder'; import { t } from './i18n'; +import { cancelNudge, loadComeback } from './comeback'; const HOURS = Array.from({ length: 24 }, (_, h) => h); @@ -38,6 +39,35 @@ export function ReminderRows() { )}

{note || t("When the day's puzzle is ready, unless you've played.")}

+ ); } + +/** The one come-back reminder, while it's still waiting (src/comeback.ts). Switching it off ends it for good. */ +function NudgeRow() { + const [waiting, setWaiting] = useState(() => { + const s = loadComeback(); + return s.nudge && !s.done; + }); + if (!waiting) return null; + return ( + <> + +

{t("One reminder, only on a day you don't play. It won't repeat.")}

+ + ); +} diff --git a/src/TitleScreen.tsx b/src/TitleScreen.tsx index 000fdcc..56e9e31 100644 --- a/src/TitleScreen.tsx +++ b/src/TitleScreen.tsx @@ -29,6 +29,8 @@ interface Props { onSettings(): void; daily: DailyState; onDaily(boss?: boolean): void; + /** Today's warm-up, for players who haven't reached the daily yet. */ + warmup?: { best: number; onOpen(): void }; onLocker(): void; /** The floor maker, when it's switched on. */ onMaker?(): void; @@ -64,7 +66,7 @@ function BigBot({ poked }: { poked: boolean }) { ); } -export function TitleScreen({ levels, towerLabel, progress, booted, onBooted, onPlay, onTower, onSettings, daily, onDaily, onLocker, lockerNew, onMaker }: Props) { +export function TitleScreen({ levels, towerLabel, progress, booted, onBooted, onPlay, onTower, onSettings, daily, onDaily, warmup, onLocker, lockerNew, onMaker }: Props) { const [settled, setSettled] = useState(() => booted || reducedMotion()); const [poked, setPoked] = useState(false); const [candy, setCandy] = useColourful(); @@ -151,7 +153,7 @@ export function TitleScreen({ levels, towerLabel, progress, booted, onBooted, on {t('Tower map')} ★ {stars} · {t('{n} / {total} floors', { n: cleared, total: ids.length })} )} - {!fresh && !DEMO && } + {!fresh && !DEMO && } {!fresh && !DEMO && onMaker && ( + ); + } if (!open) { return ( )} + {nudgeNote &&

{nudgeNote}

} + {askNudge && shown >= 3 && ( +
+

{t('Nice start! Want one reminder tomorrow, in case you forget to come back?')}

+
+ + +
+
+ )} {askReminder && shown >= 3 && (

{t("Want a reminder when tomorrow's puzzle is ready?")}

diff --git a/src/i18n/fr/ui.json b/src/i18n/fr/ui.json index 48c7257..a8d810e 100644 --- a/src/i18n/fr/ui.json +++ b/src/i18n/fr/ui.json @@ -1167,5 +1167,28 @@ "For a new phone. Replaces the progress here.": "Pour un nouveau téléphone. Remplace la progression d'ici.", "Can't reach the store": "Impossible de joindre la boutique", "Check your connection, then try again.": "Vérifie ta connexion, puis réessaie.", - "No floors yet": "Aucun étage pour l'instant" + "No floors yet": "Aucun étage pour l'instant", + "Warm-up": "Échauffement", + "+1 hint for the tower. A new warm-up arrives tomorrow.": "+1 indice pour la tour. Un nouvel échauffement arrive demain.", + "A new warm-up arrives tomorrow.": "Un nouvel échauffement arrive demain.", + "Come-back reminder": "Rappel de retour", + "One reminder, only on a day you don't play. It won't repeat.": "Un seul rappel, seulement un jour où tu ne joues pas. Il ne se répète pas.", + "PATCH saved you a warm-up": "PATCH t'a gardé un échauffement", + "Floor {n} giving you trouble? A quick warm-up puzzle earns you a free hint.": "L'étage {n} te donne du fil à retordre ? Un petit casse-tête d'échauffement te rapporte un indice gratuit.", + "A two-minute puzzle is waiting, and Floor {n} is right where you left it.": "Un casse-tête de deux minutes t'attend, et l'étage {n} est là où tu l'as laissé.", + "Warm-up puzzle": "Échauffement", + "a quick puzzle that earns a hint": "un petit casse-tête qui rapporte un indice", + "Daily challenge opens after Floor {n}": "Défi du jour après l'étage {n}", + "New today": "Nouveau", + "Quick puzzle · earns a hint": "Rapide · rapporte un indice", + "Forward walks on level ground. Where the floor steps up or down, use jump.": "Avancer marche sur un sol plat. Là où le sol monte ou descend d'une marche, utilise sauter.", + "Turns spin LoopBot on the spot. Walk to the corner, turn, then keep walking.": "Les virages font pivoter LoopBot sur place. Marche jusqu'au coin, tourne, puis continue.", + "There is {n} turn.": "Il y a {n} virage.", + "There are {n} turns.": "Il y a {n} virages.", + "Watch for {n} jump.": "Attention à {n} saut.", + "Watch for {n} jumps.": "Attention à {n} sauts.", + "Quick warm-up before the climb. Clear it and I'll send you a hint for the tower.": "Petit échauffement avant la montée. Réussis-le et je t'envoie un indice pour la tour.", + "Deal. If you don't drop by tomorrow, I'll send one reminder. Just one.": "Marché conclu. Si tu ne passes pas demain, je t'envoie un rappel. Un seul.", + "Nice start! Want one reminder tomorrow, in case you forget to come back?": "Beau départ ! Tu veux un rappel demain, au cas où tu oublierais de revenir ?", + "Yes, just one": "Oui, un seul" } diff --git a/src/styles.css b/src/styles.css index 16fa354..1b8f33d 100644 --- a/src/styles.css +++ b/src/styles.css @@ -2378,6 +2378,33 @@ button.set-row { .daily-btn.shake { animation: shake 0.42s ease; } +/* The warm-up: the daily's spot for players below Floor 11 (src/comeback.ts) */ +.daily-btn.warmup-btn { + background: linear-gradient(100deg, rgba(90, 209, 164, 0.18), rgba(35, 38, 58, 0.9) 60%); + border-color: rgba(90, 209, 164, 0.5); +} +.daily-btn.warmup-btn.done { + background: rgba(35, 38, 58, 0.85); + border-color: var(--line); +} +.warmup-icon { + flex: 0 0 26px; + height: 26px; + border-radius: var(--r-sm); + display: grid; + place-items: center; + background: rgba(90, 209, 164, 0.2); + color: var(--good); +} +.warmup-btn .daily-sub { + flex-direction: column; + align-items: flex-start; + gap: 0; +} +.warmup-btn .daily-sub > span:last-child { + font-weight: 500; + opacity: 0.8; +} .title-daily { animation: title-pop 0.4s cubic-bezier(0.3, 1.5, 0.5, 1) 1.4s both; }