증강 윷놀이: 거머리·네크로맨서 연결도 그 증강이 고양이인 동안 멈춤(승리·탈락·기권 전파), 풀리면 다시 작동
- activeLink: 연결을 만든 증강이 살아 있을 때만 전파(win, eliminate, 기권) - 사람 카드에 멈춘 연결은 "(멈춤)" 표시 - 회귀 테스트 4개(멈춤, 만료 후 복원, 사슬 중간에서 끊김, 네크로맨서) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -566,9 +566,9 @@ describe('증강 윷놀이: review regressions', () => {
|
||||
|
||||
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
|
||||
leech(s, 0, 1);
|
||||
leech(s, 1, 2);
|
||||
leech(s, 2, 0); // 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' });
|
||||
@@ -594,6 +594,77 @@ describe('증강 윷놀이: review regressions', () => {
|
||||
expect(u.sides[0]!.out).toBe(true);
|
||||
});
|
||||
|
||||
/** A (side 0) holds 거머리 tied to `to`; `cat`: the 거머리 is a 고양이 for 3 rounds. */
|
||||
const leech = (s: YutState, from: number, to: number, cat = false) => {
|
||||
s.aug!.sides[from]!.augs.push({ uid: 900 + from, id: 'leech', ...(cat ? { catUntil: s.aug!.round + 3 } : {}) });
|
||||
s.aug!.sides[from]!.links.push({ to, loss: true, by: 'leech' });
|
||||
};
|
||||
/** Side `side` finishes its last piece now (ranking = all keeps the game going). */
|
||||
const finish = (s: YutState, side: number) => {
|
||||
for (const p of s.sides[side]!.pieces) Object.assign(p, { status: 'done', node: null, trail: [] });
|
||||
put(s, side, 0, 19);
|
||||
Object.assign(s, { turnSide: side, current: PLAYERS[side]! });
|
||||
moving(s, ['gae']);
|
||||
return act(s, PLAYERS[side]!, { type: 'MOVE', throwIndex: 0, from: 19 });
|
||||
};
|
||||
/** Side `side` goes out by 과유불급 (six 배). */
|
||||
const bust = (s: YutState, side: number) => {
|
||||
give(s, side, 'excess');
|
||||
Object.assign(s, { turnSide: side, current: PLAYERS[side]!, phase: 'throw', throwsOwed: 1, pending: [] });
|
||||
return act(s, PLAYERS[side]!, { type: 'THROW' }, new Script([F, F, F, F, F, F]));
|
||||
};
|
||||
|
||||
test('고양이가 된 거머리: the link pauses (no shared win, no shared loss, not on conceding either)', () => {
|
||||
let s = make(4, { ranking: 'all' });
|
||||
leech(s, 0, 1, true);
|
||||
expect(yut.view(s, 'A').aug!.sides[0]!.links).toEqual([{ to: 1, by: 'leech', on: false }]);
|
||||
let t = finish(s, 1);
|
||||
expect(t.sides[1]!.finishedRank).toBe(1);
|
||||
expect(t.sides[0]!.finishedRank).toBe(null);
|
||||
s = make(4, { ranking: 'all' });
|
||||
leech(s, 0, 1, true);
|
||||
t = bust(s, 1);
|
||||
expect(t.sides[1]!.out).toBe(true);
|
||||
expect(t.sides[0]!.out).toBe(false);
|
||||
s = make(4, { ranking: 'all' });
|
||||
leech(s, 0, 1, true);
|
||||
t = act(s, 'B', { type: 'CONCEDE' });
|
||||
expect(t.sides[1]!.out).toBe(true);
|
||||
expect(t.sides[0]!.out).toBe(false);
|
||||
expect(t.aug!.sides[0]!.links).toHaveLength(1); // kept for later
|
||||
});
|
||||
|
||||
test('when the 고양이 wears off the 거머리 link works again', () => {
|
||||
let s = make(4, { ranking: 'all' });
|
||||
leech(s, 0, 1, true);
|
||||
s.aug!.round += 3;
|
||||
expect(yut.view(s, 'A').aug!.sides[0]!.links[0]!.on).toBe(true);
|
||||
let t = finish(s, 1);
|
||||
expect(t.sides[0]!.finishedRank).toBe(1);
|
||||
s = make(4, { ranking: 'all' });
|
||||
leech(s, 0, 1, true);
|
||||
s.aug!.round += 3;
|
||||
t = bust(s, 1);
|
||||
expect(t.sides[0]!.out).toBe(true);
|
||||
});
|
||||
|
||||
test('A → B → C with B’s 거머리 as a 고양이: the chain stops at B (neither B nor A ranks with C)', () => {
|
||||
const s = make(4, { ranking: 'all' });
|
||||
leech(s, 0, 1);
|
||||
leech(s, 1, 2, true);
|
||||
const t = finish(s, 2);
|
||||
expect(t.sides.map((x) => x.finishedRank)).toEqual([null, null, 1, null]);
|
||||
});
|
||||
|
||||
test('네크로맨서 links follow the same rule', () => {
|
||||
const s = make(4, { ranking: 'all' });
|
||||
s.aug!.sides[0]!.augs.push({ uid: 950, id: 'necro', used: true, catUntil: s.aug!.round + 3 });
|
||||
s.aug!.sides[0]!.links.push({ to: 1, loss: false, by: 'necro' });
|
||||
expect(finish(structuredClone(s), 1).sides[0]!.finishedRank).toBe(null);
|
||||
s.aug!.round += 3;
|
||||
expect(finish(s, 1).sides[0]!.finishedRank).toBe(1);
|
||||
});
|
||||
|
||||
test('a 고양이 also stops the special piece of a 변환 augment', () => {
|
||||
const s = make(2);
|
||||
give(s, 0, 'vanguard');
|
||||
|
||||
@@ -209,7 +209,8 @@ export interface AugSideView {
|
||||
ritual: number;
|
||||
garlic: number;
|
||||
queenLives: number | null;
|
||||
links: { to: SideId; by: AugId }[];
|
||||
/** `on`: false while the augment that made the link is a 고양이 (the link waits). */
|
||||
links: { to: SideId; by: AugId; on: boolean }[];
|
||||
reason: string | null;
|
||||
bronze: boolean;
|
||||
/** Waiting special pieces (they enter on their own, see the MOVE `piece` field). */
|
||||
@@ -801,6 +802,14 @@ function killNodes(s: YutState, ctx: Ctx, killer: SideId | null, nodes: NodeId[]
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* A 거머리 / 네크로맨서 link only works while the augment that made it works (a 고양이 from 언제부터 착각한 거지?
|
||||
* pauses it; the link stays and works again when the cat wears off).
|
||||
*/
|
||||
function activeLink(s: YutState, side: SideId, link: AugSide['links'][number]): boolean {
|
||||
return !!hasAug(s, side, link.by);
|
||||
}
|
||||
|
||||
function usedRanks(s: YutState): Set<number> {
|
||||
return new Set(s.sides.map((x) => x.finishedRank).filter((r): r is number => r !== null));
|
||||
}
|
||||
@@ -827,7 +836,7 @@ function win(s: YutState, ctx: Ctx, side: SideId, reason: string, aug: AugId | n
|
||||
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);
|
||||
const l = a.sides[y.id]!.links.find((k) => k.to === winner && activeLink(s, y.id, k));
|
||||
if (!l || !sideActive(y) || (a.winsOff && l.by !== 'leech')) continue;
|
||||
y.finishedRank = rank;
|
||||
a.sides[y.id]!.reason = AUGS[l.by].name;
|
||||
@@ -853,7 +862,7 @@ function eliminate(s: YutState, ctx: Ctx, side: SideId, reason: string, aug: Aug
|
||||
a.objs = a.objs.filter((o) => !(o.owner === side && (o.kind === 'mark' || o.kind === 'mine')));
|
||||
log(s, ctx, { type: 'augOut', side, reason, ...(aug ? { aug } : {}) });
|
||||
addFx(s, { kind: 'out', side, ...(aug ? { aug } : {}), text: `${nm(side)} 탈락 · ${reason}` });
|
||||
for (const y of s.sides) if (a.sides[y.id]!.links.some((k) => k.to === side && k.loss)) eliminate(s, ctx, y.id, '거머리(같이 탈락)', 'leech');
|
||||
for (const y of s.sides) if (a.sides[y.id]!.links.some((k) => k.to === side && k.loss && activeLink(s, y.id, k))) eliminate(s, ctx, y.id, '거머리(같이 탈락)', 'leech');
|
||||
}
|
||||
|
||||
function gameOver(s: YutState): boolean {
|
||||
@@ -2813,7 +2822,7 @@ function concedeAug(s: YutState, ctx: Ctx, actor: PlayerId): void {
|
||||
x.outSeq = ++s.outCount;
|
||||
a.sides[side]!.reason = '기권';
|
||||
for (const p of x.pieces) if (p.status === 'board') clearPiece(p, 'home');
|
||||
for (const y of s.sides) if (a.sides[y.id]!.links.some((k) => k.to === side && k.loss)) eliminate(s, ctx, y.id, '거머리(같이 탈락)', 'leech');
|
||||
for (const y of s.sides) if (a.sides[y.id]!.links.some((k) => k.to === side && k.loss && activeLink(s, y.id, k))) eliminate(s, ctx, y.id, '거머리(같이 탈락)', 'leech');
|
||||
if (checkEnd(s, ctx)) return;
|
||||
// drop the side from a selection / prompt in progress
|
||||
if (a.select) {
|
||||
@@ -2973,7 +2982,7 @@ export function augView(s: YutState, viewer: PlayerId | null, base: YutView): Yu
|
||||
ritual: as.ritual,
|
||||
garlic: as.garlic,
|
||||
queenLives: x.pieces.some((p) => p.kind === 'queen') ? as.queenLives : null,
|
||||
links: as.links.map((l) => ({ to: l.to, by: l.by })),
|
||||
links: as.links.map((l) => ({ to: l.to, by: l.by, on: activeLink(s, x.id, l) })),
|
||||
reason: as.reason,
|
||||
bronze: !!as.bronze,
|
||||
homeSpecial: x.pieces.filter((p) => p.status === 'home' && p.kind).map((p) => ({ piece: p.id, kind: p.kind! })),
|
||||
|
||||
Reference in New Issue
Block a user