merge: Gateway 입구 공지 복사 기능 통합

This commit is contained in:
2026-08-19 11:12:44 +00:00
4 changed files with 380 additions and 34 deletions
+18 -1
View File
@@ -1,6 +1,6 @@
import { TRPCError } from '@trpc/server'; import { TRPCError } from '@trpc/server';
import { asRecord } from '@sammo-ts/common'; import { asNumber, asRecord } from '@sammo-ts/common';
import { zWorldStateConfig, zWorldStateMeta } from '../../context.js'; import { zWorldStateConfig, zWorldStateMeta } from '../../context.js';
import { isSelectionPoolWorld, resolveSelectionMaxGeneral } from '@sammo-ts/game-engine/turn/selectPoolService.js'; import { isSelectionPoolWorld, resolveSelectionMaxGeneral } from '@sammo-ts/game-engine/turn/selectPoolService.js';
@@ -26,7 +26,14 @@ export const lobbyRouter = router({
const userCnt = await ctx.db.general.count({ where: { npcState: { lt: 2 } } }); const userCnt = await ctx.db.general.count({ where: { npcState: { lt: 2 } } });
const npcCnt = await ctx.db.general.count({ where: { npcState: { gte: 2 } } }); const npcCnt = await ctx.db.general.count({ where: { npcState: { gte: 2 } } });
const nationCnt = await ctx.db.nation.count({ where: { level: { gt: 0 } } }); const nationCnt = await ctx.db.nation.count({ where: { level: { gt: 0 } } });
const rawConfig = asRecord(rawWorldState.config);
const scenarioTitle = asRecord(asRecord(rawWorldState.meta).scenarioMeta).title; const scenarioTitle = asRecord(asRecord(rawWorldState.meta).scenarioMeta).title;
const autorunUser = worldState.meta.autorun_user;
const autorunOptions = autorunUser?.options
? Object.entries(autorunUser.options)
.filter(([, enabled]) => enabled)
.map(([option]) => option)
: [];
const gameTime = await loadCurrentGameTime(ctx.db); const gameTime = await loadCurrentGameTime(ctx.db);
let myGeneral = null; let myGeneral = null;
@@ -55,10 +62,20 @@ export const lobbyRouter = router({
fictionMode: worldState.config.fictionMode ?? '사실', fictionMode: worldState.config.fictionMode ?? '사실',
starttime: worldState.meta.starttime ?? '', starttime: worldState.meta.starttime ?? '',
opentime: worldState.meta.opentime ?? '', opentime: worldState.meta.opentime ?? '',
preopenAt: worldState.meta.preopenAt ?? '',
turntime: worldState.meta.turntime ?? '', turntime: worldState.meta.turntime ?? '',
serverTime: gameTime.now.toISOString(), serverTime: gameTime.now.toISOString(),
clockMode: gameTime.mode ?? 'realtime', clockMode: gameTime.mode ?? 'realtime',
otherTextInfo: worldState.meta.otherTextInfo ?? '', otherTextInfo: worldState.meta.otherTextInfo ?? '',
npcMode: worldState.config.npcMode ?? 0,
defaultStatTotal: asNumber(asRecord(rawConfig.stat).total, 165),
autorunUser:
autorunUser?.limit_minutes && autorunUser.limit_minutes > 0 && autorunOptions.length > 0
? {
limitMinutes: autorunUser.limit_minutes,
options: autorunOptions,
}
: null,
isUnited: worldState.meta.isunited ?? worldState.meta.isUnited ?? 0, isUnited: worldState.meta.isunited ?? worldState.meta.isUnited ?? 0,
selectionPoolEnabled: isSelectionPoolWorld(rawWorldState), selectionPoolEnabled: isSelectionPoolWorld(rawWorldState),
npcPossessionEnabled: worldState.config.npcMode === 1, npcPossessionEnabled: worldState.config.npcMode === 1,
+47 -2
View File
@@ -10,7 +10,8 @@ const buildContext = (
tick?: bigint; tick?: bigint;
mode?: string; mode?: string;
wallAnchor?: Date; wallAnchor?: Date;
} = {} } = {},
config: Record<string, unknown> = {}
): GameApiContext => ): GameApiContext =>
({ ({
auth: null, auth: null,
@@ -22,7 +23,7 @@ const buildContext = (
currentYear: 200, currentYear: 200,
currentMonth: 1, currentMonth: 1,
tickSeconds: 3_600, tickSeconds: 3_600,
config: {}, config,
meta, meta,
clockBaseTime: clock.baseTime ?? null, clockBaseTime: clock.baseTime ?? null,
clockTick: clock.tick ?? null, clockTick: clock.tick ?? null,
@@ -67,4 +68,48 @@ describe('lobby season state', () => {
expect(result.serverTime).toBe('2026-08-15T02:00:00.000Z'); expect(result.serverTime).toBe('2026-08-15T02:00:00.000Z');
expect(result.clockMode).toBe('manual'); expect(result.clockMode).toBe('manual');
}); });
it('projects the Ref-compatible opening announcement settings without exposing disabled autorun options', async () => {
const result = await appRouter
.createCaller(
buildContext(
{
preopenAt: '2026-08-19 22:00:00',
opentime: '2026-08-19 23:00:00',
scenarioMeta: { title: '【가상모드27-b】 아시아 명장전(비급)' },
autorun_user: {
limit_minutes: 1_440,
options: {
develop: true,
warp: true,
recruit: false,
recruit_high: true,
train: true,
battle: true,
chief: true,
},
},
},
{},
{
fictionMode: '가상',
npcMode: 0,
stat: { total: 310, min: 10, max: 110 },
}
)
)
.lobby.info();
expect(result).toMatchObject({
preopenAt: '2026-08-19 22:00:00',
opentime: '2026-08-19 23:00:00',
scenarioTitle: '【가상모드27-b】 아시아 명장전(비급)',
npcMode: 0,
defaultStatTotal: 310,
autorunUser: {
limitMinutes: 1_440,
options: ['develop', 'warp', 'recruit_high', 'train', 'battle', 'chief'],
},
});
});
}); });
@@ -51,7 +51,18 @@ type LobbyFixtureOptions = {
isUnited?: number; isUnited?: number;
starttime?: string; starttime?: string;
opentime?: string; opentime?: string;
preopenAt?: string;
turntime?: string; turntime?: string;
turnTerm?: number;
scenarioTitle?: string;
npcMode?: number;
defaultStatTotal?: number;
korName?: string;
otherTextInfo?: string;
autorunUser?: {
limitMinutes: number;
options: string[];
} | null;
lobbyBundleFailures?: number; lobbyBundleFailures?: number;
profileStatus?: 'RUNNING' | 'PREOPEN' | 'PAUSED' | 'COMPLETED' | 'STOPPED'; profileStatus?: 'RUNNING' | 'PREOPEN' | 'PAUSED' | 'COMPLETED' | 'STOPPED';
includeStoppedProfile?: boolean; includeStoppedProfile?: boolean;
@@ -78,7 +89,15 @@ const installFixture = async (page: Page, options: LobbyFixtureOptions = {}) =>
isUnited = 0, isUnited = 0,
starttime = '2026-07-30 00:00:00', starttime = '2026-07-30 00:00:00',
opentime = '2026-07-30 00:00:00', opentime = '2026-07-30 00:00:00',
preopenAt = '',
turntime = '2026-07-30 00:05:00', turntime = '2026-07-30 00:05:00',
turnTerm = 5,
scenarioTitle = '',
npcMode = 0,
defaultStatTotal = 165,
korName = 'hwe',
otherTextInfo = '',
autorunUser = null,
lobbyBundleFailures = 0, lobbyBundleFailures = 0,
profileStatus = 'RUNNING', profileStatus = 'RUNNING',
includeStoppedProfile = false, includeStoppedProfile = false,
@@ -134,7 +153,7 @@ const installFixture = async (page: Page, options: LobbyFixtureOptions = {}) =>
battleSimRunning: true, battleSimRunning: true,
tournamentRunning: true, tournamentRunning: true,
}, },
korName: 'hwe', korName,
color: '#ffffff', color: '#ffffff',
localAccountPolicy: { localAccountPolicy: {
accessAllowed: true, accessAllowed: true,
@@ -223,12 +242,17 @@ const installFixture = async (page: Page, options: LobbyFixtureOptions = {}) =>
maxUserCnt, maxUserCnt,
npcCnt: 0, npcCnt: 0,
nationCnt, nationCnt,
turnTerm: 5, turnTerm,
fictionMode: '가상', fictionMode: '가상',
starttime, starttime,
opentime, opentime,
preopenAt,
turntime, turntime,
otherTextInfo: '', otherTextInfo,
scenarioTitle,
npcMode,
defaultStatTotal,
autorunUser,
isUnited, isUnited,
selectionPoolEnabled, selectionPoolEnabled,
npcPossessionEnabled, npcPossessionEnabled,
@@ -279,6 +303,118 @@ test('exchanges the gateway token before loading authenticated lobby general dat
}); });
}); });
test('copies the complete preopen announcement and reveals autorun details without changing layout', async ({
page,
}, testInfo) => {
await installFixture(page, {
roles: ['superuser'],
kakaoVerified: false,
profileStatus: 'PREOPEN',
korName: '훼',
specialAccess: {
kind: 'OPERATOR',
grantId: null,
expiresAt: null,
allowsGeneralCreation: true,
},
preopenAt: '2026-08-19 22:00:00',
opentime: '2026-08-19 23:00:00',
starttime: '2026-08-19 23:00:00',
turnTerm: 1,
scenarioTitle: '【가상모드27-b】 아시아 명장전(비급)',
npcMode: 0,
defaultStatTotal: 310,
autorunUser: {
limitMinutes: 1_440,
options: ['develop', 'warp', 'recruit_high', 'train', 'battle', 'chief'],
},
});
await page.setViewportSize({ width: 1200, height: 900 });
await page.goto('lobby');
const row = page.locator('tbody tr').filter({ hasText: '훼섭' });
const serverName = row.locator('.profile-server-cell .font-bold');
const settings = row.locator('.profile-announcement-settings');
const autorun = row.locator('.copyable-autorun');
const detail = row.locator('.copyable-autorun-detail');
await expect(row.getByTestId('profile-preopen-at')).toHaveText('- 가오픈 일시 : 2026-08-19 22:00:00 -');
await expect(row.getByTestId('profile-open-at')).toHaveText('- 오픈 일시 : 2026-08-19 23:00:00 -');
await expect(row.getByTestId('profile-scenario-announcement')).toHaveText(
'【가상모드27-b】 아시아 명장전(비급) 1분 턴 서버'
);
const settingsText = (await settings.textContent())?.replace(/\s+/g, ' ').trim();
expect(settingsText).toBe(
'(상성 설정:가상), (빙의 여부:불가), (최대 스탯:310), ' +
'(기타 설정:자율행동[내정, 순간이동, 모병, 훈련/사기진작, 출병, 사령턴, 24시간 유효])'
);
await expect(detail).toHaveCSS('font-size', '0px');
await expect(detail).toHaveCSS('color', 'rgba(0, 0, 0, 0)');
await expect(page.getByText('특수 접근 · OPERATOR')).toHaveCount(0);
await expect(page.getByText('카카오 인증이 필요합니다.')).toHaveCount(0);
const baseGeometry = await row.evaluate((element) => ({
row: element.getBoundingClientRect().toJSON(),
documentWidth: document.documentElement.scrollWidth,
}));
await autorun.hover();
await expect(detail).toBeVisible();
await expect(detail).toContainText('내정, 순간이동, 모병, 훈련/사기진작, 출병, 사령턴, 24시간 유효');
const hoverGeometry = await row.evaluate((element) => ({
row: element.getBoundingClientRect().toJSON(),
documentWidth: document.documentElement.scrollWidth,
}));
expect(hoverGeometry).toEqual(baseGeometry);
await page.screenshot({ path: testInfo.outputPath('gateway-autorun-announcement-hover.png'), fullPage: true });
await autorun.focus();
await expect(autorun).toBeFocused();
await expect(detail).toBeVisible();
await expect(autorun).toHaveCSS('outline-width', '2px');
await page.mouse.click(8, 8);
const start = await serverName.boundingBox();
const end = await settings.boundingBox();
if (!start || !end) throw new Error('expected announcement selection geometry');
await page.mouse.move(start.x + 1, start.y + start.height / 2);
await page.mouse.down();
await page.mouse.move(end.x + end.width - 1, end.y + end.height / 2, { steps: 24 });
await page.mouse.up();
const selectedText = await page.evaluate(() => window.getSelection()?.toString() ?? '');
const compactSelection = selectedText.replace(/\s+/g, ' ').trim();
expect(compactSelection).toContain(
'훼섭 - 가오픈 일시 : 2026-08-19 22:00:00 - - 오픈 일시 : 2026-08-19 23:00:00 - ' +
'【가상모드27-b】 아시아 명장전(비급) 1분 턴 서버 ' +
'(상성 설정:가상), (빙의 여부:불가), (최대 스탯:310), ' +
'(기타 설정:자율행동[내정, 순간이동, 모병, 훈련/사기진작, 출병, 사령턴, 24시간 유효])'
);
expect(compactSelection).not.toContain('OPERATOR');
await page.evaluate(() => window.getSelection()?.removeAllRanges());
await page.setViewportSize({ width: 390, height: 844 });
await autorun.scrollIntoViewIfNeeded();
const mobileBase = await row.evaluate((element) => ({
row: element.getBoundingClientRect().toJSON(),
documentWidth: document.documentElement.scrollWidth,
}));
await autorun.hover();
await expect(detail).toBeVisible();
const mobileHover = await row.evaluate((element) => {
const tooltip = element.querySelector('.copyable-autorun-detail');
if (!tooltip) throw new Error('expected autorun tooltip');
return {
row: element.getBoundingClientRect().toJSON(),
tooltip: tooltip.getBoundingClientRect().toJSON(),
documentWidth: document.documentElement.scrollWidth,
viewportWidth: window.innerWidth,
};
});
expect(mobileHover.row).toEqual(mobileBase.row);
expect(mobileHover.documentWidth).toBe(mobileHover.viewportWidth);
expect(mobileHover.tooltip.left).toBeGreaterThanOrEqual(8);
expect(mobileHover.tooltip.right).toBeLessThanOrEqual(mobileHover.viewportWidth - 8);
await page.screenshot({ path: testInfo.outputPath('gateway-autorun-announcement-mobile.png'), fullPage: true });
});
test('loads and labels a PAUSED profile whose runtime remains available', async ({ page }, testInfo) => { test('loads and labels a PAUSED profile whose runtime remains available', async ({ page }, testInfo) => {
const gameOperations = await installFixture(page, { profileStatus: 'PAUSED' }); const gameOperations = await installFixture(page, { profileStatus: 'PAUSED' });
await page.setViewportSize({ width: 1365, height: 900 }); await page.setViewportSize({ width: 1365, height: 900 });
@@ -484,7 +620,7 @@ test('hides the Kakao verification banner for operator special access', async ({
}); });
await page.goto('lobby'); await page.goto('lobby');
await expect(page.getByText('특수 접근 · OPERATOR')).toBeVisible(); await expect(page.getByText('특수 접근 · OPERATOR')).toHaveCount(0);
await expect(page.getByText('카카오 인증이 필요합니다.')).toHaveCount(0); await expect(page.getByText('카카오 인증이 필요합니다.')).toHaveCount(0);
}); });
@@ -502,7 +638,7 @@ test('hides the Kakao verification banner when a grant removes the remaining ver
}); });
await page.goto('lobby'); await page.goto('lobby');
await expect(page.getByText('특수 접근 · RECOVERY')).toBeVisible(); await expect(page.getByText('특수 접근 · RECOVERY')).toHaveCount(0);
await expect(page.getByText('카카오 인증이 필요합니다.')).toHaveCount(0); await expect(page.getByText('카카오 인증이 필요합니다.')).toHaveCount(0);
}); });
+157 -9
View File
@@ -106,6 +106,34 @@ const handleMapTabKeydown = (event: KeyboardEvent, profileName: string): void =>
const formatGraceEndsAt = (value: string | null | undefined): string => formatServerDateTime(value); const formatGraceEndsAt = (value: string | null | undefined): string => formatServerDateTime(value);
const serverSeasonStatus = (info: LobbyInfo) => resolveServerSeasonStatus(info); const serverSeasonStatus = (info: LobbyInfo) => resolveServerSeasonStatus(info);
const formatAnnouncementDate = (value: string | null | undefined): string =>
formatServerDateTime(value, { fallback: '-' });
const npcModeText = (mode: number): string => ['불가', '가능', '선택 생성'][mode] ?? '불가';
const autorunDetailText = (info: LobbyInfo): string => {
const autorun = info.autorunUser;
if (!autorun) return '';
const enabled = new Set(autorun.options);
const labels: string[] = [];
if (enabled.has('develop')) labels.push('내정');
if (enabled.has('warp')) labels.push('순간이동');
if (enabled.has('recruit_high')) labels.push('모병');
else if (enabled.has('recruit')) labels.push('징병');
if (enabled.has('train')) labels.push('훈련/사기진작');
if (enabled.has('battle')) labels.push('출병');
if (enabled.has('chief')) labels.push('사령턴');
const limit =
autorun.limitMinutes >= 43_200
? '항상 유효'
: autorun.limitMinutes % 60 === 0
? `${autorun.limitMinutes / 60}시간 유효`
: `${autorun.limitMinutes}분 유효`;
labels.push(limit);
return labels.join(', ');
};
const autorunTooltipId = (profileName: string): string =>
`profile-autorun-${profileName.replaceAll(/[^a-zA-Z0-9_-]/g, '-')}`;
const isProfileRuntimeAvailable = (profile: LobbyProfile): boolean => profile.lifecycle.userAccessible; const isProfileRuntimeAvailable = (profile: LobbyProfile): boolean => profile.lifecycle.userAccessible;
const unavailableProfileText = (profile: LobbyProfile): string => { const unavailableProfileText = (profile: LobbyProfile): string => {
if (!profile.lifecycle.dataInitialized) return '- DB 초기화 전 · 접근 불가 -'; if (!profile.lifecycle.dataInitialized) return '- DB 초기화 전 · 접근 불가 -';
@@ -455,13 +483,7 @@ const handleEnter = async (profile: LobbyProfile, targetPath: string) => {
일시정지 · 조회/예약턴 가능 일시정지 · 조회/예약턴 가능
</div> </div>
<div <div
v-if="profile.localAccountPolicy?.specialAccess" v-if="
class="mt-2 text-xs text-emerald-300"
>
특수 접근 · {{ profile.localAccountPolicy.specialAccess.kind }}
</div>
<div
v-else-if="
profile.localAccountPolicy?.requiresKakaoVerification && profile.localAccountPolicy?.requiresKakaoVerification &&
!profile.localAccountPolicy.canCreateGeneral !profile.localAccountPolicy.canCreateGeneral
" "
@@ -481,6 +503,41 @@ const handleEnter = async (profile: LobbyProfile, targetPath: string) => {
<td class="profile-info-cell px-4 py-4 border-r border-zinc-800"> <td class="profile-info-cell px-4 py-4 border-r border-zinc-800">
<template v-if="profileDetails[profile.profileName]"> <template v-if="profileDetails[profile.profileName]">
<div class="space-y-1"> <div class="space-y-1">
<template v-if="profile.status === 'PREOPEN'">
<div
v-if="profileDetails[profile.profileName]?.preopenAt"
data-testid="profile-preopen-at"
>
- 가오픈 일시 :
{{
formatAnnouncementDate(
profileDetails[profile.profileName]?.preopenAt
)
}}
-
</div>
<div data-testid="profile-open-at">
- 오픈 일시 :
{{
formatAnnouncementDate(
profileDetails[profile.profileName]?.opentime ||
profileDetails[profile.profileName]?.starttime
)
}}
-
</div>
<div data-testid="profile-scenario-announcement">
<span class="text-orange-400">{{
profileDetails[profile.profileName]?.scenarioTitle ||
profile.scenario
}}</span
>{{ ' ' }}
<span class="text-green-400">
{{ profileDetails[profile.profileName]?.turnTerm }}분 턴 서버
</span>
</div>
</template>
<template v-else>
<div> <div>
서기 {{ profileDetails[profile.profileName]?.year }}년 서기 {{ profileDetails[profile.profileName]?.year }}년
{{ profileDetails[profile.profileName]?.month }}월 (<span {{ profileDetails[profile.profileName]?.month }}월 (<span
@@ -499,9 +556,38 @@ const handleEnter = async (profile: LobbyProfile, targetPath: string) => {
서버)</span 서버)</span
> >
</div> </div>
<div class="text-xs text-zinc-500"> </template>
<div class="profile-announcement-settings text-xs text-zinc-500">
(상성 설정:{{ profileDetails[profile.profileName]?.fictionMode }}), (상성 설정:{{ profileDetails[profile.profileName]?.fictionMode }}),
(기타 설정:{{ profileDetails[profile.profileName]?.otherTextInfo }}) <template v-if="profile.status === 'PREOPEN'">
(빙의 여부:{{
npcModeText(profileDetails[profile.profileName]?.npcMode ?? 0)
}}), (최대 스탯:{{
profileDetails[profile.profileName]?.defaultStatTotal
}}),
</template>
(기타 설정:<template
v-if="profileDetails[profile.profileName]?.otherTextInfo"
>{{ profileDetails[profile.profileName]?.otherTextInfo
}}<template v-if="profileDetails[profile.profileName]?.autorunUser"
>,
</template></template
><span
v-if="profileDetails[profile.profileName]?.autorunUser"
class="copyable-autorun"
tabindex="0"
:aria-describedby="autorunTooltipId(profile.profileName)"
>자율행동<span
:id="autorunTooltipId(profile.profileName)"
class="copyable-autorun-detail"
role="tooltip"
><span class="copyable-autorun-bracket">[</span
><span>{{
autorunDetailText(profileDetails[profile.profileName]!)
}}</span
><span class="copyable-autorun-bracket">]</span></span
></span
>)
</div> </div>
</div> </div>
</template> </template>
@@ -793,6 +879,68 @@ const handleEnter = async (profile: LobbyProfile, targetPath: string) => {
min-width: 760px; min-width: 760px;
} }
.season-status {
user-select: none;
}
.copyable-autorun {
position: relative;
cursor: help;
text-decoration: underline;
text-underline-offset: 2px;
}
.copyable-autorun-detail {
display: inline;
color: transparent;
font-size: 0;
}
.copyable-autorun-bracket {
color: transparent;
font-size: 0;
}
.copyable-autorun:hover .copyable-autorun-detail,
.copyable-autorun:focus-visible .copyable-autorun-detail {
position: absolute;
z-index: 30;
right: 0;
bottom: calc(100% + 6px);
display: block;
box-sizing: border-box;
width: max-content;
max-width: min(520px, calc(100vw - 32px));
padding: 6px 8px;
border: 1px solid #52525b;
border-radius: 4px;
background: #18181b;
box-shadow: 0 4px 12px rgb(0 0 0 / 45%);
color: #f4f4f5;
font-size: 12px;
line-height: 1.4;
text-align: left;
white-space: normal;
}
.copyable-autorun:focus-visible {
border-radius: 2px;
outline: 2px solid #fdba74;
outline-offset: 2px;
}
@media (max-width: 640px) {
.copyable-autorun:hover .copyable-autorun-detail,
.copyable-autorun:focus-visible .copyable-autorun-detail {
position: fixed;
right: 16px;
bottom: 16px;
left: 16px;
width: auto;
max-width: none;
}
}
.map-preview-tabs { .map-preview-tabs {
display: flex; display: flex;
gap: 4px; gap: 4px;