UNPKG

warframe-worldstate-parser

Version:

An Open parser for Warframe's Worldstate in Javascript

121 lines (120 loc) 3.62 kB
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs"; import { Type } from "class-transformer"; import { IsArray, IsDate, IsObject, IsString } from "class-validator"; import { steelPath, timeDeltaToString } from "warframe-worldstate-data/utilities"; //#region lib/models/SteelPathOffering.ts const monday = 1; /** * Gets the first day of the week */ function getFirstDayOfWeek() { const resultDate = /* @__PURE__ */ new Date(); /* istanbul ignore next */ const offset = resultDate.getUTCDay() === 0 ? 6 : resultDate.getUTCDay() - monday; resultDate.setUTCDate(resultDate.getUTCDate() - offset); resultDate.setUTCHours(0); resultDate.setUTCMinutes(0); resultDate.setUTCSeconds(0); resultDate.setUTCMilliseconds(0); return resultDate; } /** * Get the last day of the week */ function getLastDayOfWeek() { const last = new Date(getFirstDayOfWeek()); last.setUTCDate(last.getUTCDate() + 6); last.setUTCHours(23); last.setUTCMinutes(59); last.setUTCSeconds(59); last.setUTCMilliseconds(0); return last; } /** * When was the start of the day */ function getStartOfDay() { const today = /* @__PURE__ */ new Date(); today.setUTCHours(0); today.setUTCMinutes(0); today.setUTCSeconds(0); today.setUTCMilliseconds(0); return today; } /** * When was the end of the day */ function getEndOfDay() { const last = /* @__PURE__ */ new Date(); last.setUTCHours(23); last.setUTCMinutes(59); last.setUTCSeconds(59); last.setUTCMilliseconds(0); return last; } /** * Start of Steel Path cycle calculations */ const start = /* @__PURE__ */ new Date("2020-11-16T00:00:00.000Z"); var SteelPathOfferings = class { /** * Current week's steel path reward */ currentReward; /** * When the current rotation started */ activation; /** * When the current rotation ends */ expiry; /** * Time remaining string */ remaining; /** * Full rotation of steel path rewards */ rotation; /** * Evergreen steel path rewards */ evergreens; /** * Steel path incursion information */ incursions; constructor({ locale }) { const sSinceStart = (Date.now() - start.getTime()) / 1e3; const ind = Math.floor(sSinceStart % 4838400 / 604800); this.currentReward = steelPath(locale).rotation[ind]; this.activation = getFirstDayOfWeek(); this.expiry = getLastDayOfWeek(); this.remaining = timeDeltaToString(this.expiry.getTime() - Date.now()); this.rotation = steelPath(locale).rotation; this.evergreens = steelPath(locale).evergreen; this.incursions = { id: `spi:${getStartOfDay().getTime()}`, activation: getStartOfDay(), expiry: getEndOfDay() }; } }; __decorate([IsObject(), __decorateMetadata("design:type", Object)], SteelPathOfferings.prototype, "currentReward", void 0); __decorate([ IsDate(), Type(() => Date), __decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date) ], SteelPathOfferings.prototype, "activation", void 0); __decorate([ IsDate(), Type(() => Date), __decorateMetadata("design:type", typeof Date === "undefined" ? Object : Date) ], SteelPathOfferings.prototype, "expiry", void 0); __decorate([IsString(), __decorateMetadata("design:type", String)], SteelPathOfferings.prototype, "remaining", void 0); __decorate([IsArray(), __decorateMetadata("design:type", Array)], SteelPathOfferings.prototype, "rotation", void 0); __decorate([IsArray(), __decorateMetadata("design:type", Array)], SteelPathOfferings.prototype, "evergreens", void 0); __decorate([IsObject(), __decorateMetadata("design:type", Object)], SteelPathOfferings.prototype, "incursions", void 0); //#endregion export { SteelPathOfferings };