-
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
8 changed files
with
104 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"cSpell.words": [ | ||
"autodrain", | ||
"starfaring", | ||
"starrail", | ||
"Trailblaze", | ||
"typedefs" | ||
|
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,70 @@ | ||
import { JsonObject, JsonReader } from "config_file.js"; | ||
import StarRail from "../../client/StarRail"; | ||
import RelicData from "./RelicData"; | ||
import { RelicMainStatData } from "./RelicMainStatGroup"; | ||
import { RelicSubStatData } from "./RelicSubStatGroup"; | ||
|
||
/** @typedef */ | ||
export interface RelicSubStat { | ||
subStatData: RelicSubStatData; | ||
/** The number of times this SubStat has been enhanced */ | ||
count: number; | ||
/** */ | ||
steps: number; | ||
/** Calculated by [baseValue](RelicSubStatData#baseValue) * [count](#count) + [stepValue](RelicSubStatData#stepValue) * [steps](#steps) */ | ||
value: number; | ||
} | ||
|
||
/** | ||
* @en Relic | ||
*/ | ||
class Relic { | ||
/** */ | ||
readonly client: StarRail; | ||
|
||
/** */ | ||
readonly relicData: RelicData; | ||
/** */ | ||
readonly level: number; | ||
/** */ | ||
readonly mainStat: RelicMainStatData; | ||
/** */ | ||
readonly subStats: RelicSubStat[]; | ||
|
||
readonly _data: JsonObject; | ||
|
||
/** | ||
* @param data | ||
* @param client | ||
*/ | ||
constructor(data: JsonObject, client: StarRail) { | ||
this.client = client; | ||
this._data = data; | ||
|
||
const json = new JsonReader(this._data); | ||
|
||
this.relicData = new RelicData(json.getAsNumber("ID"), this.client); | ||
|
||
this.level = json.getAsNumberWithDefault(0, "Level"); | ||
|
||
const mainAffixId = json.getAsNumber("MainAffixID"); | ||
this.mainStat = this.relicData.mainStatGroup.mainStats.find(mainStat => mainStat.id === mainAffixId) as RelicMainStatData; | ||
|
||
this.subStats = json.get("RelicSubAffix").mapArray((_, subAffix) => { | ||
const subAffixId = subAffix.getAsNumber("SubAffixID"); | ||
const subStatData = this.relicData.subStatGroup.subStats.find(s => s.id === subAffixId) as RelicSubStatData; | ||
const count = subAffix.getAsNumber("Cnt"); | ||
const steps = subAffix.getAsNumberWithDefault(0, "Step"); | ||
|
||
return { | ||
subStatData, | ||
count, | ||
steps, | ||
value: subStatData.baseValue * count + subStatData.stepValue * steps, | ||
}; | ||
}); | ||
|
||
} | ||
} | ||
|
||
export default Relic; |
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
60f284c
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-git-main-yuko1101.vercel.app
starrail-yuko1101.vercel.app
starrail.vercel.app