원카드: 카드 내기와 원카드 외치기 분리(내면서 외치기 없앰), 잡기 전 보호 시간(1~3초, 기본 2초), 컴퓨터도 사람처럼 늦게 외치고 잡기, 한 턴 시간 무제한, 원카드 보너스 옵션
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -279,7 +279,8 @@ describe('특수 카드 (§5.2 B·C)', () => {
|
||||
|
||||
test('lastCardRule = joker: [조커, ♥5] → ♥5 leaves the joker, which may not be played as the last card', () => {
|
||||
let s = rig(make({}, ['A', 'B']), { hands: { A: ['JB', 'H5'], B: ['H9', 'S9', 'C9'] }, discard: ['H8'] });
|
||||
s = play(s, 'A', ['H5'], { declareOneCard: true });
|
||||
s = play(s, 'A', ['H5']);
|
||||
s = act(s, 'A', { type: 'declareOneCard' });
|
||||
s = play(s, 'B', ['H9']);
|
||||
expect(reject(s, 'A', { type: 'play', cardIds: ['JB'] })).toBe('마지막 카드로 조커는 낼 수 없어요.');
|
||||
expect(oneCard.view(s, 'A').my!.legalCardIds).toEqual([]);
|
||||
@@ -317,7 +318,9 @@ describe('원카드 선언 (§5.3)', () => {
|
||||
test('caught: B presses first → A takes the penalty (1장) and the window closes', () => {
|
||||
let s = play(setupOne(), 'A', ['H5']);
|
||||
expect(s.oneCardWindow).toMatchObject({ player: 'A', declared: false });
|
||||
expect(oneCard.activePlayers(s).sort()).toEqual(['A', 'B', 'C']);
|
||||
// The game waits on A's call (and B's turn); catching is open to anyone but never awaited.
|
||||
expect(oneCard.activePlayers(s).sort()).toEqual(['A', 'B']);
|
||||
expect(oneCard.legalActions!(s, 'C')).toEqual([{ type: 'declareOneCard' }]);
|
||||
const out = actE(s, 'B', { type: 'declareOneCard' });
|
||||
s = out.state;
|
||||
expect(s.hands.A).toHaveLength(2);
|
||||
@@ -335,13 +338,48 @@ describe('원카드 선언 (§5.3)', () => {
|
||||
expect(JSON.stringify(s)).toBe(before);
|
||||
});
|
||||
|
||||
test('play with declareOneCard: true cannot be caught; autoDeclare does it for everyone', () => {
|
||||
const s = play(setupOne(), 'A', ['H5'], { declareOneCard: true });
|
||||
expect(reject(s, 'B', { type: 'declareOneCard' })).not.toBeNull();
|
||||
test('calling is its own action: a play never calls (an old client flag is dropped); only autoDeclare does', () => {
|
||||
const parsed = oneCard.actionSchema.parse({ type: 'play', cardIds: ['H5'], declareOneCard: true }) as Record<string, unknown>;
|
||||
expect(parsed.declareOneCard).toBeUndefined();
|
||||
const s = act(setupOne(), 'A', parsed as OneCardAction);
|
||||
expect(s.oneCardWindow).toMatchObject({ player: 'A', declared: false });
|
||||
expect(reject(s, 'B', { type: 'declareOneCard' })).toBeNull();
|
||||
// No "play and call" variants for the bots / the random playouts either.
|
||||
const two = setupOne();
|
||||
expect(oneCard.legalActions!(two, 'A').some((a) => 'declareOneCard' in a)).toBe(false);
|
||||
expect(reject(two, 'A', { type: 'declareOneCard' })).toBe('지금은 원카드를 외칠 때가 아니에요.');
|
||||
const auto = play(setupOne({ autoDeclare: true }), 'A', ['H5']);
|
||||
expect(auto.oneCardWindow?.declared).toBe(true);
|
||||
});
|
||||
|
||||
test('protection time: only the owner may call during the first oneCardGrace seconds, then anyone may catch', () => {
|
||||
const s = play(setupOne(), 'A', ['H5']);
|
||||
const opened = s.oneCardWindow!.openedAt!;
|
||||
expect(opened).toBe(clock);
|
||||
const at = (p: string, now: number) => {
|
||||
const v = oneCard.validate(s, p, { type: 'declareOneCard' }, { now });
|
||||
return v.ok ? null : v.reason;
|
||||
};
|
||||
expect(at('A', opened)).toBeNull();
|
||||
expect(at('B', opened + 1999)).toBe('아직 잡을 수 없어요. 1장 남은 사람이 먼저 외칠 시간이에요.');
|
||||
expect(at('B', opened + 2000)).toBeNull();
|
||||
expect(oneCard.view(s, 'B').oneCardWindow).toEqual({ player: 'A', declared: false, seq: s.seq, openedAt: opened, catchFrom: opened + 2000 });
|
||||
const quick = play(setupOne({ oneCardGrace: 1 }), 'A', ['H5']);
|
||||
expect(oneCard.validate(quick, 'C', { type: 'declareOneCard' }, { now: quick.oneCardWindow!.openedAt! + 1000 }).ok).toBe(true);
|
||||
});
|
||||
|
||||
test('oneCardBonus: calling first makes everyone else take 1 card', () => {
|
||||
let s = play(setupOne({ oneCardBonus: true }), 'A', ['H5']);
|
||||
const out = actE(s, 'A', { type: 'declareOneCard' });
|
||||
s = out.state;
|
||||
expect([s.hands.A!.length, s.hands.B!.length, s.hands.C!.length]).toEqual([1, 3, 3]);
|
||||
expect(s.log.filter((e) => e.t === 'draw' && e.why === 'bonus').map((e) => ('p' in e ? e.p : ''))).toEqual(['B', 'C']);
|
||||
expect(s.current).toBe('B');
|
||||
// Off by default.
|
||||
const plain = act(play(setupOne(), 'A', ['H5']), 'A', { type: 'declareOneCard' });
|
||||
expect(plain.hands.B).toHaveLength(2);
|
||||
});
|
||||
|
||||
test('classic window lifetime and the colour-card rule (closes on the next player’s first action)', () => {
|
||||
let s = rig(make({}, ['A', 'B', 'C']), { hands: { A: ['H5', 'C9'], B: ['H9', 'S10', 'S4'], C: ['H10', 'D10', 'S3'] }, discard: ['H8'] });
|
||||
s = play(s, 'A', ['H5']);
|
||||
@@ -591,6 +629,17 @@ describe('색깔 카드 (§5.6)', () => {
|
||||
// ---------------------------------------------------------------- timers, leaving
|
||||
|
||||
describe('시간 초과, 연결 끊김, 나가기 (§8.5)', () => {
|
||||
test('turnSeconds null (무제한): no turn clock, no +4 clock; away players still get 5 s; the round pause stays', () => {
|
||||
const s = rig(make({ turnSeconds: null }), { hands: { A: ['H9', 'C4'], B: ['S9'] }, discard: ['H5'] });
|
||||
expect(oneCard.deadline!(s)).toBeNull();
|
||||
expect(oneCard.view(s, 'A').deadlineTotalMs).toBe(0);
|
||||
s.away.A = true;
|
||||
expect(oneCard.deadline!(s)).toBe(s.turnStartedAt + 5000);
|
||||
let u = rig(make({ mode: 'uno-style', unoWild4Rule: 'challenge', turnSeconds: null }), { hands: { A: ['F1', 'G1a'], B: ['Y1a'], C: ['Y3a'] }, discard: ['R5a'] });
|
||||
u = play(u, 'A', ['F1'], { chooseColor: 'G' });
|
||||
expect(oneCard.deadline!(u)).toBeNull();
|
||||
});
|
||||
|
||||
test('timeout while attacked → takes the attack; afterDraw → pass; wild4Response → accept', () => {
|
||||
let s = rig(make(), { hands: { A: ['H2', 'C4'], B: ['S2', 'S9'], C: ['D9'] }, discard: ['H5'] });
|
||||
s = play(s, 'A', ['H2']);
|
||||
@@ -807,7 +856,7 @@ function fastPlayout(players: PlayerId[], options: OneCardOptions, seed: RngStat
|
||||
const PRESETS: Record<'classic' | 'uno-style', Partial<OneCardOptions>[]> = {
|
||||
classic: [
|
||||
{},
|
||||
{ voluntaryDraw: false, multiPlay: true },
|
||||
{ voluntaryDraw: false, multiPlay: true, oneCardBonus: true, turnSeconds: null },
|
||||
{ kEffect: 'skip-two', qInTwoPlayer: 'as-skip', lastCardRule: 'special', afterJoker: 'any', threeDefense: 'off' },
|
||||
{ endCondition: 'last-standing', bankruptLimit: 15, handSize: 5, deckCount: 2, playAfterDraw: 'on' },
|
||||
{ multiPlay: true, lastCardRule: 'attack', bankruptLimit: 'none', autoDeclare: true, attackColorJoker: 13, attackSpadeA: 10 },
|
||||
@@ -815,7 +864,7 @@ const PRESETS: Record<'classic' | 'uno-style', Partial<OneCardOptions>[]> = {
|
||||
'uno-style': [
|
||||
{},
|
||||
{ voluntaryDraw: false, unoWild4Rule: 'challenge' },
|
||||
{ unoStacking: true, unoWild4Rule: 'challenge', bankruptLimit: 25, voluntaryDraw: false },
|
||||
{ unoStacking: true, unoWild4Rule: 'challenge', bankruptLimit: 25, voluntaryDraw: false, oneCardBonus: true, oneCardGrace: 1 },
|
||||
{ endCondition: 'last-standing', unoWild4Rule: 'free', bankruptLimit: 18, playAfterDraw: 'off', handSize: 5 },
|
||||
{ unoTargetScore: 200, voluntaryDraw: false, bankruptLimit: 20, autoDeclare: true },
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user