warframe-worldstate-parser
Version:
An Open parser for Warframe's Worldstate in Javascript
83 lines (82 loc) • 2.56 kB
JavaScript
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs";
import { Type } from "class-transformer";
import { IsBoolean, IsDate, IsOptional, IsString } from "class-validator";
import { node, nodeEnemy, nodeMissionType } from "warframe-worldstate-data/utilities";
//#region lib/models/SentientOutpost.ts
const duration = 1800;
const sat = () => {
const now = Math.floor(Date.now() / 1e3);
const cycleSeconds = now % duration;
const active = cycleSeconds > 0 && cycleSeconds < 1800;
const start = (now - cycleSeconds) * 1e3;
const end = (now - cycleSeconds + duration) * 1e3;
return {
active,
expiry: new Date(end),
activation: new Date(start)
};
};
/**
* Represents a set of sentient outposts that are present
* Parsed source is combined data from DE's worldstate and semlar.com/anomaly.json
*/
var SentientOutpost = class {
node;
/**
* Unique identifier
*/
id;
/**
* Start time
*/
activation;
/**
* End time
*/
expiry;
/**
* Current Mission
*/
mission;
/**
* Whether the object was active during creation
*/
active;
/**
* @param sfn Sentient outpost node number
* @param deps Dependencies
*/
constructor(sfn, { locale, sentientData, logger }) {
this.node = sfn || "000";
const id = `CrewBattleNode${this.node}`;
if (this.node === "000") this.mission = void 0;
else this.mission = {
node: node(id, locale),
faction: nodeEnemy(id, locale),
type: nodeMissionType(id, locale)
};
({activation: this.activation, expiry: this.expiry} = sat());
this.active = Boolean(this.mission);
this.id = `${id}:${this.active}`;
if (!sentientData) logger?.debug("No outpost data, skipping");
else {
this.activation = /* @__PURE__ */ new Date(sentientData.start * 1e3);
this.expiry = /* @__PURE__ */ new Date(sentientData.end * 1e3);
}
}
};
__decorate([IsString(), __decorateMetadata("design:type", String)], SentientOutpost.prototype, "id", void 0);
__decorate([
IsDate(),
Type(() => Date),
__decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date)
], SentientOutpost.prototype, "activation", void 0);
__decorate([
IsDate(),
Type(() => Date),
__decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date)
], SentientOutpost.prototype, "expiry", void 0);
__decorate([IsOptional(), __decorateMetadata("design:type", Object)], SentientOutpost.prototype, "mission", void 0);
__decorate([IsBoolean(), __decorateMetadata("design:type", Boolean)], SentientOutpost.prototype, "active", void 0);
//#endregion
export { SentientOutpost };