Skip to content

Commit

Permalink
Added battle master image endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
squaresmile committed Aug 31, 2024
1 parent abefdcc commit 974212d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/api-connector/src/ApiConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -135,6 +136,7 @@ class ApiConnector {
private cache = {
ai: new ResultCache<{ type: AiType; id: number }, AiCollection>(),
attributeAffinityMap: new ResultCache<null, AttributeAffinityMap>(),
battleMasterImage: new ResultCache<string, BattleMasterImage>(),
bgm: new ResultCache<string, BgmEntity>(),
bgmList: new ResultCache<null, BgmEntity[]>(),
buff: new ResultCache<number, Buff>(),
Expand Down Expand Up @@ -303,6 +305,22 @@ class ApiConnector {
);
}

battleMasterImage(id: number, cacheDuration?: number): Promise<BattleMasterImage> {
const params = new URLSearchParams();
const query = this.getQueryString(params);
const fetch = () => {
return ApiConnector.fetch<BattleMasterImage>(
`${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<BgmEntity> {
const params = new URLSearchParams();
if (fileName) {
Expand Down
16 changes: 16 additions & 0 deletions packages/api-connector/src/Schema/BattleMaster.ts
Original file line number Diff line number Diff line change
@@ -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[];
}

0 comments on commit 974212d

Please sign in to comment.