-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { JsonObject, JsonReader } from "config_file.js"; | ||
import StarRail from "../../client/StarRail"; | ||
import AssetsNotFoundError from "../../errors/AssetsNotFoundError"; | ||
import TextAssets from "../assets/TextAssets"; | ||
import ImageAssets from "../assets/ImageAssets"; | ||
|
||
/** | ||
* @typedef | ||
* @example | ||
* |RelicTypeId|In-game Name| | ||
* |---|---| | ||
* |HEAD|Head| | ||
* |HAND|Hands| | ||
* |BODY|Body| | ||
* |FOOT|Feet| | ||
* |OBJECT|Link Rope| | ||
* |NECK|Planar Sphere| | ||
*/ | ||
export type RelicTypeId = "HEAD" | "HAND" | "BODY" | "FOOT" | "OBJECT" | "NECK"; | ||
|
||
/** | ||
* @en RelicType | ||
*/ | ||
class RelicType { | ||
/** */ | ||
readonly id: RelicTypeId; | ||
/** */ | ||
readonly client: StarRail; | ||
|
||
/** */ | ||
readonly name: TextAssets; | ||
/** */ | ||
readonly icon: ImageAssets; | ||
|
||
readonly _data: JsonObject; | ||
|
||
/** | ||
* @param id | ||
* @param client | ||
*/ | ||
constructor(id: RelicTypeId, client: StarRail) { | ||
this.id = id; | ||
this.client = client; | ||
|
||
const _data = client.cachedAssetsManager.getStarRailCacheData("RelicBaseType")[this.id]; | ||
if (!_data) throw new AssetsNotFoundError("RelicType", this.id); | ||
this._data = _data; | ||
|
||
const json = new JsonReader(this._data); | ||
|
||
this.name = new TextAssets(json.getAsNumber("BaseTypeText", "Hash"), this.client); | ||
this.icon = new ImageAssets(json.getAsString("BaseTypeIconPath"), this.client); | ||
} | ||
} | ||
|
||
export default RelicType; |
31c5d49
There was a problem hiding this comment.
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