Skip to content

Commit

Permalink
add AvatarPropertyConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
yuko1101 committed May 16, 2023
1 parent e769a9e commit 56aea35
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/client/CachedAssetsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const contents = [
"RelicSubAffixConfig", // Relic Sub Stats
"RelicSetConfig", // Relic Sets
"RelicSetSkillConfig", // Relic Set Bonus
"AvatarPropertyConfig", // StatProperty
];

const textMapWhiteList: number[] = [
Expand Down Expand Up @@ -484,8 +485,8 @@ class CachedAssetsManager {
});
});

Object.values(data["ItemConfigRelic"]).forEach(l => {
const json = new JsonReader(l);
Object.values(data["ItemConfigRelic"]).forEach(r => {
const json = new JsonReader(r);
push(
json.getAsNumber("ItemName", "Hash"),
json.getAsNumber("ItemBGDesc", "Hash"),
Expand All @@ -499,6 +500,16 @@ class CachedAssetsManager {
);
});

Object.values(data["AvatarPropertyConfig"]).forEach(s => {
const json = new JsonReader(s);
push(
json.getAsNumber("PropertyName", "Hash"),
json.getAsNumber("PropertyNameSkillTree", "Hash"),
json.getAsNumber("PropertyNameRelic", "Hash"),
json.getAsNumber("PropertyNameFilter", "Hash"),
);
});

const requiredStringKeys = required.filter(key => key).map(key => key.toString());

if (showLog) console.info(`Required keys have been loaded (${requiredStringKeys.length.toLocaleString()} keys)`);
Expand Down
41 changes: 41 additions & 0 deletions src/models/StatProperty.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { JsonObject, JsonReader } from "config_file.js";
import StarRail from "../client/StarRail";
import AssetsNotFoundError from "../errors/AssetsNotFoundError";
import ImageAssets from "./assets/ImageAssets";
import TextAssets from "./assets/TextAssets";

/**
* @en StatProperty
Expand All @@ -9,13 +13,50 @@ class StatProperty {
/** */
readonly client: StarRail;

/** */
readonly name: TextAssets;
/** */
readonly nameSkillTree: TextAssets;
/** */
readonly nameRelic: TextAssets;
/** */
readonly nameFilter: TextAssets;
/** */
readonly isDisplay: boolean;
/** */
readonly isBattleDisplay: boolean;
/** */
readonly order: number;
/** */
readonly icon: ImageAssets;

readonly _data: JsonObject;

/**
* @param statPropertyType
* @param client
*/
constructor(statPropertyType: StatPropertyType, client: StarRail) {
this.statPropertyType = statPropertyType;
this.client = client;

const _data = client.cachedAssetsManager.getStarRailCacheData("AvatarPropertyConfig")[this.statPropertyType];
if (!_data) throw new AssetsNotFoundError("StatProperty", this.statPropertyType);
this._data = _data;

const json = new JsonReader(this._data);

this.name = new TextAssets(json.getAsNumber("PropertyName", "Hash"), this.client);
this.nameSkillTree = new TextAssets(json.getAsNumber("PropertyNameSkillTree", "Hash"), this.client);
this.nameRelic = new TextAssets(json.getAsNumber("PropertyNameRelic", "Hash"), this.client);
this.nameFilter = new TextAssets(json.getAsNumber("PropertyNameFilter", "Hash"), this.client);

this.isDisplay = json.getAsBooleanWithDefault(false, "IsDisplay");
this.isBattleDisplay = json.getAsBooleanWithDefault(false, "isBattleDisplay");

this.order = json.getAsNumber("Order");

this.icon = new ImageAssets(json.getAsString("IconPath"), this.client);
}
}

Expand Down

1 comment on commit 56aea35

@vercel
Copy link

@vercel vercel bot commented on 56aea35 May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

starrail – ./

starrail.vercel.app
starrail-git-main-yuko1101.vercel.app
starrail-yuko1101.vercel.app

Please sign in to comment.