장수 명령 선택기에 능력치 경험 종류를 복원한다
This commit is contained in:
1 parent
bebd4848b4
commit
0ed2f4a80b
5 files changed
+154
-23
No files matched your search
@@ -48,6 +48,7 @@ export interface TurnCommandAvailability {
|
|||||||
name: string;
|
name: string;
|
||||||
turnDurationText?: string;
|
turnDurationText?: string;
|
||||||
costText?: string;
|
costText?: string;
|
||||||
|
statExperienceText?: string;
|
||||||
reqArg: boolean;
|
reqArg: boolean;
|
||||||
possible: boolean;
|
possible: boolean;
|
||||||
status: AvailabilityStatus;
|
status: AvailabilityStatus;
|
||||||
@@ -151,6 +152,39 @@ const REF_GENERAL_COMMAND_GROUPS = [
|
|||||||
commands: ReadonlyArray<GeneralTurnCommandKey>;
|
commands: ReadonlyArray<GeneralTurnCommandKey>;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
// 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<string, readonly GeneralTurnCommandKey[]>;
|
||||||
|
|
||||||
|
const statExperienceByCommand = new Map<string, string>(
|
||||||
|
Object.entries(GENERAL_COMMAND_STAT_EXPERIENCE).flatMap(([text, keys]) => keys.map((key) => [key, text] as const))
|
||||||
|
);
|
||||||
|
|
||||||
const REF_NATION_COMMAND_GROUPS = [
|
const REF_NATION_COMMAND_GROUPS = [
|
||||||
{
|
{
|
||||||
category: '휴식',
|
category: '휴식',
|
||||||
@@ -858,11 +892,13 @@ const buildGroups = (
|
|||||||
// 개인·국가 모두 실행 정의의 준비 턴과 마지막 실행 턴을 표시한다.
|
// 개인·국가 모두 실행 정의의 준비 턴과 마지막 실행 턴을 표시한다.
|
||||||
const turnDurationText = getTurnDurationText(entry.definition);
|
const turnDurationText = getTurnDurationText(entry.definition);
|
||||||
const costText = getCommandCostText(entry, ctx, view, env);
|
const costText = getCommandCostText(entry, ctx, view, env);
|
||||||
|
const statExperienceText = scope === 'general' ? statExperienceByCommand.get(entry.definition.key) : undefined;
|
||||||
const value: TurnCommandAvailability = {
|
const value: TurnCommandAvailability = {
|
||||||
key: entry.definition.key,
|
key: entry.definition.key,
|
||||||
name: entry.definition.name,
|
name: entry.definition.name,
|
||||||
...(turnDurationText ? { turnDurationText } : {}),
|
...(turnDurationText ? { turnDurationText } : {}),
|
||||||
...(costText ? { costText } : {}),
|
...(costText ? { costText } : {}),
|
||||||
|
...(statExperienceText ? { statExperienceText } : {}),
|
||||||
reqArg: entry.reqArg,
|
reqArg: entry.reqArg,
|
||||||
inputFields: entry.inputFields,
|
inputFields: entry.inputFields,
|
||||||
...availability,
|
...availability,
|
||||||
|
|||||||
@@ -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 () => {
|
it('projects the Ref twenty-year non-aggression end-year window', async () => {
|
||||||
const table = await buildTurnCommandTable({
|
const table = await buildTurnCommandTable({
|
||||||
worldState: buildWorldState(),
|
worldState: buildWorldState(),
|
||||||
|
|||||||
@@ -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') });
|
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 }) => {
|
test('shows general command durations from metadata on desktop and mobile', async ({ page }) => {
|
||||||
const requests = await install(page, false, {
|
const requests = await install(page, false, {
|
||||||
general: [
|
general: [
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ export type CommandAvailability = {
|
|||||||
name: string;
|
name: string;
|
||||||
turnDurationText?: string;
|
turnDurationText?: string;
|
||||||
costText?: string;
|
costText?: string;
|
||||||
|
statExperienceText?: string;
|
||||||
reqArg: boolean;
|
reqArg: boolean;
|
||||||
status: 'available' | 'blocked' | 'needsInput' | 'unknown';
|
status: 'available' | 'blocked' | 'needsInput' | 'unknown';
|
||||||
possible: boolean;
|
possible: boolean;
|
||||||
|
|||||||
@@ -1,30 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
import type { CommandAvailability, CommandGroup, CommandTable } from '../command/types';
|
||||||
import SkeletonLines from '../ui/SkeletonLines.vue';
|
import SkeletonLines from '../ui/SkeletonLines.vue';
|
||||||
|
|
||||||
type CommandAvailability = {
|
|
||||||
key: string;
|
|
||||||
name: string;
|
|
||||||
turnDurationText?: string;
|
|
||||||
costText?: string;
|
|
||||||
reqArg: boolean;
|
|
||||||
status: 'available' | 'blocked' | 'needsInput' | 'unknown';
|
|
||||||
possible: boolean;
|
|
||||||
reason?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
type CommandGroup = {
|
|
||||||
category: string;
|
|
||||||
values: CommandAvailability[];
|
|
||||||
};
|
|
||||||
|
|
||||||
type CommandTable = {
|
|
||||||
general: CommandGroup[];
|
|
||||||
nation: CommandGroup[];
|
|
||||||
};
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
commandTable: CommandTable | null;
|
commandTable: Pick<CommandTable, 'general' | 'nation'> | null;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
activeCategory?: string;
|
activeCategory?: string;
|
||||||
scope?: 'all' | 'general' | 'nation';
|
scope?: 'all' | 'general' | 'nation';
|
||||||
@@ -162,7 +142,12 @@ const commandTitle = (command: CommandAvailability) =>
|
|||||||
:title="commandTitle(command)"
|
:title="commandTitle(command)"
|
||||||
@click="emit('select', command.key)"
|
@click="emit('select', command.key)"
|
||||||
>
|
>
|
||||||
<span class="command-name">{{ command.name }}</span>
|
<span class="command-heading">
|
||||||
|
<span class="command-name">{{ command.name }}</span>
|
||||||
|
<small v-if="command.statExperienceText" class="command-stat-experience">
|
||||||
|
({{ command.statExperienceText }})
|
||||||
|
</small>
|
||||||
|
</span>
|
||||||
<small v-if="command.turnDurationText" class="command-duration">
|
<small v-if="command.turnDurationText" class="command-duration">
|
||||||
/{{ command.turnDurationText }}
|
/{{ command.turnDurationText }}
|
||||||
</small>
|
</small>
|
||||||
@@ -249,6 +234,13 @@ const commandTitle = (command: CommandAvailability) =>
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.command-stat-experience {
|
||||||
|
display: inline-block;
|
||||||
|
margin-inline-start: 0.3em;
|
||||||
|
font-size: var(--sammo-font-size-smaller);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
.command-duration {
|
.command-duration {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: var(--sammo-font-size-small);
|
font-size: var(--sammo-font-size-small);
|
||||||
|
|||||||
Reference in new issue
Block a user