UNPKG

warframe-worldstate-parser

Version:

An Open parser for Warframe's Worldstate in Javascript

96 lines (95 loc) 2.96 kB
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs"; import { WorldStateObject } from "./WorldStateObject.mjs"; import { IsBoolean, IsInt, IsNumber, IsString, Min } from "class-validator"; import { fromNow, languageString, timeDeltaToString } from "warframe-worldstate-data/utilities"; //#region lib/models/FlashSale.ts /** * Represents a flash sale */ var FlashSale = class extends WorldStateObject { /** * The item being offered in the flash sale */ item; /** * The item's discount percentage */ discount; /** * The item's discounted credit price */ regularOverride; /** * The item's discounted platinum price */ premiumOverride; /** * Whether this item is show in the in-game market */ isShownInMarket; /** * Whether this item is featured in the in-game market */ isFeatured; /** * Whether this item is marked as popular in the in-game market */ isPopular; /** * Unique identifier for this sale built from the end time and reward */ id; /** * @param {object} data The flash sale data * @param {Dependency} deps The dependencies object * @param {string} deps.locale Locale to use for translations */ constructor(data, { locale = "en" } = { locale: "en" }) { super({ Activation: data.StartDate, Expiry: data.EndDate }); this.item = languageString(data.TypeName, locale); this.discount = data.Discount; this.regularOverride = data.RegularOverride; this.premiumOverride = data.PremiumOverride; this.isShownInMarket = data.ShowInMarket; this.isFeatured = data.Featured; this.isPopular = data.Popular; this.id = `${data.TypeName.split("/").slice(-1)[0]}${this.expiry.getTime()}`; } /** * ETA string (at time of object creation) */ get eta() { return timeDeltaToString(fromNow(this.expiry)); } /** * Whether or not this is expired (at time of object creation) */ get expired() { return fromNow(this.expiry) < 0; } }; __decorate([IsString(), __decorateMetadata("design:type", String)], FlashSale.prototype, "item", void 0); __decorate([ IsNumber(), Min(0), __decorateMetadata("design:type", Number) ], FlashSale.prototype, "discount", void 0); __decorate([ IsInt(), Min(0), __decorateMetadata("design:type", Number) ], FlashSale.prototype, "regularOverride", void 0); __decorate([ IsInt(), Min(0), __decorateMetadata("design:type", Number) ], FlashSale.prototype, "premiumOverride", void 0); __decorate([IsBoolean(), __decorateMetadata("design:type", Boolean)], FlashSale.prototype, "isShownInMarket", void 0); __decorate([IsBoolean(), __decorateMetadata("design:type", Boolean)], FlashSale.prototype, "isFeatured", void 0); __decorate([IsBoolean(), __decorateMetadata("design:type", Boolean)], FlashSale.prototype, "isPopular", void 0); __decorate([IsString(), __decorateMetadata("design:type", String)], FlashSale.prototype, "id", void 0); //#endregion export { FlashSale };