증강 윷놀이: 이의있음!은 모두 고른 뒤 화면 전체에 크게 띄우고, 그 선택에서 모두가 고른 증강을 없앤 채 모두 새 후보로 다시 고름

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-08 02:05:51 +09:00
parent f4fb796dfe
commit 2403b6747f
5 changed files with 122 additions and 19 deletions

View File

@@ -107,15 +107,53 @@ describe('증강 윷놀이: options and selection', () => {
expect(yut.view(t, 'A').aug!.sides[1]!.augs[0]!.voided).toBe(true);
});
test('이의있음! rerolls the offers and is not kept', () => {
const s = yut.setup({ players: ['A', 'B'], options: yut.optionsSchema.parse({ augmented: true }), rng: SeededRng.fromSeed(seedN(2)), now: 0 });
s.aug!.select!.offers['0'] = ['objection', 'cat', 'fog'];
const t = act(s, 'A', { type: 'AUG_PICK', aug: 'objection' });
const offers = t.aug!.select!.offers['0']!;
expect(offers).toHaveLength(3);
expect(offers).not.toContain('objection');
expect(offers).not.toContain('cat');
expect(t.aug!.select!.left['0']).toBe(1);
test('이의있음!: kept secret until everyone has picked, then every pick is called off and everyone picks again', () => {
const s = yut.setup({ players: ['A', 'B', 'C'], options: yut.optionsSchema.parse({ augmented: true }), rng: SeededRng.fromSeed(seedN(2)), now: 0 });
s.aug!.select!.offers = { '0': ['objection', 'cat', 'fog'], '1': ['shield', 'cat', 'fog'], '2': ['tiger', 'cat', 'fog'] };
let t = act(s, 'A', { type: 'AUG_PICK', aug: 'objection' });
t = act(t, 'B', { type: 'AUG_PICK', aug: 'shield' });
// not revealed yet: no log line / popup, A just waits like anyone who picked
expect(JSON.stringify(t.log)).not.toContain('이의');
expect(t.aug!.fx.some((f) => f.kind === 'objection')).toBe(false);
expect(yut.view(t, 'C').aug!.select!.waiting).toEqual([2]);
expect(yut.view(t, 'A').aug!.select!.offers).toEqual([]);
t = act(t, 'C', { type: 'AUG_PICK', aug: 'tiger' });
// everyone picked → 이의있음!: nobody gets anything, the same selection starts over for all
expect(t.phase).toBe('aug');
expect(t.aug!.sides.every((x) => x.augs.length === 0)).toBe(true);
const sel = t.aug!.select!;
expect(sel.no).toBe(s.aug!.select!.no);
expect(sel.picks).toEqual([]);
expect(sel.left).toEqual({ '0': 1, '1': 1, '2': 1 });
for (const k of ['0', '1', '2']) {
expect(sel.offers[k]).toHaveLength(3);
expect(sel.offers[k]).not.toContain('objection');
}
const fx = t.aug!.fx.filter((f) => f.kind === 'objection');
expect(fx).toHaveLength(1);
expect(fx[0]).toMatchObject({ side: 0, aug: 'objection' });
expect(fx[0]!.text).toContain('빨강');
expect(yut.view(t, 'B').aug!.fx.some((f) => f.kind === 'objection')).toBe(true);
// the second round of picks counts normally
const pick = (st: YutState, who: string, k: string) => act(st, who, { type: 'AUG_PICK', aug: st.aug!.select!.offers[k]!.find((x) => x !== 'detective' && x !== 'delivery' && x !== 'cat')! });
t = pick(pick(pick(t, 'A', '0'), 'B', '1'), 'C', '2');
expect(t.aug!.select).toBeNull();
expect(t.aug!.sides.map((x) => x.augs.length)).toEqual([1, 1, 1]);
expect(t.aug!.sides.some((x) => x.augs.some((o) => o.id === 'objection'))).toBe(false);
});
test('이의있음! in 혼돈 mode ends that person\'s picking; a 배달 order is offered again in the redo', () => {
const s = yut.setup({ players: ['A', 'B'], options: yut.optionsSchema.parse({ augmented: true, augChaos: true }), rng: SeededRng.fromSeed(seedN(2)), now: 0 });
const sel = s.aug!.select!;
sel.offers = { '0': ['objection', 'cat', 'fog'], '1': ['shield', 'cat', 'fog'] };
sel.ordered = { '1': ['shield'] };
let t = act(s, 'A', { type: 'AUG_PICK', aug: 'objection' });
expect(t.aug!.select!.left['0']).toBe(0);
t = act(t, 'B', { type: 'AUG_PICK', aug: 'shield' });
t = act(t, 'B', { type: 'AUG_PICK', aug: t.aug!.select!.offers['1']![0]! });
expect(t.aug!.select!.left).toEqual({ '0': 2, '1': 2 });
expect(t.aug!.select!.offers['1']).toContain('shield');
expect(t.aug!.delivery['1']).toEqual([]);
});
test('간택: a 고양이 among the offers must be taken', () => {

View File

@@ -131,12 +131,14 @@ export interface AugSelect {
offers: Record<string, AugId[]>;
left: Record<string, number>;
picks: { side: SideId; id: AugId; target?: AugId }[];
/** 배달 orders this selection was made with, so an 이의있음! redo offers them again. */
ordered?: Record<string, AugId[]>;
}
/** Something the screen should show once (popup / animation); `no` increases. */
export interface AugFx {
no: number;
kind: 'win' | 'out' | 'effect' | 'flick' | 'pick' | 'bronze';
kind: 'win' | 'out' | 'effect' | 'flick' | 'pick' | 'bronze' | 'objection';
side: SideId;
aug?: AugId;
text: string;
@@ -1287,6 +1289,8 @@ function openSelection(s: YutState, ctx: Ctx): void {
const a = A(s);
const tier = selectionTier(a.selNo, a.rounds.length);
const sel: AugSelect = { no: a.selNo + 1, tier, offers: {}, left: {}, picks: [] };
const ordered = Object.entries(a.delivery).filter(([, ids]) => ids.length);
if (ordered.length) sel.ordered = Object.fromEntries(ordered.map(([k, ids]) => [k, [...ids]]));
for (const x of liveSides(s)) {
const offers = genOffers(s, x.id, tier, ctx.rng, []);
if (!offers.length) continue;
@@ -1336,9 +1340,10 @@ function applyPick(s: YutState, ctx: Ctx, side: SideId, act: AugPick): void {
const sel = a.select!;
const key = String(side);
if (act.aug === 'objection') {
log(s, ctx, { type: 'augEffect', side, aug: 'objection', text: `${nm(side)}: 이의있음! 다시 골라요` });
sel.offers[key] = genOffers(s, side, sel.tier, ctx.rng, ['objection', ...sel.offers[key]!, ...sel.picks.filter((p) => p.side === side).map((p) => p.id)]);
if (!sel.offers[key]!.length) sel.left[key] = 0;
// kept secret like any pick; when everyone is done the whole selection is called off (resolveSelection)
sel.picks.push({ side, id: 'objection' });
sel.left[key] = 0;
sel.offers[key] = [];
} else {
sel.picks.push({ side, id: act.aug, ...(act.target ? { target: act.target } : {}) });
sel.left[key]! -= 1;
@@ -1352,10 +1357,12 @@ function resolveSelection(s: YutState, ctx: Ctx): void {
const a = A(s);
const sel = a.select!;
a.select = null;
const objectors = [...new Set(sel.picks.filter((p) => p.id === 'objection').map((p) => p.side))].filter((k) => sideActive(s.sides[k]!));
if (objectors.length && redoSelection(s, ctx, sel, objectors)) return;
const voidIds = new Map<AugId, SideId>();
for (const p of sel.picks) if (p.id === 'detective' && p.target) voidIds.set(p.target, p.side);
const n = s.sides.length;
const order = [...sel.picks].sort((p, q) => ((p.side - s.turnSide + n) % n) - ((q.side - s.turnSide + n) % n));
const order = sel.picks.filter((p) => p.id !== 'objection').sort((p, q) => ((p.side - s.turnSide + n) % n) - ((q.side - s.turnSide + n) % n));
for (const p of order) {
const by = voidIds.get(p.id);
if (by !== undefined && by !== p.side) {
@@ -1373,6 +1380,32 @@ function resolveSelection(s: YutState, ctx: Ctx): void {
afterInterlude(s, ctx);
}
/**
* 이의있음!: nobody gets what they picked in this selection; every live side picks again from new offers
* (이의있음! is not offered again, so it happens at most once per selection). False when nobody has anything to pick.
*/
function redoSelection(s: YutState, ctx: Ctx, sel: AugSelect, objectors: SideId[]): boolean {
const a = A(s);
const who = objectors.map((k) => nm(k)).join(', ');
const text = `${josa(who, '이/가')} 이의를 제기했어요. 이번에 고른 증강을 모두 없애고 다시 골라요`;
log(s, ctx, { type: 'augEffect', side: objectors[0]!, aug: 'objection', text: `이의있음! ${text}` });
addFx(s, { kind: 'objection', side: objectors[0]!, aug: 'objection', text });
const next: AugSelect = { no: sel.no, tier: sel.tier, offers: {}, left: {}, picks: [], ...(sel.ordered ? { ordered: sel.ordered } : {}) };
for (const x of liveSides(s)) {
const key = String(x.id);
a.delivery[key] = [...(sel.ordered?.[key] ?? [])];
const offers = genOffers(s, x.id, sel.tier, ctx.rng, ['objection']);
a.delivery[key] = [];
if (!offers.length) continue;
next.offers[key] = offers;
next.left[key] = s.options.augChaos ? 2 : 1;
}
if (!Object.keys(next.offers).length) return false;
a.select = next;
s.phase = 'aug';
return true;
}
/** Random empty node (no pieces, no objects), never 참먹이. */
function randomEmptyNode(s: YutState, rng: Rng, avoid: NodeId[] = []): NodeId | null {
const a = A(s);

View File

@@ -83,7 +83,7 @@ const L: Omit<AugInfo, 'id'>[] = [
{ name: '언제부터 착각한 거지?', tier: 'any', kind: 'instant', text: '다른 사람의 증강 하나를 3라운드 동안 고양이로 바꿔요.', note: '이미 다 쓴 증강은 고를 수 없어요.' },
{ name: '윷을 잘 던져봐', tier: 'any', kind: 'active', once: true, text: '윷을 던져 한 사람을 맞혀요. 맞은 사람은 차례를 두 번 건너뛰어요.' },
{ name: '이도류', tier: 'any', kind: 'passive', text: '윷가락을 2개씩 두 번 던져서 결과를 두 개 받아요. 모(둘 다 등)는 도로 바뀌어요.', note: '도·개·빽도만 나와서 한 번 더 던지는 일은 없어요.' },
{ name: '이의있음!', tier: 'any', kind: 'instant', text: '이번 증강 선택을 없던 걸로 하고 새 후보 중에서 다시 골라요.' },
{ name: '이의있음!', tier: 'any', kind: 'instant', text: '이번 증강 선택을 없던 걸로 해요. 모두 고르고 나면 모두가 고른 증강이 사라지고, 모두 새 후보 중에서 다시 골라요.', note: '다시 고를 때는 이의있음!이 나오지 않아요.' },
{ name: '자진모리 장단', tier: 'any', kind: 'passive', text: '걸이 두 번 나올 때마다 개를 하나 더 받아요.' },
{ name: '천마군림보 - 달걸음', tier: 'any', kind: 'passive', text: '내 말은 모두 반대 방향(시계 방향)으로 돌아요.', note: '참먹이에서 날윷 쪽으로 출발하고, 찌모·뒷모·방에 멈추면 지름길로 꺾어요.' },
{ name: '천상의 보호막', tier: 'any', kind: 'active', once: true, text: '내 말뭉치 하나에 보호막을 씌워요. 보호막은 잡힐 때 한 번 막아 줘요.', note: '막아 낸 말은 그 자리에 그대로 남아요.' },