warframe-worldstate-parser
Version:
An Open parser for Warframe's Worldstate in Javascript
63 lines (62 loc) • 2.12 kB
JavaScript
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs";
import { WorldStateObject } from "./WorldStateObject.mjs";
import { IsNumber, IsString } from "class-validator";
import { fromNow, operation, operationSymbol, timeDeltaToString, upgrade } from "warframe-worldstate-data/utilities";
//#region lib/models/GlobalUpgrade.ts
/**
* Represents an upgrade that applies to all players
*/
var GlobalUpgrade = class extends WorldStateObject {
/**
* The effect of the upgrade
*/
upgrade;
/**
* The operation type
*/
operation;
/**
* Symbol for operation
*/
operationSymbol;
/**
* The operation value
*/
upgradeOperationValue;
/**
* @param {object} data The global upgrade data
* @param {object} deps The dependencies object
* @param {string} deps.locale Locale to use for translations
*/
constructor(data, { locale = "en" } = { locale: "en" }) {
super(data);
this.upgrade = upgrade(data.UpgradeType, locale);
this.operation = operation(data.OperationType, locale);
this.operationSymbol = operationSymbol(data.OperationType, locale);
this.upgradeOperationValue = data.Value;
}
/**
* Plaintext description of upgrade
*/
get desc() {
return `${this.upgradeOperationValue}${this.operationSymbol} ${this.upgrade} for ${this.eta}`;
}
/**
* ETA string (at time of object creation)
*/
get eta() {
return timeDeltaToString(fromNow(this.expiry));
}
/**
* Whether or not this is expired (at time of object creation)
*/
get expired() {
return fromNow(this.expiry) < 0;
}
};
__decorate([IsString(), __decorateMetadata("design:type", String)], GlobalUpgrade.prototype, "upgrade", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], GlobalUpgrade.prototype, "operation", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], GlobalUpgrade.prototype, "operationSymbol", void 0);
__decorate([IsNumber(), __decorateMetadata("design:type", Number)], GlobalUpgrade.prototype, "upgradeOperationValue", void 0);
//#endregion
export { GlobalUpgrade };