감찰부 장수 카드에 특기와 장비 설명을 표시한다
This commit is contained in:
1 parent
8125d68c95
commit
bebd4848b4
3 files changed
+111
-6
No files matched your search
@@ -6,7 +6,7 @@ import { getBillByLevel, LogCategory } from '@sammo-ts/logic';
|
||||
import { accessAuthedProcedure } from '../../../trpc.js';
|
||||
import {
|
||||
loadCrewTypeDisplayNames,
|
||||
loadItemDisplayNames,
|
||||
loadItemDisplayDetails,
|
||||
resolveDedicationLevelName,
|
||||
resolveOfficerLevelName,
|
||||
sanitizeInternalDisplayCode,
|
||||
@@ -133,7 +133,7 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
|
||||
typeof constValues.maxDedLevel === 'number' && Number.isFinite(constValues.maxDedLevel)
|
||||
? Math.max(0, Math.trunc(constValues.maxDedLevel))
|
||||
: 30;
|
||||
const [personalityNames, domesticNames, warNames, crewTypeNames, itemNames] = await Promise.all([
|
||||
const [personalityNames, domesticNames, warNames, crewTypeNames, itemDetails] = await Promise.all([
|
||||
loadTraitNames(
|
||||
generalRows.map((general) => general.personalCode),
|
||||
'personality'
|
||||
@@ -147,7 +147,7 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
|
||||
'war'
|
||||
),
|
||||
loadCrewTypeDisplayNames(worldState, ctx.profile.id),
|
||||
loadItemDisplayNames(
|
||||
loadItemDisplayDetails(
|
||||
generalRows.flatMap((general) => [
|
||||
general.weaponCode,
|
||||
general.bookCode,
|
||||
@@ -158,7 +158,8 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
|
||||
]);
|
||||
const traitName = (code: string, names: Awaited<ReturnType<typeof loadTraitNames>>): string =>
|
||||
names.get(code)?.name ?? sanitizeInternalDisplayCode(code);
|
||||
const itemName = (code: string): string => itemNames.get(code) ?? sanitizeInternalDisplayCode(code);
|
||||
const itemName = (code: string): string => itemDetails.get(code)?.name ?? sanitizeInternalDisplayCode(code);
|
||||
const itemInfo = (code: string): string => itemDetails.get(code)?.info ?? '';
|
||||
|
||||
const generals = generalRows.map((general) => {
|
||||
const meta =
|
||||
@@ -225,11 +226,22 @@ export const getBattleCenter = accessAuthedProcedure.query(async ({ ctx }) => {
|
||||
horse: itemName(general.horseCode),
|
||||
item: itemName(general.itemCode),
|
||||
},
|
||||
itemInfo: {
|
||||
weapon: itemInfo(general.weaponCode),
|
||||
book: itemInfo(general.bookCode),
|
||||
horse: itemInfo(general.horseCode),
|
||||
item: itemInfo(general.itemCode),
|
||||
},
|
||||
traits: {
|
||||
personal: traitName(general.personalCode, personalityNames),
|
||||
specialDomestic: traitName(general.specialCode, domesticNames),
|
||||
specialWar: traitName(general.special2Code, warNames),
|
||||
},
|
||||
traitInfo: {
|
||||
personal: personalityNames.get(general.personalCode)?.info ?? '',
|
||||
specialDomestic: domesticNames.get(general.specialCode)?.info ?? '',
|
||||
specialWar: warNames.get(general.special2Code)?.info ?? '',
|
||||
},
|
||||
progression: {
|
||||
experienceLevel: metaNumber('explevel'),
|
||||
dedicationLevel,
|
||||
|
||||
@@ -1072,6 +1072,34 @@ describe('battle-center general and user permissions', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('projects registered trait and equipment descriptions for battle center viewers', async () => {
|
||||
const me = buildGeneral({ meta: { belong: 3 } });
|
||||
const other = buildGeneral({
|
||||
id: 8,
|
||||
personalCode: 'che_안전',
|
||||
specialCode: 'che_상재',
|
||||
special2Code: 'che_신산',
|
||||
horseCode: 'che_명마_15_적토마',
|
||||
weaponCode: 'unregistered',
|
||||
itemCode: 'che_내정_납금박산로',
|
||||
});
|
||||
const fixture = createContext({ me, targets: [me, other], nationMeta: { secretLimit: 3 } });
|
||||
const result = await appRouter.createCaller(fixture.context).nation.getBattleCenter();
|
||||
|
||||
expect(result.generals.find(({ id }) => id === other.id)).toMatchObject({
|
||||
traitInfo: {
|
||||
personal: expect.stringContaining('징·모병 비용'),
|
||||
specialDomestic: expect.stringContaining('상업 투자'),
|
||||
specialWar: expect.stringContaining('[계략] 화계·탈취·파괴·선동'),
|
||||
},
|
||||
itemInfo: { horse: '통솔 +15', weapon: '', book: '', item: '[내정] 내정 성공률 +15%p' },
|
||||
});
|
||||
expect(result.generals.find(({ id }) => id === me.id)).toMatchObject({
|
||||
traitInfo: { personal: '', specialDomestic: '', specialWar: '' },
|
||||
itemInfo: { horse: '', weapon: '', book: '', item: '' },
|
||||
});
|
||||
});
|
||||
|
||||
it('redacts another user action log while allowing own, NPC, chief, and non-private logs', async () => {
|
||||
const me = buildGeneral({ meta: { belong: 3, permission: 'normal' } });
|
||||
const otherUser = buildGeneral({ id: 8, userId: 'user-8', name: '타유저', npcState: 0 });
|
||||
|
||||
@@ -332,8 +332,14 @@ const battleCenter = (state: FixtureState) => ({
|
||||
crewTypeId: 1,
|
||||
crewTypeName: '보병',
|
||||
equipment: { weapon: 'None', book: 'None', horse: 'None', item: 'None' },
|
||||
equipmentNames: { weapon: '-', book: '-', horse: '-', item: '-' },
|
||||
traits: { personal: '-', specialDomestic: '-', specialWar: '-' },
|
||||
equipmentNames: state.richMyInfo
|
||||
? { weapon: '단도', book: '효경전', horse: '적토마(+15)', item: '납금박산로' }
|
||||
: { weapon: '-', book: '-', horse: '-', item: '-' },
|
||||
itemInfo: state.richMyInfo
|
||||
? { weapon: '무력 +1', book: '지력 +1', horse: '통솔 +15', item: '내정 성공률 +15%p' }
|
||||
: undefined,
|
||||
traits: state.mainTraits ?? { personal: '-', specialDomestic: '-', specialWar: '-' },
|
||||
traitInfo: state.richMyInfo ? myGeneral(state).general.traitInfo : undefined,
|
||||
progression: {
|
||||
experienceLevel: 1,
|
||||
dedicationLevel: 2,
|
||||
@@ -2714,6 +2720,65 @@ test('세력장수 이름 링크는 선택한 장수의 감찰부를 열고 목
|
||||
await expect(page.locator('#nation-general-list a[data-general-name]')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('감찰부 특기와 장비는 마우스와 키보드로 설명을 확인할 수 있다', async ({ page }) => {
|
||||
const state: FixtureState = {
|
||||
permission: 'head',
|
||||
myset: 3,
|
||||
richMyInfo: true,
|
||||
mainTraits: { personal: '안전', specialDomestic: '상재', specialWar: '신산' },
|
||||
settingMutations: [],
|
||||
accessPages: [],
|
||||
};
|
||||
await install(page, state);
|
||||
const card = page.locator('.battle-general-card');
|
||||
const tooltip = page.locator('.tippy-box[data-state="visible"]');
|
||||
for (const viewport of [
|
||||
{ width: 1365, height: 900 },
|
||||
{ width: 390, height: 844 },
|
||||
]) {
|
||||
await page.setViewportSize(viewport);
|
||||
await page.goto('battle-center?generalId=7');
|
||||
await expect(card).toContainText('검증장수');
|
||||
await waitForVisualAssets(page);
|
||||
const cardBefore = await card.boundingBox();
|
||||
for (const [id, description] of [
|
||||
['special-domestic', '상업 내정 효율이 증가합니다.'],
|
||||
['special-war', '계략 성공률이 증가합니다.'],
|
||||
['horse', '통솔 +15'],
|
||||
['item', '내정 성공률 +15%p'],
|
||||
]) {
|
||||
const trigger = card.locator(`[data-rich-tooltip="${id}"]`);
|
||||
await trigger.hover();
|
||||
await expect(trigger).toHaveCSS('cursor', 'help');
|
||||
await expect(tooltip).toContainText(description);
|
||||
await page.mouse.move(1, 1);
|
||||
await expect(tooltip).toHaveCount(0);
|
||||
}
|
||||
const war = card.locator('[data-rich-tooltip="special-war"]');
|
||||
await war.focus();
|
||||
await expect(war).toBeFocused();
|
||||
await expect(tooltip.locator('.rich-tooltip-content__line')).toHaveText([
|
||||
'계략 성공률이 증가합니다.',
|
||||
'발동 순서는 레거시와 같습니다.',
|
||||
]);
|
||||
const cardAfter = await card.boundingBox();
|
||||
expect(cardAfter?.width).toBe(cardBefore?.width);
|
||||
expect(cardAfter?.height).toBe(cardBefore?.height);
|
||||
await persistParityArtifact(page, `battle-center-description-${viewport.width}`, {
|
||||
url: page.url(),
|
||||
card: cardAfter,
|
||||
trigger: await war.boundingBox(),
|
||||
tooltip: await tooltip.boundingBox(),
|
||||
font: await tooltip.evaluate((element) => getComputedStyle(element).font),
|
||||
markup: await tooltip.innerHTML(),
|
||||
});
|
||||
await page.locator('.selector-row select').nth(1).selectOption('8');
|
||||
await expect(card).toContainText('다른장수');
|
||||
await expect(war).not.toHaveAttribute('tabindex', '0');
|
||||
await expect(tooltip).toHaveCount(0);
|
||||
}
|
||||
});
|
||||
|
||||
test('감찰부 하단 창 닫기 버튼은 상단 버튼과 같은 크기를 유지한다', async ({ page }) => {
|
||||
const head: FixtureState = { permission: 'head', myset: 3, settingMutations: [], accessPages: [] };
|
||||
await install(page, head);
|
||||
|
||||
Reference in new issue
Block a user