증강 윷놀이: 안개 속 대상 숨기기, 거머리 연쇄 승리, 고양이가 된 증강의 효과(과유불급 가락·특수 말) 멈춤
- 안개: 숨은 말 때문에 생기는 자리 바꾸기·바둑 대상과 포 이동은 화면에서 뺌(서버는 그대로 받음) - 거머리·네크로맨서 연결이 여러 단계여도 끝까지 같은 순위(고리 연결도 멈춤) - 윷가락 수는 과유불급이 살아 있을 때만 +2(손버릇으로 옮겨도 따라감), 선봉장·도깨비·포·폰 능력도 고양이일 때는 멈춤 - 회귀 테스트 5개 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,9 @@
|
||||
- **잡기 판정 순서**(`killPieces`): 평화 협정(잡는 쪽·잡히는 쪽 중 하나라도) → 거북이 등껍질(한 칸 3개 이상) → 보호막(한 번 막고 사라짐) → 프랜드 실드(1개만). 증강으로 잡는 것도 같다. 잡을 때 오르는 것: 무신정변·소 뒷걸음질(빽도)·살인(체력)·나만 친구 없어·어부지리(차례가 아닌 사람)·복수의 칼날.
|
||||
- 잡으면 한 번 더 던지기는 보통 이동·특수 말 이동만. 증강 효과로 잡은 것(트럭·합체·바둑 등)은 한 번 더 던지지 않는다(바둑은 잡은 수만큼 던진다).
|
||||
- **차례 소모**(8톤 트럭·3단 합체·알까기): 그 차례 첫 던지기 전에만 쓰고, 쓰면 차례가 끝난다.
|
||||
- 1회 증강은 쓰면 칸에 "사용함" 도장(✔). 명탐정에 걸린 증강은 줄이 그어진다. 언제부터 착각한 거지?에 걸리면 🐱(효과·버튼·승리 조건 모두 꺼짐).
|
||||
- 1회 증강은 쓰면 칸에 "사용함" 도장(✔). 명탐정에 걸린 증강은 줄이 그어진다. 언제부터 착각한 거지?에 걸리면 🐱(효과·버튼·승리 조건 모두 꺼짐). 과유불급의 윷가락 +2, 변환으로 만든 특수 말의 능력(선봉장 +1칸, 도깨비·포 이동, 폰 전진)도 그동안 멈췄다가 풀리면 돌아온다.
|
||||
- 거머리·네크로맨서 연결은 이어진다: A→B→C에서 C가 이기면 B와 A도 같은 순위.
|
||||
- 안개 속에서는 숨은 말 때문에 생기는 선택지(자리 바꾸기·바둑 대상, 포가 넘는 칸)도 화면에 나오지 않는다.
|
||||
- 취~소 뒤에는 모든 승리 조건 증강이 꺼진다(중전마마·김첨지 등의 말은 남고 승리만 없음).
|
||||
|
||||
## 3. 해석이 필요했던 부분
|
||||
|
||||
@@ -180,7 +180,7 @@ describe('증강 윷놀이: throws', () => {
|
||||
test('과유불급: six sticks, all 배 → out', () => {
|
||||
const s = make(3);
|
||||
give(s, 0, 'excess');
|
||||
expect(s.aug!.sides[0]!.sticks).toBe(6);
|
||||
expect(yut.view(s, 'A').aug!.sides[0]!.sticks).toBe(6);
|
||||
const t = act(s, 'A', { type: 'THROW' }, new Script([F, F, F, F, F, F]));
|
||||
expect(t.sides[0]!.out).toBe(true);
|
||||
expect(t.current).toBe('B');
|
||||
@@ -536,6 +536,88 @@ describe('증강 윷놀이: abilities and instant effects', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('증강 윷놀이: review regressions', () => {
|
||||
test('안개: ability targets and 포 moves do not give hidden pieces away', () => {
|
||||
const s = make(2);
|
||||
give(s, 0, 'fog');
|
||||
put(s, 0, 0, 12); // A hides on 찌개
|
||||
put(s, 0, 1, 2); // screen for B's 포, out of B's sight
|
||||
put(s, 1, 0, 6); // B sees around 뒷도
|
||||
s.aug!.fog = { owner: 0, left: 2 };
|
||||
give(s, 1, 'swap');
|
||||
give(s, 1, 'cannon');
|
||||
const cannonPiece = s.sides[1]!.pieces[1]!;
|
||||
put(s, 1, 1, 18);
|
||||
cannonPiece.kind = 'cannon';
|
||||
cannonPiece.group = cannonPiece.id;
|
||||
Object.assign(s, { turnSide: 1, current: 'B' });
|
||||
// the server knows the targets…
|
||||
const all = JSON.stringify(yut.legalActions!(s, 'B'));
|
||||
expect(all).toContain('"node":12');
|
||||
// …B's screen does not
|
||||
const vb = yut.view(s, 'B');
|
||||
expect(vb.aug!.fogged).toBe(true);
|
||||
expect(vb.stacks.some((st) => st.side === 0)).toBe(false);
|
||||
const json = JSON.stringify(vb.aug!.uses);
|
||||
expect(json).not.toContain('"node":12');
|
||||
expect(json).not.toContain('찌개');
|
||||
expect(vb.aug!.specials.filter((m) => m.kind === 'cannon').every((m) => (m.over ?? []).every((n) => n !== 2 && n !== 12))).toBe(true);
|
||||
});
|
||||
|
||||
test('거머리 chains: A → B → C, C wins → B and A share the rank', () => {
|
||||
const s = make(4, { ranking: 'all' });
|
||||
s.aug!.sides[0]!.links.push({ to: 1, loss: true, by: 'leech' });
|
||||
s.aug!.sides[1]!.links.push({ to: 2, loss: true, by: 'leech' });
|
||||
s.aug!.sides[2]!.links.push({ to: 0, loss: true, by: 'leech' }); // a loop must not hang
|
||||
for (const p of s.sides[2]!.pieces) Object.assign(p, { status: 'done', node: null, trail: [] });
|
||||
put(s, 2, 0, 19);
|
||||
Object.assign(s, { turnSide: 2, current: 'C' });
|
||||
moving(s, ['gae']);
|
||||
const t = act(s, 'C', { type: 'MOVE', throwIndex: 0, from: 19 });
|
||||
expect(t.sides.map((x) => x.finishedRank)).toEqual([1, 1, 1, null]);
|
||||
expect(t.final!.ranking.map((r) => [r.side, r.rank])).toEqual([[0, 1], [1, 1], [2, 1], [3, 2]]);
|
||||
});
|
||||
|
||||
test('a 고양이 (언제부터 착각한 거지?) turns 과유불급 off, sticks back to 4 until it wears off', () => {
|
||||
const s = make(2);
|
||||
give(s, 0, 'excess');
|
||||
expect(yut.view(s, 'A').aug!.sides[0]!.sticks).toBe(6);
|
||||
s.aug!.sides[0]!.augs[0]!.catUntil = s.aug!.round + 3;
|
||||
expect(yut.view(s, 'A').aug!.sides[0]!.sticks).toBe(4);
|
||||
const t = act(s, 'A', { type: 'THROW' }, new Script([F, F, F, F]));
|
||||
expect(t.lastThrow!.sticks).toHaveLength(4);
|
||||
expect(t.lastThrow!.result).toBe('yut');
|
||||
expect(t.sides[0]!.out).toBe(false);
|
||||
s.aug!.round += 3;
|
||||
expect(yut.view(s, 'A').aug!.sides[0]!.sticks).toBe(6);
|
||||
const u = act(s, 'A', { type: 'THROW' }, new Script([F, F, F, F, F, F]));
|
||||
expect(u.sides[0]!.out).toBe(true);
|
||||
});
|
||||
|
||||
test('a 고양이 also stops the special piece of a 변환 augment', () => {
|
||||
const s = make(2);
|
||||
give(s, 0, 'vanguard');
|
||||
give(s, 0, 'dokkaebi');
|
||||
put(s, 0, 0, 3);
|
||||
put(s, 0, 1, 5);
|
||||
Object.assign(s.sides[0]!.pieces[0]!, { kind: 'vanguard', group: 0 });
|
||||
Object.assign(s.sides[0]!.pieces[1]!, { kind: 'dokkaebi', group: 1 });
|
||||
for (const o of s.aug!.sides[0]!.augs) o.catUntil = s.aug!.round + 3;
|
||||
expect(yut.view(s, 'A').aug!.specials).toHaveLength(0);
|
||||
moving(s, ['do']);
|
||||
const t = act(s, 'A', { type: 'MOVE', throwIndex: 0, from: 'home' });
|
||||
expect(nodesOf(t, 0)[2]).toBe(1); // no 선봉장 bonus step
|
||||
});
|
||||
|
||||
test('손버릇 takes 과유불급 with its two sticks', () => {
|
||||
const s = make(2);
|
||||
give(s, 1, 'excess');
|
||||
give(s, 0, 'thief');
|
||||
const t = act(s, 'A', { type: 'AUG_ANSWER', choice: uidOf(s, 1, 'excess') });
|
||||
expect(yut.view(t, 'A').aug!.sides.map((x) => x.sticks)).toEqual([6, 4]);
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------- winning & going out
|
||||
|
||||
describe('증강 윷놀이: special wins and ranks', () => {
|
||||
|
||||
@@ -237,6 +237,8 @@ export interface AugSpecialMove {
|
||||
to: NodeId | 'goal';
|
||||
path: NodeId[];
|
||||
captures: number;
|
||||
/** 포: the nodes between it and its landing spot it looked at (the screen included). */
|
||||
over?: NodeId[];
|
||||
}
|
||||
|
||||
export interface YutAugView {
|
||||
@@ -392,6 +394,9 @@ function distOf(s: YutState, side: SideId, p: Piece): number {
|
||||
}
|
||||
const sideDist = (s: YutState, x: SideState) => x.pieces.reduce((a, p) => a + distOf(s, x.id, p), 0);
|
||||
|
||||
/** Sticks this side throws now: its own count (등가교환·짐덩이) + 2 while 과유불급 works (not while it is a 고양이). */
|
||||
const sticksOf = (s: YutState, side: SideId) => A(s).sides[side]!.sticks + (hasAug(s, side, 'excess') ? 2 : 0);
|
||||
|
||||
const emptyThrown = (): Record<Throw, number> => ({ do: 0, gae: 0, geol: 0, yut: 0, mo: 0, backdo: 0 });
|
||||
|
||||
// ---------------------------------------------------------------- setup
|
||||
@@ -490,7 +495,7 @@ function walkBack(s: YutState, side: SideId, from: NodeId, trail: NodeId[], k: n
|
||||
function forwardSteps(s: YutState, side: SideId, t: Throw): number {
|
||||
const x = s.sides[side]!;
|
||||
let n = THROW_STEPS[t];
|
||||
if (x.pieces.some((p) => p.kind === 'vanguard' && p.status === 'board')) n += 1;
|
||||
if (hasAug(s, side, 'vanguard') && x.pieces.some((p) => p.kind === 'vanguard' && p.status === 'board')) n += 1;
|
||||
if (A(s).lastDance && s.turnSide === side) n *= 2;
|
||||
return n;
|
||||
}
|
||||
@@ -817,15 +822,20 @@ function win(s: YutState, ctx: Ctx, side: SideId, reason: string, aug: AugId | n
|
||||
for (const p of x.pieces) if (p.status === 'board') clearPiece(p, 'home');
|
||||
log(s, ctx, { type: 'sideFinished', side, rank, ...(aug ? { aug } : {}) });
|
||||
addFx(s, { kind: 'win', side, ...(aug ? { aug } : {}), rank, text: aug ? `${AUGS[aug].name}: 특수 승리 조건 달성!` : '말을 모두 냈어요!' });
|
||||
for (const y of s.sides) {
|
||||
const l = a.sides[y.id]!.links.find((k) => k.to === side);
|
||||
if (l && sideActive(y) && !(a.winsOff && l.by !== 'leech')) {
|
||||
// Chains (A → B → C: C wins, so B and then A win too). A side ranks once, so loops end by themselves.
|
||||
const queue: SideId[] = [side];
|
||||
while (queue.length) {
|
||||
const winner = queue.shift()!;
|
||||
for (const y of s.sides) {
|
||||
const l = a.sides[y.id]!.links.find((k) => k.to === winner);
|
||||
if (!l || !sideActive(y) || (a.winsOff && l.by !== 'leech')) continue;
|
||||
y.finishedRank = rank;
|
||||
a.sides[y.id]!.reason = AUGS[l.by].name;
|
||||
if (aug) a.sides[y.id]!.special = true;
|
||||
for (const p of y.pieces) if (p.status === 'board') clearPiece(p, 'home');
|
||||
log(s, ctx, { type: 'sideFinished', side: y.id, rank, aug: l.by });
|
||||
addFx(s, { kind: 'win', side: y.id, aug: l.by, rank, text: `${nm(side)}의 승리에 편승해 같은 순위를 얻었어요` });
|
||||
addFx(s, { kind: 'win', side: y.id, aug: l.by, rank, text: `${nm(winner)}의 승리에 편승해 같은 순위를 얻었어요` });
|
||||
queue.push(y.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1336,9 +1346,6 @@ function acquire(s: YutState, ctx: Ctx, side: SideId, id: AugId, target?: AugId)
|
||||
if (target) (a.delivery[String(side)] ??= []).push(target);
|
||||
owned.target = target ? AUG_IDS.indexOf(target) : undefined;
|
||||
break;
|
||||
case 'excess':
|
||||
as.sticks += 2;
|
||||
break;
|
||||
case 'fold':
|
||||
a.prompts.push({ kind: 'fold', owner: side, actors: [side], answers: {} });
|
||||
break;
|
||||
@@ -1726,10 +1733,6 @@ function resolvePrompt(s: YutState, ctx: Ctx, pr: AugPrompt): void {
|
||||
if (i < 0) continue;
|
||||
const [t] = as.augs.splice(i, 1);
|
||||
a.sides[o]!.augs.push(t!);
|
||||
if (t!.id === 'excess') {
|
||||
as.sticks -= 2;
|
||||
a.sides[o]!.sticks += 2;
|
||||
}
|
||||
say('thief', `손버릇: ${josa(`[${AUGS[t!.id].name}]`, '을/를')} 빼앗아 왔어요`);
|
||||
}
|
||||
break;
|
||||
@@ -1799,22 +1802,22 @@ function doThrowAug(s: YutState, ctx: Ctx, pick: 'do' | 'gae' | undefined, force
|
||||
let note: string | undefined;
|
||||
if (forced) {
|
||||
results = [forced];
|
||||
sticks = sticksFor(forced, as.sticks);
|
||||
sticks = sticksFor(forced, sticksOf(s, id));
|
||||
note = '손은 눈보다 빠르다';
|
||||
} else if (hasAug(s, id, 'doggy')) {
|
||||
const r = pick ?? 'gae';
|
||||
results = [r];
|
||||
sticks = sticksFor(r, as.sticks);
|
||||
sticks = sticksFor(r, sticksOf(s, id));
|
||||
note = '개돼지';
|
||||
} else if (hasAug(s, id, 'doberman')?.used && as.dogCoins >= 2) {
|
||||
as.dogCoins -= 2;
|
||||
results = ['mo'];
|
||||
sticks = sticksFor('mo', as.sticks);
|
||||
sticks = sticksFor('mo', sticksOf(s, id));
|
||||
note = '도베르만';
|
||||
} else if (hasAug(s, id, 'moordo')) {
|
||||
const r: Throw = ctx.rng.next() < 0.4 ? 'mo' : 'do';
|
||||
results = [r];
|
||||
sticks = sticksFor(r, as.sticks);
|
||||
sticks = sticksFor(r, sticksOf(s, id));
|
||||
} else if (hasAug(s, id, 'dual')) {
|
||||
const p = o.stickModel === 'fair' ? 0.5 : 0.6;
|
||||
sticks = [ctx.rng.next() < p, ctx.rng.next() < p, ctx.rng.next() < p, ctx.rng.next() < p];
|
||||
@@ -1842,7 +1845,7 @@ function doThrowAug(s: YutState, ctx: Ctx, pick: 'do' | 'gae' | undefined, force
|
||||
}
|
||||
// 과유불급 sticks are always half-and-half (with 실제 윷 odds six 배 would come up far too often).
|
||||
const p = o.stickModel === 'fair' || hasAug(s, id, 'excess') ? 0.5 : 0.6;
|
||||
sticks = Array.from({ length: as.sticks }, () => ctx.rng.next() < p);
|
||||
sticks = Array.from({ length: sticksOf(s, id) }, () => ctx.rng.next() < p);
|
||||
const k = sticks.filter(Boolean).length;
|
||||
if (hasAug(s, id, 'excess') && k === 6) {
|
||||
s.lastThrow = { no: s.throwNo, player: s.current, sticks, result: 'yut', note: '과유불급' };
|
||||
@@ -1892,7 +1895,7 @@ function doThrowAug(s: YutState, ctx: Ctx, pick: 'do' | 'gae' | undefined, force
|
||||
}
|
||||
}
|
||||
// 폰: every pawn walks one step per throw.
|
||||
for (const p of s.sides[id]!.pieces.filter((x) => x.kind === 'pawn' && x.status !== 'done')) {
|
||||
for (const p of hasAug(s, id, 'pawn') ? s.sides[id]!.pieces.filter((x) => x.kind === 'pawn' && x.status !== 'done') : []) {
|
||||
pawnStep(s, ctx, id, p);
|
||||
if (phaseOf(s) === 'finished') return;
|
||||
if (!sideActive(s.sides[id]!)) {
|
||||
@@ -2633,7 +2636,7 @@ export function specialMoves(s: YutState, side: SideId): AugSpecialMove[] {
|
||||
const rev = !!hasAug(s, side, 'moonwalk');
|
||||
for (const p of x.pieces) {
|
||||
if (p.status === 'done' || frozen(s, p)) continue;
|
||||
if (p.kind === 'dokkaebi' && !a.sides[side]!.usedTurn.includes(`p${p.id}`)) {
|
||||
if (p.kind === 'dokkaebi' && hasAug(s, side, 'dokkaebi') && !a.sides[side]!.usedTurn.includes(`p${p.id}`)) {
|
||||
const f = walk(p.status === 'home' ? 'home' : p.node!, 1, s.options.finishRule, false, rev, !!hasAug(s, side, 'shortcut'));
|
||||
out.push({ piece: p.id, kind: 'dokkaebi', from: p.status === 'home' ? 'home' : p.node!, to: f.to === GOAL ? 'goal' : f.to, path: f.path, captures: f.to === GOAL ? 0 : previewKills(s, side, f.to, [p.id], false) });
|
||||
if (p.status === 'board') {
|
||||
@@ -2642,7 +2645,7 @@ export function specialMoves(s: YutState, side: SideId): AugSpecialMove[] {
|
||||
out.push({ piece: p.id, kind: 'dokkaebi', from: p.node!, to: b.to === GOAL ? 'goal' : b.to, path: b.path, captures: b.to === GOAL ? 0 : previewKills(s, side, b.to, [p.id], true) });
|
||||
}
|
||||
}
|
||||
if (p.kind === 'cannon' && p.status === 'board' && !a.sides[side]!.usedTurn.includes(`p${p.id}`)) {
|
||||
if (p.kind === 'cannon' && hasAug(s, side, 'cannon') && p.status === 'board' && !a.sides[side]!.usedTurn.includes(`p${p.id}`)) {
|
||||
for (const line of STRAIGHT_LINES) {
|
||||
const i = line.indexOf(p.node!);
|
||||
if (i < 0) continue;
|
||||
@@ -2658,10 +2661,10 @@ export function specialMoves(s: YutState, side: SideId): AugSpecialMove[] {
|
||||
path.push(n);
|
||||
if (here.length) {
|
||||
const enemy = here.some((q) => sideOfPiece(s, q) !== side);
|
||||
if (enemy && n !== 0) out.push({ piece: p.id, kind: 'cannon', from: p.node!, to: n, path: [...path], captures: previewKills(s, side, n, [p.id], false) });
|
||||
if (enemy && n !== 0) out.push({ piece: p.id, kind: 'cannon', from: p.node!, to: n, path: [...path], captures: previewKills(s, side, n, [p.id], false), over: line.slice(Math.min(i, j), Math.max(i, j) + 1) });
|
||||
break;
|
||||
}
|
||||
if (n !== 0 && !out.some((m) => m.piece === p.id && m.to === n)) out.push({ piece: p.id, kind: 'cannon', from: p.node!, to: n, path: [...path], captures: 0 });
|
||||
if (n !== 0 && !out.some((m) => m.piece === p.id && m.to === n)) out.push({ piece: p.id, kind: 'cannon', from: p.node!, to: n, path: [...path], captures: 0, over: line.slice(Math.min(i, j), Math.max(i, j) + 1) });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2962,7 +2965,7 @@ export function augView(s: YutState, viewer: PlayerId | null, base: YutView): Yu
|
||||
return {
|
||||
id: x.id,
|
||||
augs: as.augs.map((o) => ({ uid: o.uid, id: o.id, used: !!o.used, voided: !!o.voided, catUntil: (o.catUntil ?? 0) > a.round ? o.catUntil! : null, note: ownedNote(s, x.id, o) })),
|
||||
sticks: as.sticks,
|
||||
sticks: sticksOf(s, x.id),
|
||||
pieces: x.pieces.length,
|
||||
skip: as.skip,
|
||||
hp: as.hp,
|
||||
@@ -3039,8 +3042,23 @@ export function augView(s: YutState, viewer: PlayerId | null, base: YutView): Yu
|
||||
v.log = v.log.map((e) => (e.type === 'moved' && e.side !== mySide ? { type: 'moved', side: e.side, player: e.player, throw: e.throw, fog: true } : e));
|
||||
// a "잡기!" badge would give hidden pieces away
|
||||
if (v.legalMoves) v.legalMoves = v.legalMoves.map((m) => (m.to !== GOAL && !visible(m.to) ? { ...m, captures: 0 } : m));
|
||||
aug.specials = aug.specials.map((m) => (m.to !== 'goal' && !visible(m.to) ? { ...m, captures: 0 } : m));
|
||||
aug.uses = aug.uses.map((u) => ({ ...u, kills: undefined }));
|
||||
// Choices that only exist because of pieces hidden in the fog are left out (the server still accepts them).
|
||||
const seen = (ns: (NodeId | 'home' | 'goal' | undefined)[]) => ns.every((n) => n === undefined || n === 'home' || n === 'goal' || visible(n));
|
||||
aug.specials = aug.specials
|
||||
.filter((m) => m.kind !== 'cannon' || seen([m.to, ...m.path, ...(m.over ?? [])]))
|
||||
.map((m) => (m.to !== 'goal' && !visible(m.to) ? { ...m, captures: 0 } : m));
|
||||
aug.uses = aug.uses
|
||||
.filter((u) => {
|
||||
// Only choices aimed at other players' pieces can give hidden ones away (명사수 lists every node anyway).
|
||||
if (u.id === 'baduk') {
|
||||
const l = lineOf(u.action.node!, u.action.node2!)!;
|
||||
const [i, j] = [l.indexOf(u.action.node!), l.indexOf(u.action.node2!)].sort((p, q) => p - q);
|
||||
return seen(l.slice(i!, j! + 1));
|
||||
}
|
||||
if (u.id === 'swap') return seen([u.action.node]);
|
||||
return true;
|
||||
})
|
||||
.map((u) => ({ ...u, kills: undefined, label: u.id === 'baduk' ? u.label.replace(/ 사이 \d+개$/, ' 사이') : u.label }));
|
||||
}
|
||||
if (a.hidden && mySide !== pr?.owner) {
|
||||
v = {
|
||||
|
||||
Reference in New Issue
Block a user