diff --git a/server-new/app/Services/Jax/src/CDragonRequest.ts b/server-new/app/Services/Jax/src/CDragonRequest.ts index c60328a..753dc6a 100644 --- a/server-new/app/Services/Jax/src/CDragonRequest.ts +++ b/server-new/app/Services/Jax/src/CDragonRequest.ts @@ -24,6 +24,7 @@ export default class CDragonRequest { // https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/perks.json // https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/perkstyles.json // https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-summary.json + // https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/summoner-spells.json public async execute () { const url = `https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/${this.endpoint}` diff --git a/server-new/app/Services/Jax/src/Endpoints/CDragonEndpoint.ts b/server-new/app/Services/Jax/src/Endpoints/CDragonEndpoint.ts index 87b5c00..12b4721 100644 --- a/server-new/app/Services/Jax/src/Endpoints/CDragonEndpoint.ts +++ b/server-new/app/Services/Jax/src/Endpoints/CDragonEndpoint.ts @@ -1,6 +1,80 @@ import { JaxConfig } from '../../JaxConfig' import CDragonRequest from '../CDragonRequest' +export interface ChampionDTO { + id: number, + name: string, + alias: string, + squarePortraitPath: string, + roles: string[] +} + +export interface ItemDTO { + id: number, + name: string, + description: string, + active: boolean, + inStore: boolean, + from: number[], + to: number[], + categories: string[], + mapStringIdInclusions: string[], + maxStacks: number, + modeNameInclusions: string[], + requiredChampion: string, + requiredAlly: string, + requiredBuffCurrencyName: string, + requiredBuffCurrencyCost: number, + specialRecipe: number, + isEnchantment: boolean, + price: number, + priceTotal: number, + iconPath: string +} + +export interface PerkDTO { + id: number, + name: string, + majorChangePatchVersion: string, + tooltip: string, + shortDesc: string, + longDesc: string, + iconPath: string, + endOfGameStatDescs: string[] +} + +export interface PerkStyleResponse { + schemaVersion: string, + styles: PerkStyleDTO[] +} + +export interface PerkStyleDTO { + id: number, + name: string, + tooltip: string, + iconPath: string, + assetMap: { [key: string]: string }, + isAdvanced: boolean, + allowedSubStyles: number[], + subStyleBonus: { styleId: number, perkId: number }[], + slots: { type: string, slotLabel: string, perks: number[] }[], + defaultPageName: string, + defaultSubStyle: number, + defaultPerks: number[], + defaultPerksWhenSplashed: number[], + defaultStatModsPerSubStyle: { id: string, perks: number[] }[] +} + +export interface SummonerSpellDTO { + id: number, + name: string, + description: string, + summonerLevel: number, + cooldown: number, + gameModes: string[], + iconPath: string +} + export default class CDragonEndpoint { private config: JaxConfig @@ -8,23 +82,23 @@ export default class CDragonEndpoint { this.config = config } - public champions () { + public async champions (): Promise { return new CDragonRequest(this.config, 'champion-summary.json', 36000).execute() } - public items () { + public async items (): Promise { return new CDragonRequest(this.config, 'items.json', 36000).execute() } - public perks () { + public async perks (): Promise { return new CDragonRequest(this.config, 'perks.json', 36000).execute() } - public perkstyles () { + public async perkstyles (): Promise { return new CDragonRequest(this.config, 'perkstyles.json', 36000).execute() } - public summonerSpells () { + public async summonerSpells (): Promise { return new CDragonRequest(this.config, 'summoner-spells.json', 36000).execute() } } diff --git a/server-new/app/Transformers/MatchTransformer.ts b/server-new/app/Transformers/MatchTransformer.ts index c006cfc..f70b054 100644 --- a/server-new/app/Transformers/MatchTransformer.ts +++ b/server-new/app/Transformers/MatchTransformer.ts @@ -1,8 +1,9 @@ import { getSeasonNumber, queuesWithRole, sortTeamByRole, supportItems } from 'App/helpers' import Jax from 'App/Services/Jax' import { MatchDto, ParticipantDto, ParticipantTimelineDto } from 'App/Services/Jax/src/Endpoints/MatchEndpoint' -import { Item, ParticipantBasic, ParticipantDetails, PercentStats, Stats, SummonerSpell } from 'App/Models/Match' +import { Champion, Item, ParticipantBasic, ParticipantDetails, PercentStats, Stats, SummonerSpell } from 'App/Models/Match' import RoleIdentificationService from 'App/Services/RoleIdentiticationService' +import { ChampionDTO, ItemDTO, PerkDTO, PerkStyleDTO, SummonerSpellDTO } from 'App/Services/Jax/src/Endpoints/CDragonEndpoint' export interface PlayerRole { champion: number, @@ -11,11 +12,11 @@ export interface PlayerRole { } export default abstract class MatchTransformer { - protected champions: any - protected items: any - protected perks: any - protected perkstyles: any - protected summonerSpells: any + protected champions: ChampionDTO[] + protected items: ItemDTO[] + protected perks: PerkDTO[] + protected perkstyles: PerkStyleDTO[] + protected summonerSpells: SummonerSpellDTO[] protected championRoles: any protected sortTeamByRole: (a: ParticipantBasic | ParticipantDetails, b: ParticipantBasic | ParticipantDetails) => number /** @@ -42,12 +43,18 @@ export default abstract class MatchTransformer { * Get champion specific data * @param id of the champion */ - public getChampion (id: number) { - const champion = { ...this.champions.find((c: any) => c.id === id) } - champion.icon = 'https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/' - + `${champion.squarePortraitPath.split('/assets/')[1].toLowerCase()}` - delete champion.squarePortraitPath - return champion + public getChampion (id: number): Champion { + const originalChampionData = this.champions.find(c => c.id === id) + const icon = 'https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/' + + originalChampionData!.squarePortraitPath.split('/assets/')[1].toLowerCase() + + return { + icon, + id: originalChampionData!.id, + name: originalChampionData!.name, + alias: originalChampionData!.alias, + roles: originalChampionData!.roles, + } } /** @@ -149,14 +156,14 @@ export default abstract class MatchTransformer { continue } - const item = this.items.find((i: any) => i.id === id) - const itemUrl = item.iconPath.split('/assets/')[1].toLowerCase() + const item = this.items.find(i => i.id === id) + const itemUrl = item!.iconPath.split('/assets/')[1].toLowerCase() items.push({ image: `https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/${itemUrl}`, - name: item.name, - description: item.description, - price: item.priceTotal, + name: item!.name, + description: item!.description, + price: item!.priceTotal, }) } @@ -189,11 +196,11 @@ export default abstract class MatchTransformer { * @param perkSubStyle secondary perks category */ public getPerksImages (perk0: number, perkSubStyle: number) { - const firstRune = this.perks.find((p: any) => p.id === perk0) - const firstRuneUrl = firstRune.iconPath.split('/assets/')[1].toLowerCase() + const firstRune = this.perks.find(p => p.id === perk0) + const firstRuneUrl = firstRune!.iconPath.split('/assets/')[1].toLowerCase() const primaryRune = `https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/${firstRuneUrl}` - const secondRuneStyle = this.perkstyles.find((p: any) => p.id === perkSubStyle) + const secondRuneStyle = this.perkstyles.find(p => p.id === perkSubStyle) const secondRuneStyleUrl = secondRuneStyle ? secondRuneStyle.iconPath.split('/assets/')[1].toLowerCase() : null const secondaryRune = secondRuneStyleUrl ? @@ -305,11 +312,11 @@ export default abstract class MatchTransformer { if (id === 0) { return null } - const spell = this.summonerSpells.find((s: any) => s.id === id) - const spellName = spell.iconPath.split('/assets/')[1].toLowerCase() + const spell = this.summonerSpells.find(s => s.id === id) + const spellName = spell!.iconPath.split('/assets/')[1].toLowerCase() return { - name: spell.name, - description: spell.description, + name: spell!.name, + description: spell!.description, icon: `https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/${spellName}`, } }