From 3a5dd5fd09ed6a46b2ce9cadfebc987390d1a98a Mon Sep 17 00:00:00 2001 From: hided62 Date: Wed, 12 Aug 2026 15:33:08 +0000 Subject: [PATCH] fix: render neutral main nation and trait names --- app/game-api/src/router/general/index.ts | 39 +++++++-- .../test/inGameMenuPermissions.test.ts | 34 ++++++++ app/game-frontend/e2e/inGameMenus.spec.ts | 79 ++++++++++++++++++- .../src/components/main/NationBasicCard.vue | 18 +++-- 4 files changed, 156 insertions(+), 14 deletions(-) diff --git a/app/game-api/src/router/general/index.ts b/app/game-api/src/router/general/index.ts index e5633a18..0ca59a00 100644 --- a/app/game-api/src/router/general/index.ts +++ b/app/game-api/src/router/general/index.ts @@ -18,7 +18,7 @@ import { ConflictingTurnDaemonCommandError } from '../../daemon/databaseTranspor import { resolveAccessWindows } from '../../services/generalAccess.js'; import { adjustAccountIconForUser } from '../../services/accountIconSync.js'; import { getMyGeneral } from '../shared/general.js'; -import { resolveNationNotice } from '../nation/shared.js'; +import { loadTraitNames, resolveNationNotice, type TraitNameMap } from '../nation/shared.js'; const zGeneralSettings = z.object({ tnmt: z.number().int().optional(), @@ -34,6 +34,17 @@ const zImmediateActionInput = z }) .optional(); const MAIN_RECORD_LIMIT = 15; +const NEUTRAL_NATION_CONTEXT = { + id: 0, + name: '재야', + color: '#000000', + level: 0, + gold: 0, + rice: 0, + tech: 0, + typeCode: 'None', + capitalCityId: null, +} as const; const resolveImmediateActionRequestId = ( contextRequestId: string | undefined, @@ -135,6 +146,18 @@ const normalizeItemCode = (value: string | null): string | null => { return value; }; +const resolveTraitDisplayName = (code: string, names: TraitNameMap): string => { + if (!code || code === 'None') { + return '-'; + } + const loadedName = names.get(code)?.name; + if (loadedName) { + return loadedName; + } + // Ref는 class getName()을 표시하므로 로더가 모르는 선택적 특기도 raw namespace는 노출하지 않는다. + return code.replace(/^che_(?:event_)?/u, ''); +}; + const resolveUserSettings = (meta: Record) => { // The legacy general columns are persisted at the top level of General.meta. // Keep reading the short-lived nested shape for installations that ran the @@ -265,10 +288,16 @@ export const getGeneralContext = async (ctx: GameApiContext) => { capitalCityId: true, }, }) - : null, + : Promise.resolve(NEUTRAL_NATION_CONTEXT), ctx.db.worldState.findFirst({ select: { config: true } }), ]); + const [personalityNames, domesticNames, warNames] = await Promise.all([ + loadTraitNames([general.personalCode], 'personality'), + loadTraitNames([general.specialCode], 'domestic'), + loadTraitNames([general.special2Code], 'war'), + ]); + const metaRecord = asRecord(general.meta); const worldConfig = asRecord(worldState?.config); const constValues = asRecord(worldConfig.const ?? worldConfig.consts); @@ -303,9 +332,9 @@ export const getGeneralContext = async (ctx: GameApiContext) => { turnTime: general.turnTime.toISOString(), crewTypeId: general.crewTypeId, traits: { - personal: general.personalCode, - specialWar: general.specialCode, - specialDomestic: general.special2Code, + personal: resolveTraitDisplayName(general.personalCode, personalityNames), + specialDomestic: resolveTraitDisplayName(general.specialCode, domesticNames), + specialWar: resolveTraitDisplayName(general.special2Code, warNames), }, progression: { experienceLevel: readNumber(metaRecord.explevel, 0), diff --git a/app/game-api/test/inGameMenuPermissions.test.ts b/app/game-api/test/inGameMenuPermissions.test.ts index a8f79a25..77c9dcd6 100644 --- a/app/game-api/test/inGameMenuPermissions.test.ts +++ b/app/game-api/test/inGameMenuPermissions.test.ts @@ -248,6 +248,40 @@ describe('in-game my information ownership', () => { ); }); + it('returns the Ref-style neutral nation frame and trait display names on the main read model', async () => { + const fixture = createContext({ + me: buildGeneral({ + nationId: 0, + officerLevel: 0, + personalCode: 'che_안전', + specialCode: 'che_상재', + special2Code: 'che_신산', + }), + }); + + await expect(appRouter.createCaller(fixture.context).general.me()).resolves.toMatchObject({ + general: { + traits: { + personal: '안전', + specialDomestic: '상재', + specialWar: '신산', + }, + }, + nation: { + id: 0, + name: '재야', + color: '#000000', + level: 0, + gold: 0, + rice: 0, + tech: 0, + typeCode: 'None', + capitalCityId: null, + }, + }); + expect(fixture.db.nation.findUnique).not.toHaveBeenCalled(); + }); + it('reads legacy top-level settings and dispatches only the session-owned general', async () => { const requestCommand = vi.fn(async () => ({ type: 'setMySetting', ok: true, generalId: 7 })); const fixture = createContext({ requestCommand }); diff --git a/app/game-frontend/e2e/inGameMenus.spec.ts b/app/game-frontend/e2e/inGameMenus.spec.ts index 9992ea83..33ceb619 100644 --- a/app/game-frontend/e2e/inGameMenus.spec.ts +++ b/app/game-frontend/e2e/inGameMenus.spec.ts @@ -45,6 +45,7 @@ type FixtureState = { adjustIconInputs?: Array>; joinConfig?: Record; createGeneralInputs?: Array>; + mainTraits?: { personal: string; specialDomestic: string; specialWar: string }; }; type TrpcRequestPayload = { @@ -75,7 +76,7 @@ const myGeneral = (state: FixtureState) => ({ age: 30, turnTime: '2026-01-01 00:10:00', crewTypeId: 1, - traits: { personal: 'None', specialDomestic: 'None', specialWar: 'None' }, + traits: state.mainTraits ?? { personal: '-', specialDomestic: '-', specialWar: '-' }, progression: { experienceLevel: 1, dedicationLevel: 2, @@ -86,7 +87,19 @@ const myGeneral = (state: FixtureState) => ({ items: { horse: 'che_명마', weapon: null, book: null, item: null }, }, city: { id: 1, name: '업', level: 8, nationId: 1 }, - nation: { id: 1, name: '위', color: '#777777', level: 3 }, + nation: state.buildNationCandidateEnabled + ? { + id: 0, + name: '재야', + color: '#000000', + level: 0, + gold: 0, + rice: 0, + tech: 0, + typeCode: 'None', + capitalCityId: null, + } + : { id: 1, name: '위', color: '#777777', level: 3 }, settings: { tnmt: 0, defence_train: 80, @@ -221,6 +234,25 @@ const install = async (page: Page, state: FixtureState) => { state.createGeneralInputs?.push(jsonInput); return response({ generalId: 9 }); } + if (operation === 'dashboard.getContextBundleDelta') { + return response({ + context: { + kind: 'snapshot', + revision: 'AAAAAAAAAAAAAAAAAAAAAA', + data: myGeneral(state), + }, + commandTable: { + kind: 'snapshot', + revision: 'BBBBBBBBBBBBBBBBBBBBBB', + data: { general: [], nation: [] }, + }, + boardAccess: { + kind: 'snapshot', + revision: 'CCCCCCCCCCCCCCCCCCCCCC', + data: { permission: 4, canMeeting: true, canSecret: true }, + }, + }); + } if (operation === 'general.me') { state.generalMeQueries = (state.generalMeQueries ?? 0) + 1; return response(myGeneral(state)); @@ -437,6 +469,49 @@ test('정화된 국가 방침은 실행 가능한 속성 없이 Chromium에 표 .toBeUndefined(); }); +test('재야 메인은 국가 틀과 성격·특기 표기명을 Chromium에 표시한다', async ({ page }) => { + const state: FixtureState = { + permission: 'member', + myset: 0, + buildNationCandidateEnabled: true, + mainTraits: { personal: '안전', specialDomestic: '상재', specialWar: '신산' }, + settingMutations: [], + accessPages: [], + }; + await install(page, state); + await page.setViewportSize({ width: 1000, height: 900 }); + await page.goto(''); + + const nationCard = page.locator('.nation-card'); + await expect(nationCard.locator('.title')).toHaveText('재야'); + await expect(nationCard.locator('.empty')).toHaveCount(0); + await expect(nationCard.locator('.grid strong')).toHaveText(Array.from({ length: 6 }, () => '해당 없음')); + + const generalCard = page.locator('.general-card'); + await expect(generalCard).toContainText('성격안전'); + await expect(generalCard).toContainText('전투특기신산'); + await expect(generalCard).toContainText('내정특기상재'); + await expect(generalCard).not.toContainText('che_'); + + const geometry = await nationCard.evaluate((element) => { + const rect = element.getBoundingClientRect(); + const title = element.querySelector('.title')!; + return { + width: rect.width, + height: rect.height, + titleBackground: getComputedStyle(title).backgroundColor, + placeholderCount: [...element.querySelectorAll('.grid strong')].filter( + (cell) => cell.textContent?.trim() === '해당 없음' + ).length, + }; + }); + expect(geometry.width).toBeGreaterThan(0); + expect(geometry.height).toBeGreaterThan(0); + expect(geometry.titleBackground).toBe('rgb(0, 0, 0)'); + expect(geometry.placeholderCount).toBe(6); + await persistParityArtifact(page, 'main-neutral-trait-display', geometry); +}); + test('접속량정보 keeps the legacy public 1016px chart geometry', async ({ page }) => { const state: FixtureState = { permission: 'member', myset: 0, settingMutations: [], accessPages: [] }; await install(page, state); diff --git a/app/game-frontend/src/components/main/NationBasicCard.vue b/app/game-frontend/src/components/main/NationBasicCard.vue index 5efa9097..6470648f 100644 --- a/app/game-frontend/src/components/main/NationBasicCard.vue +++ b/app/game-frontend/src/components/main/NationBasicCard.vue @@ -31,15 +31,19 @@ const props = defineProps<{ class="title" :style="{ backgroundColor: props.nation.color, color: legacyNationTextColor(props.nation.color) }" > - {{ props.nation.name }} (Lv {{ props.nation.level }}) + {{ props.nation.name }}
- 국고{{ props.nation.gold.toLocaleString() }} 국량{{ props.nation.rice.toLocaleString() }} 기술{{ props.nation.tech.toLocaleString() }} 체제{{ props.nation.typeCode }} 수도{{ props.nation.capitalCityId ?? '-' }} 국가 등급{{ props.nation.level }} + 국고{{ props.nation.id === 0 ? '해당 없음' : props.nation.gold.toLocaleString() }} + 국량{{ props.nation.id === 0 ? '해당 없음' : props.nation.rice.toLocaleString() }} + 기술{{ props.nation.id === 0 ? '해당 없음' : props.nation.tech.toLocaleString() }} + 체제{{ props.nation.id === 0 ? '해당 없음' : props.nation.typeCode }} + 수도{{ props.nation.id === 0 ? '해당 없음' : (props.nation.capitalCityId ?? '-') }} + 국가 등급{{ props.nation.id === 0 ? '해당 없음' : props.nation.level }}