증강 윷놀이: 이의있음! 재선택에서는 혼돈 모드 두 번째 후보에도 이의있음!이 안 나오게, 증강 팝업이 위아래 공간이 모자라도 화면 안에 들어오게
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -114,8 +114,14 @@ function AugPopCard({ el, id, state, popId }: PopInfo & { el: HTMLElement; popId
|
||||
const r = el.getBoundingClientRect();
|
||||
const p = ref.current!.getBoundingClientRect();
|
||||
const gap = 8;
|
||||
const vh = window.innerHeight;
|
||||
// below the chip if it fits, else above if it fits, else on the roomier side; then kept inside the screen
|
||||
let top = r.bottom + gap;
|
||||
if (top + p.height > window.innerHeight - gap && r.top - gap - p.height >= gap) top = r.top - gap - p.height;
|
||||
if (top + p.height > vh - gap) {
|
||||
const above = r.top - gap - p.height;
|
||||
if (above >= gap || r.top > vh - r.bottom) top = above;
|
||||
}
|
||||
top = Math.max(gap, Math.min(top, vh - gap - p.height));
|
||||
const left = Math.min(Math.max(gap, r.left + r.width / 2 - p.width / 2), window.innerWidth - gap - p.width);
|
||||
setPos({ left, top });
|
||||
}, [el, id, stateKey]);
|
||||
|
||||
@@ -1776,7 +1776,23 @@ const PLANS: Record<string, Plan> = {
|
||||
else await p.locator('.aug-bar').first().tap();
|
||||
await pop(p).waitFor({ state: 'detached', timeout: 3000 });
|
||||
}
|
||||
console.log(' yut-aug: chip popups ok (hover on PC, tap on phone)');
|
||||
// a short landscape window (844×390): every chip's card stays fully on screen, whichever side it opens on
|
||||
const vp0 = host.viewportSize()!;
|
||||
await host.setViewportSize({ width: 844, height: 390 });
|
||||
const chips = host.locator('.aug-chip');
|
||||
for (let i = 0; i < (await chips.count()); i++) {
|
||||
for (const block of ['start', 'center', 'end'] as const) {
|
||||
await chips.nth(i).evaluate((el, b) => el.scrollIntoView({ block: b }), block);
|
||||
await host.mouse.move(2, 2);
|
||||
await chips.nth(i).hover();
|
||||
await pop(host).waitFor({ timeout: 3000 });
|
||||
const box = (await pop(host).boundingBox())!;
|
||||
if (box.y < 0 || box.y + box.height > 390 || box.x < 0 || box.x + box.width > 844) throw new Error(`augment popup off a 844×390 screen ${JSON.stringify(box)}`);
|
||||
}
|
||||
}
|
||||
await host.mouse.move(2, 2);
|
||||
await host.setViewportSize(vp0);
|
||||
console.log(' yut-aug: chip popups ok (hover on PC, tap on phone, 844×390)');
|
||||
}
|
||||
if (steps === 30 || steps === 120 || steps === 200) {
|
||||
await host.screenshot({ path: join(SHOTS, `yut-aug-mid${steps}-pc.png`) });
|
||||
|
||||
@@ -156,6 +156,27 @@ describe('증강 윷놀이: options and selection', () => {
|
||||
expect(t.aug!.delivery['1']).toEqual([]);
|
||||
});
|
||||
|
||||
test('이의있음! happens once per selection: the redo never offers it, 혼돈 mode\'s second offers included', () => {
|
||||
const on: AugId[] = ['cat', 'shield', 'objection'];
|
||||
const augOff = AUG_IDS.filter((id) => !on.includes(id));
|
||||
const s = yut.setup({ players: ['A', 'B'], options: yut.optionsSchema.parse({ augmented: true, augChaos: true, augOff }), rng: SeededRng.fromSeed(seedN(2)), now: 0 });
|
||||
s.aug!.select!.offers = { '0': ['objection', 'cat', 'shield'], '1': ['cat', 'shield'] };
|
||||
let t = act(s, 'A', { type: 'AUG_PICK', aug: 'objection' });
|
||||
t = act(t, 'B', { type: 'AUG_PICK', aug: 'cat' });
|
||||
t = act(t, 'B', { type: 'AUG_PICK', aug: t.aug!.select!.offers['1']![0]! });
|
||||
expect(t.aug!.select!.redo).toBe(true);
|
||||
for (const who of ['A', 'B']) {
|
||||
const key = who === 'A' ? '0' : '1';
|
||||
expect(t.aug!.select!.offers[key]).not.toContain('objection');
|
||||
t = act(t, who, { type: 'AUG_PICK', aug: t.aug!.select!.offers[key]![0]! });
|
||||
expect(t.aug!.select!.offers[key]).not.toContain('objection');
|
||||
t = act(t, who, { type: 'AUG_PICK', aug: t.aug!.select!.offers[key]![0]! });
|
||||
}
|
||||
expect(t.aug!.select).toBeNull();
|
||||
expect(t.log.filter((e) => e.type === 'augEffect' && (e as { aug?: string }).aug === 'objection')).toHaveLength(1);
|
||||
expect(t.aug!.sides.map((x) => x.augs.map((o) => o.id).sort())).toEqual([['cat', 'shield'], ['cat', 'shield']]);
|
||||
});
|
||||
|
||||
test('간택: a 고양이 among the offers must be taken', () => {
|
||||
const s = make(2);
|
||||
give(s, 1, 'chosen');
|
||||
|
||||
@@ -134,6 +134,8 @@ export interface AugSelect {
|
||||
picks: { side: SideId; id: AugId; target?: AugId }[];
|
||||
/** 배달 orders this selection was made with, so an 이의있음! redo offers them again. */
|
||||
ordered?: Record<string, AugId[]>;
|
||||
/** This is the 이의있음! redo: 이의있음! is never offered again (혼돈 mode's second offers included). */
|
||||
redo?: boolean;
|
||||
}
|
||||
|
||||
/** Something the screen should show once (popup / animation); `no` increases. */
|
||||
@@ -1348,7 +1350,8 @@ function applyPick(s: YutState, ctx: Ctx, side: SideId, act: AugPick): void {
|
||||
} else {
|
||||
sel.picks.push({ side, id: act.aug, ...(act.target ? { target: act.target } : {}) });
|
||||
sel.left[key]! -= 1;
|
||||
sel.offers[key] = sel.left[key]! > 0 ? genOffers(s, side, sel.tier, ctx.rng, sel.picks.filter((p) => p.side === side).map((p) => p.id)) : [];
|
||||
const mine = sel.picks.filter((p) => p.side === side).map((p) => p.id);
|
||||
sel.offers[key] = sel.left[key]! > 0 ? genOffers(s, side, sel.tier, ctx.rng, sel.redo ? ['objection', ...mine] : mine) : [];
|
||||
if (!sel.offers[key]!.length) sel.left[key] = 0;
|
||||
}
|
||||
if (Object.values(sel.left).every((n) => n <= 0)) resolveSelection(s, ctx);
|
||||
@@ -1391,7 +1394,7 @@ function redoSelection(s: YutState, ctx: Ctx, sel: AugSelect, objectors: SideId[
|
||||
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 } : {}) };
|
||||
const next: AugSelect = { no: sel.no, tier: sel.tier, offers: {}, left: {}, picks: [], redo: true, ...(sel.ordered ? { ordered: sel.ordered } : {}) };
|
||||
for (const x of liveSides(s)) {
|
||||
const key = String(x.id);
|
||||
a.delivery[key] = [...(sel.ordered?.[key] ?? [])];
|
||||
|
||||
Reference in New Issue
Block a user