diff --git a/app/game-api/src/turns/commandTable.ts b/app/game-api/src/turns/commandTable.ts index b05b6fc3..fcafd164 100644 --- a/app/game-api/src/turns/commandTable.ts +++ b/app/game-api/src/turns/commandTable.ts @@ -48,6 +48,7 @@ export interface TurnCommandAvailability { name: string; turnDurationText?: string; costText?: string; + statExperienceText?: string; reqArg: boolean; possible: boolean; status: AvailabilityStatus; @@ -151,6 +152,39 @@ const REF_GENERAL_COMMAND_GROUPS = [ commands: ReadonlyArray; }>; +// Ref 명령 선택기의 경험 종류를 복원하며, 결과나 병종에 따라 달라지는 경우는 따로 표시한다. +const GENERAL_COMMAND_STAT_EXPERIENCE = { + '통솔 경험': [ + 'che_강행', + 'che_귀환', + 'che_등용', + 'che_모병', + 'che_사기진작', + 'che_선동', + 'che_숙련전환', + 'che_이동', + 'che_전투태세', + 'che_정착장려', + 'che_주민선정', + 'che_증여', + 'che_집합', + 'che_징병', + 'che_첩보', + 'che_헌납', + 'che_훈련', + 'cr_맹훈련', + ], + '무력 경험': ['che_성벽보수', 'che_수비강화', 'che_치안강화', 'che_탈취', 'che_파괴'], + '지력 경험': ['che_기술연구', 'che_농지개간', 'che_상업투자', 'che_화계'], + '무작위 능력치 경험': ['che_군량매매', 'che_단련', 'che_물자조달', 'che_인재탐색'], + '무작위 능력치 경험 가능': ['che_견문'], + '병종별 능력치 경험': ['che_출병'], +} as const satisfies Record; + +const statExperienceByCommand = new Map( + Object.entries(GENERAL_COMMAND_STAT_EXPERIENCE).flatMap(([text, keys]) => keys.map((key) => [key, text] as const)) +); + const REF_NATION_COMMAND_GROUPS = [ { category: '휴식', @@ -858,11 +892,13 @@ const buildGroups = ( // 개인·국가 모두 실행 정의의 준비 턴과 마지막 실행 턴을 표시한다. const turnDurationText = getTurnDurationText(entry.definition); const costText = getCommandCostText(entry, ctx, view, env); + const statExperienceText = scope === 'general' ? statExperienceByCommand.get(entry.definition.key) : undefined; const value: TurnCommandAvailability = { key: entry.definition.key, name: entry.definition.name, ...(turnDurationText ? { turnDurationText } : {}), ...(costText ? { costText } : {}), + ...(statExperienceText ? { statExperienceText } : {}), reqArg: entry.reqArg, inputFields: entry.inputFields, ...availability, diff --git a/app/game-api/test/commandTable.test.ts b/app/game-api/test/commandTable.test.ts index bc8a21eb..d66d1cd8 100644 --- a/app/game-api/test/commandTable.test.ts +++ b/app/game-api/test/commandTable.test.ts @@ -504,6 +504,37 @@ describe('buildTurnCommandTable', () => { } }); + it('projects stat experience hints for general commands without promising a fixed stat increase', async () => { + const table = await buildTurnCommandTable({ + worldState: buildWorldState(), + general: buildGeneral(), + city: buildCity(), + nation: buildNation(), + nationGenerals: null, + }); + const find = (key: string) => table.general.flatMap(({ values }) => values).find((entry) => entry.key === key); + const expected = { + che_선동: '통솔 경험', + che_탈취: '무력 경험', + che_파괴: '무력 경험', + che_화계: '지력 경험', + che_이동: '통솔 경험', + che_수비강화: '무력 경험', + che_상업투자: '지력 경험', + che_물자조달: '무작위 능력치 경험', + che_인재탐색: '무작위 능력치 경험', + che_견문: '무작위 능력치 경험 가능', + che_출병: '병종별 능력치 경험', + }; + for (const [key, statExperienceText] of Object.entries(expected)) { + expect(find(key)).toMatchObject({ statExperienceText }); + } + expect(find('휴식')?.statExperienceText).toBeUndefined(); + expect( + table.nation.flatMap(({ values }) => values).every(({ statExperienceText }) => !statExperienceText) + ).toBe(true); + }); + it('projects the Ref twenty-year non-aggression end-year window', async () => { const table = await buildTurnCommandTable({ worldState: buildWorldState(), diff --git a/app/game-frontend/e2e/commandArguments.spec.ts b/app/game-frontend/e2e/commandArguments.spec.ts index f80d2425..fdad2d2d 100644 --- a/app/game-frontend/e2e/commandArguments.spec.ts +++ b/app/game-frontend/e2e/commandArguments.spec.ts @@ -1545,6 +1545,77 @@ test('shows speciality reset cooldowns and reserves special user commands from t await picker.screenshot({ path: test.info().outputPath('special-user-commands-mobile-500.png') }); }); +test('shows stat experience next to strategy commands and preserves reservation on desktop and mobile', async ({ + page, +}, testInfo) => { + const strategy = commandTable.general.find(({ category }) => category === '계략')!; + const requests = await install(page, false, { + general: [ + { + ...strategy, + values: strategy.values.map((command, index) => ({ + ...command, + statExperienceText: ['지력 경험', '통솔 경험', '무력 경험', '무력 경험'][index], + costText: '금 500 · 쌀 500', + })), + }, + ], + nation: [], + inputOptions, + }); + for (const viewport of [ + { width: 1365, height: 900 }, + { width: 390, height: 844 }, + ]) { + await page.setViewportSize(viewport); + await page.goto(gamePath('/')); + await page.getByRole('button', { name: '1턴 명령 입력', exact: true }).click(); + const picker = page.getByTestId('command-picker'); + const fire = picker.getByRole('button', { name: /화계.*지력 경험/ }); + await expect(picker.locator('.command-stat-experience')).toHaveText([ + '(지력 경험)', + '(통솔 경험)', + '(무력 경험)', + '(무력 경험)', + ]); + await expect(fire.locator('.command-cost')).toHaveText('금 500 · 쌀 500'); + await expect(fire).toHaveClass(/blocked reservable/); + await expect(fire).toHaveAttribute('title', '현재 조건에서는 실행할 수 없습니다.'); + await expect(fire).toBeEnabled(); + await page.evaluate(() => document.fonts.ready); + await fire.hover(); + await fire.focus(); + await expect(fire).toBeFocused(); + const geometry = await picker.locator('.command-item').evaluateAll((buttons) => + buttons.map((button) => { + const experience = button.querySelector('.command-stat-experience')!; + return { + button: button.getBoundingClientRect().toJSON(), + hint: experience.getBoundingClientRect().toJSON(), + overflow: button.scrollWidth - button.clientWidth, + hintFont: getComputedStyle(experience).font, + }; + }) + ); + expect(geometry.every(({ button, hint, overflow }) => overflow <= 0 && hint.right <= button.right)).toBe(true); + const artifact = `general-stat-experience-${viewport.width}`; + await writeFile( + testInfo.outputPath(`${artifact}.json`), + JSON.stringify({ url: page.url(), geometry }, null, 2) + ); + await writeFile(testInfo.outputPath(`${artifact}.html`), await picker.evaluate((element) => element.outerHTML)); + await picker.screenshot({ path: testInfo.outputPath(`${artifact}.png`) }); + await fire.click(); + const form = page.getByTestId('command-argument-form'); + await form.locator('select').first().selectOption('2'); + await page.getByRole('button', { name: '화계 입력', exact: true }).click(); + await expect(page.locator('[data-command-scope="general"] .action-column > div').first()).toHaveText( + '【허창】에 화계실행' + ); + } + expect(JSON.stringify(requests)).toContain('"action":"che_화계","args":{"destCityId":2}'); +}); + test('shows general command durations from metadata on desktop and mobile', async ({ page }) => { const requests = await install(page, false, { general: [ diff --git a/app/game-frontend/src/components/command/types.ts b/app/game-frontend/src/components/command/types.ts index 8494fb35..b51a6599 100644 --- a/app/game-frontend/src/components/command/types.ts +++ b/app/game-frontend/src/components/command/types.ts @@ -86,6 +86,7 @@ export type CommandAvailability = { name: string; turnDurationText?: string; costText?: string; + statExperienceText?: string; reqArg: boolean; status: 'available' | 'blocked' | 'needsInput' | 'unknown'; possible: boolean; diff --git a/app/game-frontend/src/components/main/CommandSelectForm.vue b/app/game-frontend/src/components/main/CommandSelectForm.vue index 9c672d5c..a3a33b9c 100644 --- a/app/game-frontend/src/components/main/CommandSelectForm.vue +++ b/app/game-frontend/src/components/main/CommandSelectForm.vue @@ -1,30 +1,10 @@