warframe-worldstate-parser
Version:
An Open parser for Warframe's Worldstate in Javascript
77 lines (76 loc) • 2.34 kB
JavaScript
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs";
import { WorldStateObject } from "./WorldStateObject.mjs";
import { IsBoolean, IsString } from "class-validator";
import { fromNow, timeDeltaToString } from "warframe-worldstate-data/utilities";
//#region lib/models/VallisCycle.ts
const lStart = /* @__PURE__ */ new Date("2026-02-04T19:46:48Z");
const loopTime = 16e5;
const coldTime = loopTime - 4e5;
/**
* Get the current cycle state for Orb Vallis
* @returns current cycle state
*/
function getCurrentCycle() {
const toNextFull = loopTime - (Date.now() - lStart.getTime()) % loopTime;
let state = "cold";
if (toNextFull > coldTime) state = "warm";
let toNextMinor;
if (toNextFull < coldTime) toNextMinor = toNextFull;
else toNextMinor = toNextFull - coldTime;
const milliAtNext = Date.now() + toNextMinor;
const milliAtPrev = Date.now() + toNextFull - (state === "warm" ? loopTime : coldTime);
const timeAtPrevious = new Date(milliAtPrev);
timeAtPrevious.setSeconds(0);
return {
state,
toNextMinor,
toNextFull,
timeAtNext: new Date(milliAtNext),
timeAtPrevious
};
}
/**
* Represents the current Earth Day/Night Cycle
* @augments {WorldStateObject}
*/
var VallisCycle = class extends WorldStateObject {
/**
* Whether or not this it's daytime
*/
isWarm;
/**
* Current cycle state. One of `warm`, `cold`
*/
state;
/**
* The current cetus cycle, for calculating the other fields
*/
#ec = getCurrentCycle();
constructor() {
super({ _id: { $oid: "vallisCycle0" } });
this.id = `vallisCycle${this.#ec.timeAtPrevious.getTime()}`;
this.activation = this.#ec.timeAtPrevious;
this.expiry = this.#ec.timeAtNext;
this.isWarm = this.#ec.state === "warm";
this.state = this.#ec.state;
}
/**
* Whether this event has expired
*/
get expired() {
return fromNow(this.expiry) < 0;
}
/**
* Time remaining string
*/
get timeLeft() {
return timeDeltaToString(this.#ec.toNextMinor);
}
get shortString() {
return `${this.timeLeft.replace(/\s\d*s/gi, "")} to ${this.isWarm ? "Cold" : "Warm"}`;
}
};
__decorate([IsBoolean(), __decorateMetadata("design:type", Boolean)], VallisCycle.prototype, "isWarm", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], VallisCycle.prototype, "state", void 0);
//#endregion
export { VallisCycle };