Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,19 @@ export default function App() {
// 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]);
// Phones keep the app suspended for days, so coming back from the background counts as a launch:
// the nudge moves on (it must not arrive on a day they opened the game), and a new day re-renders
// so today's warm-up and daily show without a restart.
const [, setToday] = useState(dateKey);
useEffect(() => {
const back = () => {
if (document.visibilityState !== 'visible') return;
setToday(dateKey());
void refreshNudge(progressRef.current);
};
document.addEventListener('visibilitychange', back);
return () => document.removeEventListener('visibilitychange', back);
}, []);
// Tapping the nudge opens the warm-up, when there is one today.
useEffect(
() =>
Expand Down
6 changes: 6 additions & 0 deletions src/editor/firstFloors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { parseReference } from '../sim/program';
import { introPalette, isIntroFloor, newCommands, nextStep, pathPreview } from './firstFloors';
import { PALETTE_ORDER } from './commands';
import type { LevelFile } from '../sim/types';
import { warmupLevel } from '../daily/warmup';

const level = (id: string) => LEVELS.find((l) => l.id === id) as LevelFile;
const commandsOf = (id: string) => LEVELS.find((l) => l.id === id)?.commands;
Expand All @@ -22,6 +23,11 @@ describe('first floors', () => {
expect(introPalette(level('t1-f06'), PALETTE_ORDER)).toEqual(PALETTE_ORDER);
});

it('gives the day-2 warm-up the same short palette (its players are on the intro floors)', () => {
expect(introPalette(warmupLevel('2026-11-25', 'turn'), PALETTE_ORDER)).toEqual(['forward', 'turn_left', 'turn_right']);
expect(introPalette(warmupLevel('2026-11-25', 'jumps'), PALETTE_ORDER)).toEqual(['forward', 'turn_left', 'turn_right', 'jump']);
});

it('marks the commands each intro floor brings in as new', () => {
expect([...newCommands('t1-f01', commandsOf)]).toEqual([]);
expect([...newCommands('t1-f02', commandsOf)].sort()).toEqual(['turn_left', 'turn_right']);
Expand Down
8 changes: 6 additions & 2 deletions src/editor/firstFloors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Runner } from '../sim/interpreter';
import { shortestActionPath } from '../sim/solver';
import { applyAction, cloneWorld, createWorld, goalsMet } from '../sim/world';
import { makeBlock } from '../sim/program';
import { isWarmupId } from '../daily/warmup';

/** Tower 1's opening floors, in order. */
export const INTRO_FLOORS = ['t1-f01', 't1-f02', 't1-f03', 't1-f04', 't1-f05'];
Expand All @@ -23,9 +24,12 @@ export function isIntroFloor(id: string): boolean {
return INTRO_FLOORS.includes(id);
}

/** On the intro floors, drop the palette commands this floor doesn't have yet. */
/**
* On the intro floors, drop the palette commands this floor doesn't have yet. The day-2 warm-up is
* for the same early players, so it gets the same short palette.
*/
export function introPalette(level: Pick<LevelFile, 'id' | 'commands'>, palette: PaletteCommand[]): PaletteCommand[] {
if (!isIntroFloor(level.id)) return palette;
if (!isIntroFloor(level.id) && !isWarmupId(level.id)) return palette;
return palette.filter((c) => (level.commands as string[]).includes(c));
}

Expand Down
4 changes: 4 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3050,6 +3050,10 @@ button.set-row {
color: var(--ink);
font: inherit;
font-size: var(--fs-input);
/* a long choice ("Automatique (Français)") shrinks instead of pushing out of the row on narrow phones */
min-width: 0;
max-width: 65%;
text-overflow: ellipsis;
}
.reminder-ask {
margin: 10px 0 4px;
Expand Down
Loading