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
29 changes: 25 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { initMusic, setMusicTheme, themeForFloor, themeForOverflow } from './aud
import { useRewards } from './rewards/useRewards';
import { Locker } from './rewards/Locker';
import { Toasts } from './rewards/Toasts';
import { applyLookCss, loadLook } from './rewards/looks';
import { GiftCard } from './rewards/GiftCard';
import { giftDue, markGiftOpened } from './rewards/gift';
import { applyLookCss, loadLook, saveLook } from './rewards/looks';
import type { Look } from './rewards/looks';
import { refreshReminders } from './reminder';
import { reducedMotion } from './fx/confetti';
Expand Down Expand Up @@ -298,9 +300,12 @@ export default function App() {
const level = levels[safeIndex];
/** Leaving a tower floor: play the band's story beat first if it's due. */
const leaveFloor = (next: () => void) => {
const due = interludeAfter(safeIndex + 1, (progress.stars[level.id] ?? 0) > 0, undefined, tower);
if (due) setBeat({ beat: due, then: next });
else next();
const cleared = (progress.stars[level.id] ?? 0) > 0;
// PATCH's first gift opens after Floor 3 (and after any story beat, though Floor 3 has none)
const then = giftDue(tower, safeIndex + 1, cleared) ? () => setGift({ then: next }) : next;
const due = interludeAfter(safeIndex + 1, cleared, undefined, tower);
if (due) setBeat({ beat: due, then });
else then();
};
// Leaving one of the first floors for the map without ever clearing it asks, once, what stopped
// them (src/survey). Only right as they leave, by the button or Android Back; never on a later launch.
Expand All @@ -321,6 +326,8 @@ export default function App() {
const [locker, setLocker] = useState(false);
// A story beat waiting to play before the next screen (PATCH's radio call, or the ending).
const [beat, setBeat] = useState<{ beat: Beat; then: () => void } | null>(null);
// The Floor 3 gift card, waiting to show before the next screen.
const [gift, setGift] = useState<{ then: () => void } | null>(null);
useEffect(() => applyLookCss(look), [look]);
const openLocker = () => {
setLocker(true);
Expand All @@ -339,6 +346,20 @@ export default function App() {
}}
/>
)}
{gift && (
<GiftCard
look={look}
onWear={(l) => {
saveLook(l);
setLook(l);
}}
onDone={() => {
markGiftOpened();
setGift(null);
gift.then();
}}
/>
)}
{locker && <Locker stats={rewards.stats} earned={rewards.earned} look={look} onLook={setLook} onClose={() => setLocker(false)} />}
<Toasts toasts={rewards.toasts} onDone={rewards.dismissToast} />
</>
Expand Down
59 changes: 55 additions & 4 deletions src/TowerMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import './fractal.css';
import './precinct.css';
import { msg, t, t as tr, tn } from './i18n';
import { flavourOf } from './colourful';
import { GIFT_FLOOR, giftOpened } from './rewards/gift';
import './goals.css';

interface Props {
levels: LevelFile[];
Expand Down Expand Up @@ -97,6 +99,14 @@ const BAND_NAMES: Record<string, string> = {
watchtower: msg('The Watchtower'),
};

/** What each of Tower 1's bands teaches, shown on the next band's sign so there's always something to climb toward. */
const BAND_NEW: Record<string, string> = {
maintenance: msg('New: loops'),
workshop: msg('New: functions'),
control: msg('New: if and while'),
rooftop: msg('New: typed code'),
};

/** What lies under each tower, shown at the foot of its map. */
const GROUND: Record<number, string> = { 1: msg('Sub-basement'), 2: msg('Ice cellar'), 3: msg('Old cistern'), 4: msg('River vault'), 5: msg('Dry dock'), 6: msg('Twin vault'), 7: msg('Root crypt'), 8: msg('Impound lot') };

Expand Down Expand Up @@ -354,6 +364,13 @@ export function TowerMap({ levels, tower, towers, onTowerPick, progress, current
// The furthest open floor you haven't cleared yet: what "Continue" plays.
const firstOpen = ids.findIndex((id, i) => isUnlocked(progress, ids, i) && !(progress.stars[id] ?? 0));
const target = firstOpen === -1 ? current : firstOpen;
const bands = bandsOf(levels);
// The band after the one you're climbing glows, with what it teaches: the next thing to reach.
const hereBand = bands.findIndex((b) => target >= b.first && target <= b.last);
const nextBand = firstOpen === -1 || hereBand === -1 ? null : (bands[hereBand + 1]?.key ?? null);
// Once a tower is cleared, the roof points at the next one.
const nextTower = cleared === ids.length ? pickable(towers).find((x) => x.n > tower) : undefined;
const gift = tower === 1 && !giftOpened() && !(progress.stars[ids[GIFT_FLOOR - 1]] ?? 0) ? GIFT_FLOOR - 1 : -1;

// Floors opened since the last visit get an unlock animation, once.
const [seen] = useState(() => readSeen(tower));
Expand Down Expand Up @@ -448,14 +465,34 @@ export function TowerMap({ levels, tower, towers, onTowerPick, progress, current
</button>
)}
<div className="tower-scroll">
{tower === 1 && cleared < ids.length && !DEMO && (
<p className="roof-sign roof-vanta">
<span className="roof-vanta-eye" aria-hidden="true" />
{t('VANTA is waiting on the roof')}
</p>
)}
{nextTower && (
<button
type="button"
className="roof-sign roof-next"
style={lightVars(TOWER_LIGHT[nextTower.n] ?? TOWER_LIGHT[1])}
onClick={() => {
if (!towerUnlocked(nextTower)) return lockedTower(nextTower);
fx.tap();
onTowerPick(nextTower.n);
}}
>
{t('Next tower: {name}', { name: tr(nextTower.name) })} <Icon name="chevron" size={16} />
</button>
)}
<div className="tower-roof" aria-hidden="true">
<span className="beacon" />
</div>
{DEMO && <div className="tower-band demo-more">{t('Floors 11 to 50 · in the full game')}</div>}
{bandsOf(levels)
{[...bands]
.reverse()
.map((band) => (
<section key={band.key} className={`tower-section band-${band.key}`} data-flavour={flavourOf(band.key)}>
<section key={band.key} className={`tower-section band-${band.key}${band.key === nextBand ? ' next-band' : ''}`} data-flavour={flavourOf(band.key)}>
<div className="tower-band">
{t(BAND_NAMES[band.key] ?? band.key)} · {t('Floors {first} to {last}', { first: band.first + 1, last: band.last + 1 })}
</div>
Expand All @@ -477,6 +514,8 @@ export function TowerMap({ levels, tower, towers, onTowerPick, progress, current
boss ? 'boss' : '',
here ? 'current' : '',
open && fresh(i) ? 'fresh' : '',
open && !stars && i === target ? 'next-up' : '',
i === gift ? 'gift-floor' : '',
shaking === i ? 'shake' : '',
]
.filter(Boolean)
Expand All @@ -493,16 +532,21 @@ export function TowerMap({ levels, tower, towers, onTowerPick, progress, current
onPick(i);
}}
aria-label={
open
(open
? here
? tn(stars, 'Floor {floor}, {title}, {n} star, you are here', 'Floor {floor}, {title}, {n} stars, you are here', { floor: i + 1, title: l.title })
: tn(stars, 'Floor {floor}, {title}, {n} star', 'Floor {floor}, {title}, {n} stars', { floor: i + 1, title: l.title })
: t('Floor {n}, locked', { n: i + 1 })
: t('Floor {n}, locked', { n: i + 1 })) + (i === gift ? `. ${t('Clear it to unlock a gift from PATCH')}` : '')
}
>
<span className="tf-num">{i + 1}</span>
{here && <MiniBot />}
<span className="tf-title">{open ? l.title : t('Locked')}</span>
{i === gift && (
<span className="tf-gift" aria-hidden="true">
<Icon name="gift" size={18} />
</span>
)}
{open ? (
<span className="tf-stars" aria-hidden="true">
{[1, 2, 3].map((s) => (
Expand All @@ -522,6 +566,13 @@ export function TowerMap({ levels, tower, towers, onTowerPick, progress, current
);
})}
</ol>
{band.key === nextBand && (
<p className="next-gate">
<span className="next-chip">{t('Up next')}</span>
<span className="next-name">{t(BAND_NAMES[band.key] ?? band.key)}</span>
{tower === 1 && BAND_NEW[band.key] && <span className="next-new">{t(BAND_NEW[band.key])}</span>}
</p>
)}
</section>
))}
<div className="tower-ground">{t(GROUND[tower] ?? GROUND[1])}</div>
Expand Down
9 changes: 9 additions & 0 deletions src/editor/ResultsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { burst, reducedMotion, stop } from '../fx/confetti';
import { DEMO } from '../demo';
import { shortDate } from '../daily';
import { msg, t, tn } from '../i18n';
import { earlyGoal } from '../rewards/gift';

interface Props {
floorNumber: number;
Expand Down Expand Up @@ -112,6 +113,8 @@ export function ResultsCard({ floorNumber, tower = 1, floorCount, earned, prevBe
setReminderNote(on ? t('Reminder set for {time}. Change it in Settings.', { time: hourLabel(DEFAULT_HOUR) }) : t('Notifications are off for LoopBot. You can allow them in your phone settings.'));
};
const title = custom ? t('Your floor') : overflow ? t('Overflow · Floor {n}', { n: overflow.floor }) : daily ? (daily.boss ? t('Sunday boss · {date}', { date: shortDate(daily.date) }) : t('Daily · {date}', { date: shortDate(daily.date) })) : t('Floor {n}', { n: floorNumber });
// Tower 1's first floors point at the next thing to aim for: a gift, PATCH's call, loops.
const goal = !daily && !custom && !overflow ? earlyGoal(tower, floorNumber, prevBest === 0, DEMO) : null;
const tip =
earned === 3
? null
Expand Down Expand Up @@ -175,6 +178,12 @@ export function ResultsCard({ floorNumber, tower = 1, floorCount, earned, prevBe
</div>
{tip && !custom?.note && <p className="tip">{tip}</p>}
{outro && <p className="story">{outro}</p>}
{goal && (
<p className={`results-goal goal-${goal.icon}${shown >= 3 ? ' in' : ''}`}>
<Icon name={goal.icon} size={20} />
<span>{t(goal.text, goal.vars)}</span>
</p>
)}
{!daily && shared && <p className="tip">{shared}</p>}
{custom?.note && <p className="tip">{custom.note}</p>}
{daily && <p className="tip">{shared ?? reminderNote ?? (daily.boss ? t('Same boss for everyone this Sunday. A new one arrives next week.') : t('Same puzzle for everyone today. A new one arrives at midnight.'))}</p>}
Expand Down
Loading
Loading