feat: add spell and rune tooltips
This commit is contained in:
1 parent
4906f665fd
commit
292e37aaac
8 files changed
+404
-161
No files matched your search
@@ -20,7 +20,7 @@ describe('RiotDdragonService', () => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('includes localized item metadata in the manifest', async () => {
|
||||
it('includes localized item, spell, and rune metadata in the manifest', async () => {
|
||||
const fetchMock = jest.fn(async (url: string) => {
|
||||
if (url.endsWith('/api/versions.json')) {
|
||||
return jsonResponse(['15.24.1']);
|
||||
@@ -35,12 +35,40 @@ describe('RiotDdragonService', () => {
|
||||
if (url.endsWith('/summoner.json')) {
|
||||
return jsonResponse({
|
||||
data: {
|
||||
SummonerFlash: { key: '4', id: 'SummonerFlash', name: '점멸' },
|
||||
SummonerFlash: {
|
||||
key: '4',
|
||||
id: 'SummonerFlash',
|
||||
name: '점멸',
|
||||
description: '커서 방향으로 순간이동합니다.',
|
||||
tooltip: '<span>커서 방향으로 순간이동합니다.</span>',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
if (url.endsWith('/runesReforged.json')) {
|
||||
return jsonResponse([]);
|
||||
return jsonResponse([
|
||||
{
|
||||
id: 8000,
|
||||
key: 'Precision',
|
||||
icon: 'perk-images/Styles/7201_Precision.png',
|
||||
name: '정밀',
|
||||
slots: [
|
||||
{
|
||||
runes: [
|
||||
{
|
||||
id: 8005,
|
||||
key: 'PressTheAttack',
|
||||
icon: 'perk-images/Styles/Precision/PressTheAttack/PressTheAttack.png',
|
||||
name: '집중 공격',
|
||||
shortDesc: '연속 공격 시 추가 피해',
|
||||
longDesc:
|
||||
'<lol-uikit-tooltipped-keyword>기본 공격</lol-uikit-tooltipped-keyword>으로 적을 약화시킵니다.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
if (url.endsWith('/item.json')) {
|
||||
return jsonResponse({
|
||||
@@ -70,6 +98,33 @@ describe('RiotDdragonService', () => {
|
||||
await expect(service.getManifest('ko_KR')).resolves.toMatchObject({
|
||||
version: '15.24.1',
|
||||
locale: 'ko_KR',
|
||||
summonerSpells: {
|
||||
'4': {
|
||||
key: 'SummonerFlash',
|
||||
name: '점멸',
|
||||
description: '커서 방향으로 순간이동합니다.',
|
||||
tooltip: '<span>커서 방향으로 순간이동합니다.</span>',
|
||||
},
|
||||
},
|
||||
runesReforged: [
|
||||
{
|
||||
id: 8000,
|
||||
name: '정밀',
|
||||
slots: [
|
||||
{
|
||||
runes: [
|
||||
{
|
||||
id: 8005,
|
||||
name: '집중 공격',
|
||||
shortDesc: '연속 공격 시 추가 피해',
|
||||
longDesc:
|
||||
'<lol-uikit-tooltipped-keyword>기본 공격</lol-uikit-tooltipped-keyword>으로 적을 약화시킵니다.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
items: {
|
||||
'1055': {
|
||||
name: '도란의 검',
|
||||
@@ -90,8 +145,22 @@ describe('RiotDdragonService', () => {
|
||||
expect.any(Object),
|
||||
);
|
||||
expect(redis.setJson).toHaveBeenCalledWith(
|
||||
'ddragon:manifest:v4:ko_KR',
|
||||
'ddragon:manifest:v5:ko_KR',
|
||||
expect.objectContaining({
|
||||
summonerSpells: expect.objectContaining({
|
||||
'4': expect.objectContaining({ description: '커서 방향으로 순간이동합니다.' }),
|
||||
}),
|
||||
runesReforged: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
slots: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
runes: expect.arrayContaining([
|
||||
expect.objectContaining({ longDesc: expect.stringContaining('기본 공격') }),
|
||||
]),
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
]),
|
||||
items: expect.objectContaining({
|
||||
'1055': expect.objectContaining({ name: '도란의 검' }),
|
||||
}),
|
||||
|
||||
@@ -5,7 +5,7 @@ const DDRAGON_BASE = 'https://ddragon.leagueoflegends.com';
|
||||
const DDRAGON_CDN = `${DDRAGON_BASE}/cdn`;
|
||||
const DEFAULT_LOCALE = 'ko_KR';
|
||||
const CACHE_TTL_SECONDS = 24 * 60 * 60;
|
||||
const CACHE_VERSION = 'v4';
|
||||
const CACHE_VERSION = 'v5';
|
||||
const FETCH_TIMEOUT_MS = 10_000;
|
||||
|
||||
export interface DdragonChampionEntry {
|
||||
@@ -16,6 +16,8 @@ export interface DdragonChampionEntry {
|
||||
export interface DdragonSummonerSpellEntry {
|
||||
key: string;
|
||||
name: string;
|
||||
description: string;
|
||||
tooltip: string;
|
||||
}
|
||||
|
||||
export interface DdragonRuneEntry {
|
||||
@@ -23,6 +25,8 @@ export interface DdragonRuneEntry {
|
||||
key: string;
|
||||
icon: string;
|
||||
name: string;
|
||||
shortDesc: string;
|
||||
longDesc: string;
|
||||
}
|
||||
|
||||
export interface DdragonRuneStyleEntry extends DdragonRuneEntry {
|
||||
@@ -66,6 +70,8 @@ interface SummonerSpellDataEntry {
|
||||
key: string;
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
tooltip?: string;
|
||||
}
|
||||
|
||||
interface SummonerSpellDataResponse {
|
||||
@@ -77,6 +83,8 @@ interface RuneDataEntry {
|
||||
key: string;
|
||||
icon: string;
|
||||
name: string;
|
||||
shortDesc?: string;
|
||||
longDesc?: string;
|
||||
}
|
||||
|
||||
interface RuneStyleDataEntry extends RuneDataEntry {
|
||||
@@ -195,6 +203,9 @@ export class RiotDdragonService {
|
||||
map[entry.key] = {
|
||||
key: entry.id,
|
||||
name: typeof entry.name === 'string' ? entry.name : entry.id,
|
||||
description:
|
||||
typeof entry.description === 'string' ? entry.description : '',
|
||||
tooltip: typeof entry.tooltip === 'string' ? entry.tooltip : '',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -218,6 +229,9 @@ export class RiotDdragonService {
|
||||
key: style.key,
|
||||
icon: style.icon,
|
||||
name: style.name,
|
||||
shortDesc:
|
||||
typeof style.shortDesc === 'string' ? style.shortDesc : '',
|
||||
longDesc: typeof style.longDesc === 'string' ? style.longDesc : '',
|
||||
slots: (style.slots ?? []).map((slot) => ({
|
||||
runes: (slot.runes ?? [])
|
||||
.filter((rune): rune is RuneDataEntry => isRuneEntry(rune))
|
||||
@@ -226,6 +240,9 @@ export class RiotDdragonService {
|
||||
key: rune.key,
|
||||
icon: rune.icon,
|
||||
name: rune.name,
|
||||
shortDesc:
|
||||
typeof rune.shortDesc === 'string' ? rune.shortDesc : '',
|
||||
longDesc: typeof rune.longDesc === 'string' ? rune.longDesc : '',
|
||||
})),
|
||||
})),
|
||||
}));
|
||||
|
||||
Reference in new issue
Block a user