diff --git a/src/client/CachedAssetsManager.ts b/src/client/CachedAssetsManager.ts index a2d5eec..cf2ecc4 100644 --- a/src/client/CachedAssetsManager.ts +++ b/src/client/CachedAssetsManager.ts @@ -47,6 +47,7 @@ const contents = [ "RelicSubAffixConfig", // Relic Sub Stats "RelicSetConfig", // Relic Sets "RelicSetSkillConfig", // Relic Set Bonus + "AvatarPropertyConfig", // StatProperty ]; const textMapWhiteList: number[] = [ @@ -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"), @@ -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)`); diff --git a/src/models/StatProperty.ts b/src/models/StatProperty.ts index 9826ba5..e6c73ca 100644 --- a/src/models/StatProperty.ts +++ b/src/models/StatProperty.ts @@ -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 @@ -9,6 +13,25 @@ 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 @@ -16,6 +39,24 @@ class StatProperty { 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); } }