From 974212df44b8173c85bbce5c2779b965bc2d6be4 Mon Sep 17 00:00:00 2001 From: squaresmile Date: Fri, 30 Aug 2024 23:03:58 -0400 Subject: [PATCH] Added battle master image endpoint --- packages/api-connector/src/ApiConnector.ts | 18 ++++++++++++++++++ .../api-connector/src/Schema/BattleMaster.ts | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 packages/api-connector/src/Schema/BattleMaster.ts diff --git a/packages/api-connector/src/ApiConnector.ts b/packages/api-connector/src/ApiConnector.ts index 87bd083c..46153b5a 100644 --- a/packages/api-connector/src/ApiConnector.ts +++ b/packages/api-connector/src/ApiConnector.ts @@ -9,6 +9,7 @@ import Region from "./Enum/Region"; import ResultCache from "./ResultCache"; import { AiActNum, AiActTarget, AiActType, AiCollection, AiCond, AiTiming, AiType } from "./Schema/Ai"; import { Attribute, AttributeAffinityMap } from "./Schema/Attribute"; +import { BattleMasterImage } from "./Schema/BattleMaster"; import { BgmEntity } from "./Schema/Bgm"; import { BasicBuff, @@ -135,6 +136,7 @@ class ApiConnector { private cache = { ai: new ResultCache<{ type: AiType; id: number }, AiCollection>(), attributeAffinityMap: new ResultCache(), + battleMasterImage: new ResultCache(), bgm: new ResultCache(), bgmList: new ResultCache(), buff: new ResultCache(), @@ -303,6 +305,22 @@ class ApiConnector { ); } + battleMasterImage(id: number, cacheDuration?: number): Promise { + const params = new URLSearchParams(); + const query = this.getQueryString(params); + const fetch = () => { + return ApiConnector.fetch( + `${this.host}/nice/${this.region}/battle-master-image/${id}${query}` + ); + }; + + if (cacheDuration === undefined) return fetch(); + + const cacheKey = `${id}`; + + return this.cache.battleMasterImage.get(cacheKey, fetch, cacheDuration <= 0 ? null : cacheDuration); + } + bgm(id: number, cacheDuration?: number, fileName?: string): Promise { const params = new URLSearchParams(); if (fileName) { diff --git a/packages/api-connector/src/Schema/BattleMaster.ts b/packages/api-connector/src/Schema/BattleMaster.ts new file mode 100644 index 00000000..3b6f3583 --- /dev/null +++ b/packages/api-connector/src/Schema/BattleMaster.ts @@ -0,0 +1,16 @@ +import { CommonRelease } from "./CommonRelease"; +import { Gender } from "./Entity"; + +export interface BattleMasterImage { + id: number; + type: Gender; + faceIcon?: string; + skillCutin?: string; + skillCutinOffsetX: number; + skillCutinOffsetY: number; + commandSpellCutin?: string; + commandSpellCutinOffsetX: number; + commandSpellCutinOffsetY: number; + resultImage?: string; + releaseConditions: CommonRelease[]; +}