enka-network-api
Version:
Enka-network API wrapper for Genshin Impact.
33 lines (32 loc) • 1.78 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.WeaponAscension = void 0;
const config_file_js_1 = require("config_file.js");
const UpgradeCost_1 = require("../material/UpgradeCost");
const StatProperty_1 = require("../StatProperty");
const AssetsNotFoundError_1 = require("../../errors/AssetsNotFoundError");
const ExcelTransformer_1 = require("../../client/ExcelTransformer");
class WeaponAscension {
constructor(data, enka) {
this._data = data;
this.enka = enka;
const json = new config_file_js_1.JsonReader(ExcelTransformer_1.excelJsonOptions, this._data);
this.id = json.getAsNumber("weaponPromoteId");
this.ascension = json.getAsNumberWithDefault(0, "promoteLevel");
this.unlockMaxLevel = json.getAsNumber("unlockMaxLevel");
this.requiredAdventureRank = json.getAsNumberWithDefault(0, "requiredPlayerLevel");
this.cost = new UpgradeCost_1.UpgradeCost(json.getAsNumberWithDefault(0, "coinCost"), json.has("costItems") ? json.get("costItems").mapArray((_, p) => p.getAsJsonObject()) : [], enka);
this.addProps = json.get("addProps").filterArray((_, p) => p.has("propType") && p.has("value")).map(([, p]) => new StatProperty_1.StatProperty(p.getAsString("propType"), p.getAsNumber("value"), enka));
}
/**
* @param id weaponPromoteId
* @param ascension promoteLevel
*/
static getById(id, ascension, enka) {
const data = enka.cachedAssetsManager.getExcelData("WeaponPromoteExcelConfigData", id, ascension);
if (!data)
throw new AssetsNotFoundError_1.AssetsNotFoundError("WeaponAscension", `${id}-${ascension}`);
return new WeaponAscension(data, enka);
}
}
exports.WeaponAscension = WeaponAscension;
;