UNPKG

warframe-worldstate-parser

Version:

An Open parser for Warframe's Worldstate in Javascript

86 lines (85 loc) 2.71 kB
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs"; import { WorldStateObject } from "./WorldStateObject.mjs"; import { NightwaveChallenge } from "./NightwaveChallenge.mjs"; import { Type } from "class-transformer"; import { IsArray, IsInt, IsObject, IsString, Min, ValidateNested } from "class-validator"; import { fromNow, languageString, timeDeltaToString } from "warframe-worldstate-data/utilities"; //#region lib/models/Nightwave.ts /** * Represents a nightwave state * @augments {WorldStateObject} */ var Nightwave = class extends WorldStateObject { /** * The current season. 0-indexed. */ season; /** * Descriptor for affiliation */ tag; /** * The current season's current phase. 0-indexed. */ phase; /** * Misc params provided. */ params; /** * Array of possible challenges */ possibleChallenges; /** * Array of active challenges */ activeChallenges; /** * @param data The alert data * @param deps The dependencies object * @param deps.locale Locale to use for translations */ constructor(data, { locale } = { locale: "en" }) { super(data); const deps = { locale }; this.id = `nightwave${new Date(this.expiry).getTime()}`; this.season = data.Season; this.tag = languageString(data.AffiliationTag, locale); this.phase = data.Phase; this.params = JSON.parse(data.Params || "{}"); this.possibleChallenges = (data.Challenges || []).map((challenge) => new NightwaveChallenge(challenge, deps)).filter((challenge) => challenge); this.activeChallenges = (data.ActiveChallenges || []).map((challenge) => new NightwaveChallenge(challenge, deps)).filter((challenge) => challenge); } /** * How much time is left before the nightwave expires */ get eta() { return timeDeltaToString(fromNow(this.expiry)); } }; __decorate([ IsInt(), Min(0), __decorateMetadata("design:type", Number) ], Nightwave.prototype, "season", void 0); __decorate([IsString(), __decorateMetadata("design:type", String)], Nightwave.prototype, "tag", void 0); __decorate([ IsInt(), Min(0), __decorateMetadata("design:type", Number) ], Nightwave.prototype, "phase", void 0); __decorate([IsObject(), __decorateMetadata("design:type", typeof Record === "undefined" ? Object : Record)], Nightwave.prototype, "params", void 0); __decorate([ IsArray(), ValidateNested({ each: true }), Type(() => NightwaveChallenge), __decorateMetadata("design:type", Array) ], Nightwave.prototype, "possibleChallenges", void 0); __decorate([ IsArray(), ValidateNested({ each: true }), Type(() => NightwaveChallenge), __decorateMetadata("design:type", Array) ], Nightwave.prototype, "activeChallenges", void 0); //#endregion export { Nightwave };