Init commit

This commit is contained in:
Blossomi Shymae
2024-05-01 20:38:02 -05:00
commit 75bc1827e4
29 changed files with 11845 additions and 0 deletions

70
core/client.ts Normal file
View File

@@ -0,0 +1,70 @@
import { ChampionSummary, Item, LocaleVersionArgs, Perk, SummonerEmote, SummonerIcon, WardSkin } from "./models";
import axios from "axios";
export abstract class ApiObject {
static url = "https://raw.communitydragon.org";
getClientPath(args: LocaleVersionArgs): string {
return `${ApiObject.url}/${args.version}/plugins/rcp-be-lol-game-data/global/${args.locale}`;
}
}
export class Client {
public items: ItemApi;
public perks: PerkApi;
public championSummaries: ChampionSummaryApi;
public summonerEmotes: SummonerEmoteApi;
public summonerIcons: SummonerIconApi;
public wardSkins: WardSkinApi;
constructor() {
this.items = new ItemApi();
this.perks = new PerkApi();
this.championSummaries = new ChampionSummaryApi();
this.summonerEmotes = new SummonerEmoteApi();
this.summonerIcons = new SummonerIconApi();
this.wardSkins = new WardSkinApi();
}
}
export class ItemApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<Item>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/items.json`);
return res.data.map((x: any) => new Item(x));
}
}
export class PerkApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<Perk>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/perks.json`);
return res.data.map((x: any) => new Perk(x));
}
}
export class ChampionSummaryApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<ChampionSummary>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/champion-summary.json`);
return res.data.map((x: any) => new ChampionSummary(x));
}
}
export class SummonerEmoteApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<SummonerEmote>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/summoner-emotes.json`);
return res.data.map((x: any) => new SummonerEmote(x));
}
}
export class SummonerIconApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<SummonerIcon>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/summoner-icons.json`);
return res.data.map((x: any) => new SummonerEmote(x));
}
}
export class WardSkinApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<WardSkin>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/ward-skins.json`);
return res.data.map((x: any) => new WardSkin(x));
}
}

282
core/models.ts Normal file
View File

@@ -0,0 +1,282 @@
export class LocaleVersionArgs {
locale: string;
version: string
constructor({locale, version}: {locale: string, version: string}) {
this.locale = locale;
this.version = version;
}
}
export abstract class CommunityDragonObject {
static url = "https://raw.communitydragon.org";
resolveClientPath({path, args}: {path: string, args: LocaleVersionArgs}): string {
const uri = path.replace("/lol-game-data/assets", "").toLowerCase();
return `${CommunityDragonObject.url}/${args.version}/plugins/rcp-be-lol-game-data/global/${args.locale}/${uri}`;
}
resolveGamePath({path, version}: {path: string, version: string}): string {
const uri = path.replace("/lol-game-data/assets/ASSETS/", "").replace(".jpg", ".png").toLowerCase();
return `${CommunityDragonObject.url}/${version}/game/assets/${uri}`;
}
}
export class Champion extends CommunityDragonObject {
id: number;
name: string;
alias: string;
title: string;
shortBio: string;
playstyleInfo: PlaystyleInfo;
skins: Array<Skin>;
passive: Passive;
spells: Array<Spell>;
constructor(json: any) {
super();
this.id = json.id;
this.name = json.name;
this.alias = json.alias;
this.title = json.title;
this.shortBio = json.shortBio;
this.playstyleInfo = new PlaystyleInfo(json.playstyleInfo);
this.skins = json.skins.map((x: any) => new Skin(x));
this.passive = new Passive(json.passive);
this.spells = json.spells.map((x: any) => new Spell(x));
}
}
export class PlaystyleInfo extends CommunityDragonObject {
damage: number;
durability: number;
crowdControl: number;
mobility: number;
utility: number;
constructor(json: any) {
super();
this.damage = json.damage;
this.durability = json.durability;
this.crowdControl = json.crowdControl;
this.mobility = json.mobility;
this.utility = json.utility;
}
}
export class Skin extends CommunityDragonObject {
id: number;
isBase: boolean;
name: string;
rarity: string;
isLegacy: boolean;
loadScreenPath: string;
constructor(json: any) {
super();
this.id = json.id;
this.isBase = json.isBase;
this.name = json.name;
this.rarity = json.rarity;
this.isLegacy = json.isLegacy;
this.loadScreenPath = json.loadScreenPath;
}
getLoadScreen(version: string): string {
return this.resolveGamePath({path: this.loadScreenPath, version: version});
}
}
export class Passive extends CommunityDragonObject {
name: string;
description: string;
constructor(json: any) {
super();
this.name = json.name;
this.description = json.description;
}
}
export class Spell extends CommunityDragonObject {
spellKey: string;
name: string;
description: string;
constructor(json: any) {
super();
this.spellKey = json.spellKey;
this.name = json.name;
this.description = json.description;
}
}
export class ChampionSummary extends CommunityDragonObject {
id: number;
name: string;
alias: string;
squarePortraitPath: string;
constructor(json: any) {
super();
this.id = json.id;
this.name = json.name;
this.alias = json.alias;
this.squarePortraitPath = json.squarePortraitPath;
}
getIcon(args: LocaleVersionArgs): string {
return this.resolveClientPath({path: this.squarePortraitPath, args: args});
}
}
export class Item extends CommunityDragonObject {
id: number;
name: string;
description: string;
active: boolean;
inStore: boolean;
from: Array<number>;
to: Array<number>;
categories: Array<number>;
price: number;
priceTotal: number;
iconPath: string;
constructor(json: any) {
super();
this.id = json.id;
this.name = json.name;
this.description = json.description;
this.active = json.active;
this.inStore = json.inStore;
this.from = json.from;
this.to = json.to;
this.categories = json.categories;
this.price = json.price;
this.priceTotal = json.priceTotal;
this.iconPath = json.iconPath;
}
getIcon(version: string): string {
return this.resolveGamePath({path: this.iconPath, version: version});
}
}
export class Perk extends CommunityDragonObject {
id: number;
name: string;
shortDesc: string;
longDesc: string;
iconPath: string;
constructor(json: any) {
super();
this.id = json.id;
this.name = json.name;
this.shortDesc = json.shortDesc;
this.longDesc = json.longDesc;
this.iconPath = json.iconPath;
}
getIcon(version: string): string {
return this.resolveClientPath({path: this.iconPath, args: {version: version, locale: "default"}});
}
}
export class SummonerEmote extends CommunityDragonObject {
id: number;
name: string;
inventoryIcon: string;
constructor(json: any) {
super();
this.id = json.id;
this.name = json.name;
this.inventoryIcon = json.inventoryIcon;
}
getInventoryIcon(version: string): string {
return this.resolveGamePath({path: this.inventoryIcon, version: version}).replace("inventory", "vfx");
}
}
export class SummonerIcon extends CommunityDragonObject {
id: number;
title: string;
yearReleased: number;
isLegacy: boolean;
imagePath?: string;
descriptions: Array<Description>;
rarities: Array<Rarity>;
constructor(json: any) {
super();
this.id = json.id;
this.title = json.title;
this.yearReleased = json.yearReleased;
this.isLegacy = json.isLegacy;
this.imagePath = json.imagePath;
this.descriptions = json.descriptions.map((x: any) => new Description(x));
this.rarities = json.rarities.map((x: any) => new Rarity(x));
}
}
export class WardSkin extends CommunityDragonObject {
id: number;
name: string;
description : string;
wardImagePath: string;
wardShadowImagePath: string;
isLegacy: boolean;
regionDescriptions: Array<Description>;
rarities: Array<Rarity>;
constructor(json: any) {
super();
this.id = json.id;
this.name = json.name;
this.description = json.description;
this.wardImagePath = json.wardImagePath;
this.wardShadowImagePath = json.wardShadowImagePath;
this.isLegacy = json.isLegacy;
this.regionDescriptions = json.regionalDescriptions.map((x: any) => new Description(x));
this.rarities = json.rarities.map((x: any) => new Rarity(x));
}
}
export class Description extends CommunityDragonObject {
region: string;
description: string;
constructor(json: any) {
super();
this.region = json.region;
this.description = json.description;
}
}
export class Rarity extends CommunityDragonObject {
region: string;
rarity: string;
constructor(json: any) {
super();
this.region = json.region;
this.rarity = json.rarity;
}
}