할리갈리·도블·사과 게임: 뒤집기 시간 무제한·사과 게임 무제한(여기까지), 소리·움직임
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,3 +40,14 @@ test('사과 게임: 막힘 / 나감 / 끝', () => {
|
||||
s.final = { endReason: 'time', ranking: [], summary: '시간이 다 됐어요. 사과를 가장 많이 지운 사람이 이겼어요' };
|
||||
expect(helpNow(view(s, 'A'), 'A', users)).toContain('시간이 다 됐어요');
|
||||
});
|
||||
|
||||
test('사과 게임: 제한 시간 무제한 / 여기까지', () => {
|
||||
const { state: s0 } = setupGame('apple', 3, { timeLimitSec: null });
|
||||
expect(helpNow(view(s0, 'A'), 'A', users)).toContain('제한 시간은 없어요');
|
||||
const s = playing({ timeLimitSec: null });
|
||||
expect(helpNow(view(s, 'A'), 'A', users)).toContain('[여기까지 할래요]');
|
||||
expect(helpNow(view(s, null), null, users)).toContain('모두 끝냈을 때');
|
||||
s.status.A = 'done';
|
||||
s.score.A = 30;
|
||||
expect(helpNow(view(s, 'A'), 'A', users)).toContain('여기까지 했어요. 사과 30개');
|
||||
});
|
||||
|
||||
@@ -17,17 +17,20 @@ function leaders(v: AppleView, players: Record<string, PublicUser>, me: string |
|
||||
export function helpNow(v: AppleView, me: string | null, players: Record<string, PublicUser>): string {
|
||||
if (v.phase === 'ended') return `게임이 끝났어요. ${v.result?.summary ?? ''}`.trim() + '\n최종 순위에서 각자 지운 사과 개수를 볼 수 있어요.';
|
||||
const secs = v.options.timeLimitSec;
|
||||
const limit = secs % 60 === 0 ? `${secs / 60}분` : `${secs}초`;
|
||||
if (v.phase === 'countdown') return `곧 시작해요. 모두 똑같은 사과 판을 각자 풀어요. 제한 시간은 ${limit}이에요.\n${HOW}`;
|
||||
const limitLine = secs === null ? '제한 시간은 없어요. 모두 끝낼 때까지 해요.' : `제한 시간은 ${secs % 60 === 0 ? `${secs / 60}분` : `${secs}초`}이에요.`;
|
||||
if (v.phase === 'countdown') return `곧 시작해요. 모두 똑같은 사과 판을 각자 풀어요. ${limitLine}\n${HOW}`;
|
||||
const mine = v.seats.find((s) => s.id === me) ?? null;
|
||||
const lead = leaders(v, players, me);
|
||||
if (!mine) return `모두 똑같은 판을 각자 풀고 있어요. 시간이 끝났을 때 사과를 가장 많이 지운 사람이 이겨요.${lead ? `\n${lead}` : ''}`;
|
||||
const winLine = secs === null ? '모두 끝냈을 때' : '시간이 끝났을 때';
|
||||
if (!mine) return `모두 똑같은 판을 각자 풀고 있어요. ${winLine} 사과를 가장 많이 지운 사람이 이겨요.${lead ? `\n${lead}` : ''}`;
|
||||
if (mine.status === 'left') return '게임에서 나갔어요. 남은 사람들이 끝날 때까지 기다려 주세요.';
|
||||
if (mine.status === 'stuck') {
|
||||
return `내 판에는 이제 합이 10이 되는 사과 묶음이 없어요. 사과 ${mine.score}개를 지웠어요. 시간이 끝나거나 모두 막히면 순위가 나와요.${lead ? `\n${lead}` : ''}`;
|
||||
return `내 판에는 이제 합이 10이 되는 사과 묶음이 없어요. 사과 ${mine.score}개를 지웠어요. ${secs === null ? '모두 끝내면' : '시간이 끝나거나 모두 막히면'} 순위가 나와요.${lead ? `\n${lead}` : ''}`;
|
||||
}
|
||||
if (mine.status === 'done') return `여기까지 했어요. 사과 ${mine.score}개를 지웠어요. 모두 끝내면 순위가 나와요.${lead ? `\n${lead}` : ''}`;
|
||||
const lines = [HOW, '빈 칸은 합에 들어가지 않아서, 사이가 비어 있어도 멀리 있는 사과끼리 묶을 수 있어요.', `지금 내 점수는 사과 ${mine.score}개예요.`];
|
||||
if (lead) lines.push(lead);
|
||||
if (secs === null) lines.push('제한 시간이 없어요. 그만하고 싶으면 아래 [여기까지 할래요]를 두 번 눌러요.');
|
||||
lines.push(KEYS);
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/** 사과 게임 화면 (docs/games/apple.md §9). */
|
||||
import { useEffect, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent, type ReactNode } from 'react';
|
||||
import { useEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent, type ReactNode } from 'react';
|
||||
import type { AppleOptions, AppleView, SeatView } from '@bg/games/apple';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar } from '../../components/ui';
|
||||
import { useServerNow } from '../../components/TurnTimer';
|
||||
import { haptic, sounds } from '../../lib/feedback';
|
||||
import { haptic, sfx, tone } from '../../lib/feedback';
|
||||
import { socket } from '../../net/socket';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
@@ -49,7 +49,26 @@ const clock = (ms: number) => {
|
||||
const s = Math.ceil(Math.max(0, ms) / 1000);
|
||||
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`;
|
||||
};
|
||||
const limitLabel = (sec: number) => (sec % 60 === 0 ? `${sec / 60}분` : `${sec}초`);
|
||||
const limitLabel = (sec: number | null) => (sec === null ? '무제한' : sec % 60 === 0 ? `${sec / 60}분` : `${sec}초`);
|
||||
|
||||
/** Game sounds on top of the shared palette (site volume applies). */
|
||||
const apSound = {
|
||||
/** Apples popping: one rising pop per apple (up to 5), quick enough to finish while they vanish. */
|
||||
clear: (n: number) => {
|
||||
for (let i = 0; i < Math.min(5, n); i++) tone(520 + i * 110, 80, 'sine', 0.16, i * 38, { slideTo: 1100 + i * 160 });
|
||||
},
|
||||
/** Let go on a sum that is not 10: a soft "thud", no penalty. */
|
||||
miss: () => tone(230, 90, 'triangle', 0.09, 0, { slideTo: 180 }),
|
||||
/** The box being dragged just added up to 10. */
|
||||
ten: () => tone(1320, 45, 'triangle', 0.07),
|
||||
count: () => tone(660, 90, 'triangle', 0.12),
|
||||
go: () => {
|
||||
tone(988, 120, 'triangle', 0.14);
|
||||
tone(1318, 200, 'triangle', 0.12, 90);
|
||||
},
|
||||
};
|
||||
|
||||
const statusSuffix = (s: SeatView) => (s.status === 'stuck' ? ', 더 지울 사과 없음' : s.status === 'done' ? ', 여기까지 함' : s.status === 'left' ? ', 나감' : '');
|
||||
|
||||
/** Ranks by score (ties share), players who left last. */
|
||||
function ranked(seats: SeatView[]): (SeatView & { rank: number })[] {
|
||||
@@ -89,6 +108,11 @@ const CSS = `
|
||||
:root[data-theme='dark'] .ap-board { background: #3b2f22; box-shadow: var(--shadow), inset 0 0 0 3px #6b4f2a; }
|
||||
@media (prefers-color-scheme: dark) { :root[data-theme='auto'] .ap-board { background: #3b2f22; box-shadow: var(--shadow), inset 0 0 0 3px #6b4f2a; } }
|
||||
.ap-pop { animation: ap-pop .42s ease-out forwards; transform-box: fill-box; transform-origin: center; pointer-events: none; }
|
||||
.ap-burst { animation: ap-burst .45s ease-out forwards; transform-box: fill-box; transform-origin: center; pointer-events: none; }
|
||||
.ap-in { animation: ap-in .34s cubic-bezier(.3,1.5,.5,1) both; animation-delay: var(--d, 0ms); transform-box: fill-box; transform-origin: center; }
|
||||
.ap-pill b, .ap-others li b { display: inline-block; }
|
||||
.ap-over.count b { display: block; animation: ap-count .9s ease-out both; }
|
||||
.ap-stop { min-height: 40px; }
|
||||
.ap-over { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; pointer-events: none;
|
||||
border-radius: 14px; text-align: center; padding: 12px; }
|
||||
.ap-over.count { background: rgba(0,0,0,.35); color: #fff; font-size: 5rem; font-weight: 900; text-shadow: 0 3px 8px rgba(0,0,0,.5); }
|
||||
@@ -99,9 +123,12 @@ const CSS = `
|
||||
.ap-flash.ok { color: var(--success); border: 3px solid var(--success); }
|
||||
.ap-flash.bad { color: var(--text-sub); border: 3px solid var(--border); }
|
||||
.ap-keys { color: var(--text-sub); font-size: .85rem; font-weight: 600; text-align: center; margin: 0; }
|
||||
@keyframes ap-burst { 0% { transform: scale(.5); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }
|
||||
@keyframes ap-in { from { transform: scale(0); opacity: 0; } }
|
||||
@keyframes ap-count { 0% { transform: scale(1.8); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(.85); opacity: .85; } }
|
||||
@keyframes ap-pop { 0% { transform: scale(1); opacity: 1; } 40% { transform: scale(1.25); opacity: .9; } 100% { transform: scale(.2) translateY(-30px); opacity: 0; } }
|
||||
@keyframes ap-flash { 0% { opacity: 0; transform: translateX(-50%) scale(.8); } 15% { opacity: 1; transform: translateX(-50%) scale(1.05); } 70% { opacity: 1; } 100% { opacity: 0; } }
|
||||
@media (prefers-reduced-motion: reduce) { .ap-pop { animation-duration: .01s; } .ap-flash { animation: none; } }
|
||||
@media (prefers-reduced-motion: reduce) { .ap-pop { animation-duration: .01s; } .ap-flash, .ap-in, .ap-burst, .ap-over.count b { animation: none; } .ap-burst { display: none; } }
|
||||
`;
|
||||
|
||||
// ---------------------------------------------------------------- art
|
||||
@@ -125,13 +152,19 @@ function AppleDefs() {
|
||||
);
|
||||
}
|
||||
|
||||
function AppleCell({ x, y, n }: { x: number; y: number; n: number }) {
|
||||
return (
|
||||
<g transform={`translate(${x} ${y})`}>
|
||||
function AppleCell({ x, y, n, introDelay }: { x: number; y: number; n: number; introDelay?: number }) {
|
||||
const apple = (
|
||||
<>
|
||||
<use href="#ap-apple" />
|
||||
<text x="20" y="29" textAnchor="middle" fontSize="17" fontWeight="900" fill="#fff" stroke="#6b0b16" strokeWidth="0.8" paintOrder="stroke">
|
||||
{n}
|
||||
</text>
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<g transform={`translate(${x} ${y})`}>
|
||||
{/* The CSS animation goes on an inner group: it would replace the SVG translate on the outer one. */}
|
||||
{introDelay === undefined ? apple : <g className="ap-in" style={{ '--d': `${introDelay}ms` } as CSSProperties}>{apple}</g>}
|
||||
</g>
|
||||
);
|
||||
}
|
||||
@@ -185,7 +218,27 @@ function AppleBoard({ view: v, me, players, act }: BoardProps<AppleView>) {
|
||||
const seq = useRef(0);
|
||||
|
||||
const mine = v.seats.find((s) => s.id === me) ?? null;
|
||||
const canPlay = !!mine && mine.status === 'playing' && v.phase === 'playing' && !!v.cells && now < v.endsAt;
|
||||
const canPlay = !!mine && mine.status === 'playing' && v.phase === 'playing' && !!v.cells && (v.endsAt === null || now < v.endsAt);
|
||||
const unlimited = v.endsAt === null;
|
||||
const [stopAsk, setStopAsk] = useState(false);
|
||||
// The board appearing (after the countdown, or when I open the room) pops the apples in, row by row.
|
||||
const [intro, setIntro] = useState(false);
|
||||
const hadCells = useRef<boolean | null>(null);
|
||||
useEffect(() => {
|
||||
const has = !!v.cells;
|
||||
if (hadCells.current === false && has) setIntro(true);
|
||||
hadCells.current = has;
|
||||
}, [v.cells]);
|
||||
useEffect(() => {
|
||||
if (!intro) return;
|
||||
const t = setTimeout(() => setIntro(false), 900);
|
||||
return () => clearTimeout(t);
|
||||
}, [intro]);
|
||||
useEffect(() => {
|
||||
if (!stopAsk) return;
|
||||
const t = setTimeout(() => setStopAsk(false), 3000);
|
||||
return () => clearTimeout(t);
|
||||
}, [stopAsk]);
|
||||
|
||||
// My board as I see it: the server's, minus the apples I just cleared and the server has not confirmed yet.
|
||||
const cells = useMemo(() => {
|
||||
@@ -240,17 +293,18 @@ function AppleBoard({ view: v, me, players, act }: BoardProps<AppleView>) {
|
||||
}
|
||||
if (sum !== 10) {
|
||||
if (idx.length >= 2 || fromKey) {
|
||||
apSound.miss();
|
||||
setFlash({ key: ++seq.current, ok: false, text: `합 ${sum} · 10이 아니에요` });
|
||||
say(`합이 ${sum}이에요. 딱 10이 되게 골라 주세요.`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
act({ type: 'select', ...rect });
|
||||
setGone((g) => [...g, ...idx]);
|
||||
setPops((p) => [...p, { key: ++seq.current, cells: idx.map((i) => ({ i, n: cells.charCodeAt(i) - 48 })) }]);
|
||||
setFlash({ key: ++seq.current, ok: true, text: `+${idx.length}` });
|
||||
sounds.stone();
|
||||
apSound.clear(idx.length);
|
||||
haptic(15);
|
||||
act({ type: 'select', ...rect });
|
||||
say(`사과 ${idx.length}개를 지웠어요.`);
|
||||
};
|
||||
|
||||
@@ -316,9 +370,24 @@ function AppleBoard({ view: v, me, players, act }: BoardProps<AppleView>) {
|
||||
}
|
||||
};
|
||||
|
||||
const left = Math.max(0, v.endsAt - Math.max(now, v.countdownEndsAt));
|
||||
const left = v.endsAt === null ? null : Math.max(0, v.endsAt - Math.max(now, v.countdownEndsAt));
|
||||
const countdown = v.phase === 'countdown' ? Math.max(1, Math.ceil((v.countdownEndsAt - now) / 1000)) : 0;
|
||||
const sumState = !sel || sel.idx.length === 0 ? 'idle' : sel.sum === 10 ? 'ok' : sel.sum > 10 ? 'over' : 'under';
|
||||
// Sounds that follow the clock and the state: 3·2·1, start, last 10 seconds, "10!" while dragging, finished.
|
||||
const lastSec = v.phase === 'playing' && left !== null && left > 0 && left <= 10_000 ? Math.ceil(left / 1000) : 0;
|
||||
const heard = useRef({ countdown: 0, lastSec: 0, sum: 'idle', status: mine?.status ?? null });
|
||||
useEffect(() => {
|
||||
const was = heard.current;
|
||||
if (countdown !== was.countdown) {
|
||||
if (countdown > 0) apSound.count();
|
||||
else if (was.countdown > 0 && v.phase === 'playing') apSound.go();
|
||||
}
|
||||
if (lastSec && lastSec !== was.lastSec) sfx.tick();
|
||||
if (sumState === 'ok' && was.sum !== 'ok') apSound.ten();
|
||||
const st = mine?.status ?? null;
|
||||
if (st !== was.status && was.status === 'playing' && (st === 'stuck' || st === 'done') && v.phase === 'playing') sfx.good();
|
||||
heard.current = { countdown, lastSec, sum: sumState, status: st };
|
||||
});
|
||||
const others = ranked(v.seats);
|
||||
|
||||
// Selection rectangle in display coordinates.
|
||||
@@ -348,12 +417,21 @@ function AppleBoard({ view: v, me, players, act }: BoardProps<AppleView>) {
|
||||
<div className="ap">
|
||||
<style>{CSS}</style>
|
||||
<div className="ap-top">
|
||||
<span className={`ap-pill${v.phase === 'playing' && left <= 10_000 ? ' warn' : ''}`} role="timer" aria-label={`남은 시간 ${Math.floor(Math.ceil(left / 1000) / 60)}분 ${Math.ceil(left / 1000) % 60}초`}>
|
||||
⏱ {clock(left)}
|
||||
</span>
|
||||
{left === null ? (
|
||||
<span className="ap-pill" aria-label="제한 시간 없음">
|
||||
⏱ 무제한
|
||||
</span>
|
||||
) : (
|
||||
<span className={`ap-pill${v.phase === 'playing' && left <= 10_000 ? ' warn' : ''}`} role="timer" aria-label={`남은 시간 ${Math.floor(Math.ceil(left / 1000) / 60)}분 ${Math.ceil(left / 1000) % 60}초`}>
|
||||
⏱ {clock(left)}
|
||||
</span>
|
||||
)}
|
||||
{mine && (
|
||||
<span className="ap-pill" aria-label={`내 점수 사과 ${mine.score}개`}>
|
||||
🍎 <b>{mine.score}</b>
|
||||
🍎{' '}
|
||||
<b key={mine.score} className={mine.score ? 'anim-bump' : undefined}>
|
||||
{mine.score}
|
||||
</b>
|
||||
</span>
|
||||
)}
|
||||
{mine && v.phase !== 'ended' && (
|
||||
@@ -365,11 +443,13 @@ function AppleBoard({ view: v, me, players, act }: BoardProps<AppleView>) {
|
||||
{v.seats.length > 1 && (
|
||||
<ol className="ap-others" aria-label="점수">
|
||||
{others.map((s) => (
|
||||
<li key={s.id} data-me={s.id === me} data-out={s.status === 'left'} aria-label={`${s.rank}등 ${nick(players, s.id)}${s.id === me ? '(나)' : ''} 사과 ${s.score}개${s.status === 'stuck' ? ', 더 지울 사과 없음' : s.status === 'left' ? ', 나감' : ''}`}>
|
||||
<li key={s.id} data-me={s.id === me} data-out={s.status === 'left'} aria-label={`${s.rank}등 ${nick(players, s.id)}${s.id === me ? '(나)' : ''} 사과 ${s.score}개${statusSuffix(s)}`}>
|
||||
<Avatar user={userOf(players, s.id)} size={20} />
|
||||
<span>{s.id === me ? '나' : nick(players, s.id)}</span>
|
||||
<b>{s.score}</b>
|
||||
{s.status === 'stuck' && <span aria-hidden>✔</span>}
|
||||
<b key={s.score} className={s.score ? 'anim-bump' : undefined}>
|
||||
{s.score}
|
||||
</b>
|
||||
{(s.status === 'stuck' || s.status === 'done') && <span aria-hidden>✔</span>}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
@@ -403,14 +483,17 @@ function AppleBoard({ view: v, me, players, act }: BoardProps<AppleView>) {
|
||||
const n = ch.charCodeAt(0) - 48;
|
||||
if (n <= 0) return null;
|
||||
const [dr, dc] = toDisp([Math.floor(i / COLS), i % COLS]);
|
||||
return <AppleCell key={i} x={dc * S} y={dr * S} n={n} />;
|
||||
return <AppleCell key={i} x={dc * S} y={dr * S} n={n} introDelay={intro ? (dr + dc) * 14 : undefined} />;
|
||||
})}
|
||||
{pops.map((p) =>
|
||||
p.cells.map(({ i, n }) => {
|
||||
const [dr, dc] = toDisp([Math.floor(i / COLS), i % COLS]);
|
||||
return (
|
||||
<g key={`${p.key}-${i}`} className="ap-pop">
|
||||
<AppleCell x={dc * S} y={dr * S} n={n} />
|
||||
<g key={`${p.key}-${i}`}>
|
||||
<circle className="ap-burst" cx={dc * S + 20} cy={dr * S + 21} r={17} fill="none" stroke="#f87171" strokeWidth={4} />
|
||||
<g className="ap-pop">
|
||||
<AppleCell x={dc * S} y={dr * S} n={n} />
|
||||
</g>
|
||||
</g>
|
||||
);
|
||||
}),
|
||||
@@ -425,7 +508,7 @@ function AppleBoard({ view: v, me, players, act }: BoardProps<AppleView>) {
|
||||
)}
|
||||
{countdown > 0 && (
|
||||
<div className="ap-over count" aria-hidden>
|
||||
{countdown}
|
||||
<b key={countdown}>{countdown}</b>
|
||||
<small>합이 10이 되게 사과를 묶어요!</small>
|
||||
</div>
|
||||
)}
|
||||
@@ -434,9 +517,27 @@ function AppleBoard({ view: v, me, players, act }: BoardProps<AppleView>) {
|
||||
더 지울 수 있는 사과가 없어요! 사과 {mine.score}개 · 끝날 때까지 기다려요
|
||||
</div>
|
||||
)}
|
||||
{mine && mine.status === 'done' && v.phase === 'playing' && (
|
||||
<div className="ap-over note" role="status">
|
||||
여기까지 했어요! 사과 {mine.score}개 · 모두 끝날 때까지 기다려요
|
||||
</div>
|
||||
)}
|
||||
{mine && mine.status === 'left' && v.phase !== 'ended' && <div className="ap-over note">게임에서 나갔어요.</div>}
|
||||
{!mine && v.phase !== 'ended' && <div className="ap-over note">관전 중이에요 · 위에서 점수를 볼 수 있어요</div>}
|
||||
</div>
|
||||
{unlimited && canPlay && (
|
||||
<button
|
||||
type="button"
|
||||
className={`btn ${stopAsk ? 'btn-primary' : 'btn-secondary'} ap-stop`}
|
||||
onClick={() => {
|
||||
if (!stopAsk) return setStopAsk(true);
|
||||
setStopAsk(false);
|
||||
act({ type: 'stop' });
|
||||
}}
|
||||
>
|
||||
{stopAsk ? '한 번 더 누르면 여기까지 해요' : `여기까지 할래요 (사과 ${mine.score}개)`}
|
||||
</button>
|
||||
)}
|
||||
{!phone && mine && v.phase !== 'ended' && <p className="ap-keys">마우스로 드래그해서 합이 10이면 손을 떼요 · 키보드: 화살표 + 스페이스(시작점·끝점), Esc 취소</p>}
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
@@ -454,14 +555,14 @@ function AppleSide({ view: v, me, players }: BoardProps<AppleView>) {
|
||||
<style>{CSS}</style>
|
||||
<div className="card stack" style={{ gap: 6, padding: 12 }}>
|
||||
<strong>사과 게임{v.phase === 'ended' ? ' · 게임 끝' : ''}</strong>
|
||||
<span className="small muted">17×10 판 · 제한 시간 {limitLabel(v.options.timeLimitSec)} · 모두 같은 판</span>
|
||||
<span className="small muted">17×10 판 · 제한 시간 {limitLabel(v.options.timeLimitSec)}{v.options.timeLimitSec === null ? '(모두 끝낼 때까지)' : ''} · 모두 같은 판</span>
|
||||
<ol style={{ listStyle: 'none', margin: 0, padding: 0, display: 'grid', gap: 4 }}>
|
||||
{rows.map((s) => (
|
||||
<li
|
||||
key={s.id}
|
||||
className="row"
|
||||
style={{ gap: 6, flexWrap: 'nowrap', opacity: s.status === 'left' ? 0.55 : 1 }}
|
||||
aria-label={`${s.rank}등 ${nick(players, s.id)}${s.id === me ? '(나)' : ''}, 사과 ${s.score}개, ${s.clears}번 지움${s.status === 'stuck' ? ', 더 지울 사과 없음' : s.status === 'left' ? ', 나감' : ''}`}
|
||||
aria-label={`${s.rank}등 ${nick(players, s.id)}${s.id === me ? '(나)' : ''}, 사과 ${s.score}개, ${s.clears}번 지움${statusSuffix(s)}`}
|
||||
>
|
||||
<span aria-hidden style={{ width: 28, fontWeight: 800 }}>
|
||||
{s.rank}등
|
||||
@@ -470,7 +571,7 @@ function AppleSide({ view: v, me, players }: BoardProps<AppleView>) {
|
||||
<span style={{ flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', fontWeight: s.id === me ? 800 : 600 }} aria-hidden>
|
||||
{nick(players, s.id)}
|
||||
{s.id === me ? ' (나)' : ''}
|
||||
{s.status === 'stuck' ? ' · 다 지움' : s.status === 'left' ? ' · 나감' : ''}
|
||||
{s.status === 'stuck' ? ' · 다 지움' : s.status === 'done' ? ' · 여기까지' : s.status === 'left' ? ' · 나감' : ''}
|
||||
</span>
|
||||
<strong style={{ fontVariantNumeric: 'tabular-nums' }} aria-hidden>
|
||||
🍎 {s.score}
|
||||
@@ -514,12 +615,13 @@ function statusText(v: AppleView, me: string | null, players: Record<string, Pub
|
||||
}
|
||||
if (mine.status === 'left') return '게임에서 나갔어요';
|
||||
if (mine.status === 'stuck') return `더 지울 사과가 없어요 · 사과 ${mine.score}개 · 끝날 때까지 기다려요`;
|
||||
if (mine.status === 'done') return `여기까지 했어요 · 사과 ${mine.score}개 · 모두 끝날 때까지 기다려요`;
|
||||
return `사과 ${mine.score}개 지웠어요 · 합이 10이 되게 드래그!`;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- options
|
||||
|
||||
function Seg<T extends string | number | boolean>({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) {
|
||||
function Seg<T extends string | number | boolean | null>({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) {
|
||||
return (
|
||||
<div className="segmented" role="group" aria-label={label}>
|
||||
{options.map(([k, l]) => (
|
||||
@@ -543,10 +645,15 @@ function Options({ value: o, onChange }: OptionsProps<AppleOptions>) {
|
||||
[60, '1분'],
|
||||
[120, '2분'],
|
||||
[180, '3분'],
|
||||
[null, '무제한'],
|
||||
]}
|
||||
onChange={(timeLimitSec) => onChange({ ...o, timeLimitSec })}
|
||||
/>
|
||||
<span className="small muted">원래 게임은 2분이에요. 시간이 끝났을 때 사과를 가장 많이 지운 사람이 이겨요.</span>
|
||||
<span className="small muted">
|
||||
{o.timeLimitSec === null
|
||||
? '시간 제한 없이 각자 더 지울 사과가 없거나 [여기까지 할래요]를 누를 때까지 해요. 모두 끝나면 가장 많이 지운 사람이 이겨요.'
|
||||
: '원래 게임은 2분이에요. 시간이 끝났을 때 사과를 가장 많이 지운 사람이 이겨요.'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -559,7 +666,8 @@ function optionsSummary(o: AppleOptions): string {
|
||||
// ---------------------------------------------------------------- rules
|
||||
|
||||
function Rules({ options }: { options?: AppleOptions }) {
|
||||
const limit = limitLabel(options?.timeLimitSec ?? 120);
|
||||
const limitSec = options ? options.timeLimitSec : 120;
|
||||
const limit = limitLabel(limitSec);
|
||||
return (
|
||||
<div className="stack">
|
||||
<p>
|
||||
@@ -576,7 +684,10 @@ function Rules({ options }: { options?: AppleOptions }) {
|
||||
일어나지 않고 벌칙도 없어요. 지운 자리는 빈 칸이 되고 빈 칸은 합에 들어가지 않아서, 사이가 비면 멀리 있는 사과끼리도 묶을 수 있어요.
|
||||
</p>
|
||||
<p>
|
||||
제한 시간은 {limit}이에요. 시간이 끝나면 사과를 가장 많이 지운 사람이 이기고, 개수가 같으면 같은 순위예요. 모두 더 지울 수 있는 묶음이 없으면 조금 일찍 끝나요. 혼자서도 할 수 있어요.
|
||||
{limitSec === null
|
||||
? '이 방은 제한 시간이 없어요. 각자 더 지울 수 있는 묶음이 없거나 [여기까지 할래요]를 누르면 끝나고, 모두 끝나면 사과를 가장 많이 지운 사람이 이겨요. 개수가 같으면 같은 순위예요. 연결이 끊긴 채 오래 돌아오지 않으면 그때까지 점수로 끝낸 것으로 봐요.'
|
||||
: `제한 시간은 ${limit}이에요. 시간이 끝나면 사과를 가장 많이 지운 사람이 이기고, 개수가 같으면 같은 순위예요. 모두 더 지울 수 있는 묶음이 없으면 조금 일찍 끝나요.`}{' '}
|
||||
혼자서도 할 수 있어요.
|
||||
</p>
|
||||
<p>
|
||||
휴대폰에서는 판을 세로로 돌려서 보여 줘요. 키보드로는 화살표로 칸을 옮기고 <strong>스페이스</strong>(또는 Enter)로 시작점, 한 번 더 눌러 끝점을 정해요. <strong>Esc</strong>는 취소예요.
|
||||
|
||||
Reference in New Issue
Block a user