warframe-worldstate-parser
Version:
An Open parser for Warframe's Worldstate in Javascript
91 lines (90 loc) • 2.77 kB
JavaScript
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs";
import { Mission } from "./Mission.mjs";
import { WorldStateObject } from "./WorldStateObject.mjs";
import { SortieVariant } from "./SortieVariant.mjs";
import { Type } from "class-transformer";
import { IsArray, IsString, ValidateNested } from "class-validator";
import wsData from "warframe-worldstate-data";
import { fromNow, languageString, parseDate, sortieBoss, sortieFaction, timeDeltaToString } from "warframe-worldstate-data/utilities";
//#region lib/models/Sortie.ts
const { sortie: sortieData } = wsData;
/**
* Represents a daily sortie
* @augments {WorldStateObject}
*/
var Sortie = class extends WorldStateObject {
/**
* The sortie's reward pool
*/
rewardPool;
/**
* The sortie's variants
*/
variants;
/**
* Archon hunt missions if sortie is an archon hunt
*/
missions;
/**
* The sortie's boss
*/
boss;
/**
* The sortie's faction
*/
faction;
/**
* The sortie's faction
*/
factionKey;
/**
* @param data The data for all daily sorties
* @param deps The dependencies object
* @param deps.locale Locale to use for translations
*/
constructor(data, { locale = "en" } = { locale: "en" }) {
super(data);
const opts = {
sortieData,
locale
};
this.activation = parseDate(data.Activation);
this.expiry = parseDate(data.Expiry);
this.rewardPool = languageString(data.Reward, locale);
this.variants = (data.Variants ?? []).map((v) => new SortieVariant(v, opts));
this.missions = (data.Missions ?? []).map((v) => new Mission(v, opts));
this.boss = sortieBoss(data.Boss, locale);
this.faction = sortieFaction(data.Boss, locale);
this.factionKey = sortieFaction(data.Boss, "en");
}
/**
* ETA string (at time of object creation)
*/
get eta() {
return timeDeltaToString(fromNow(this.expiry));
}
/**
* Whether this is expired (at time of object creation)
*/
get expired() {
return fromNow(this.expiry) < 0;
}
};
__decorate([IsString(), __decorateMetadata("design:type", String)], Sortie.prototype, "rewardPool", void 0);
__decorate([
IsArray(),
ValidateNested({ each: true }),
Type(() => SortieVariant),
__decorateMetadata("design:type", Array)
], Sortie.prototype, "variants", void 0);
__decorate([
IsArray(),
ValidateNested({ each: true }),
Type(() => Mission),
__decorateMetadata("design:type", Array)
], Sortie.prototype, "missions", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], Sortie.prototype, "boss", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], Sortie.prototype, "faction", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], Sortie.prototype, "factionKey", void 0);
//#endregion
export { Sortie };