Your rival is offline. The game continues; they have{' '}
{formatTime(state.rival.returnWithinMs - (Date.now() - receivedAt))}
{' '}
to come back before the game ends.
Choose a {state.digits}-digit number for your rival
Each digit can be used only once.
{you.secretChosen && (
Your rival will search for {you.secretForRival}
)}
{rival?.secretChosen ? 'Rival has chosen your number.' : 'Rival is choosing your number…'}
>
);
}
function PlayingPanel({ state, busy, onSubmit }) {
const { you, rival } = state;
const roundBased = state.type !== 'TIME_CHALLENGE';
let status;
if (roundBased) {
if (state.waitingForRival) status = Waiting for your rival's guess…;
else if (rival && rival.attempts >= state.round) status = Your rival has guessed. Your turn!;
else status = 'Make your guess.';
} else if (you.found) {
status = (
You found it in {you.attempts} turns ({formatTime(you.timeMs)}), score {you.score}. Waiting for your rival to
finish…
);
} else {
status = 'Find the number as fast as you can!';
}
return (
<>
)}
>
);
}
function ResultPanel({ state, onBack }) {
const { you, rival, outcome, endReason, youLeft } = state;
const banner = {
WIN: ['You Won!', 'text-emerald-400'],
LOSE: ['You Lost', 'text-rose-400'],
DRAW: ['Draw', 'text-amber-300'],
}[outcome] || ['Game Closed', 'text-neutral-300'];
let reason = '';
if (endReason === 'PLAYER_LEFT')
reason = youLeft
? 'You aborted the game or did not come back in time.'
: 'Your rival aborted the game or did not come back in time.';
else if (state.type === 'TIME_CHALLENGE') reason = 'Both players found the number.';
else reason = you.found && rival?.found ? 'Both players found their number in the same round.' : 'A number was found.';
const rows = [
['Number to find', (p) => {p?.numberToFind ?? '-'}],
['Found', (p) => (p?.found ? '✔' : '✘')],
['Turns', (p) => p?.attempts ?? '-'],
['Time', (p) => formatTime(p?.timeMs)],
['Score', (p) => {p?.score ?? '-'}],
];
return (
{banner[0]}
{reason}
{rival && (
You
Rival
{rows.map(([label, render]) => (
{label}
{render(you)}
{render(rival)}
))}
)}
Score = 1000 × digits − 100 × turns − 2 × seconds (min 100 if found, 0 if not found).
);
}
function History({ title, history }) {
const items = [...history].reverse();
return (