warframe-worldstate-parser
Version:
An Open parser for Warframe's Worldstate in Javascript
95 lines (94 loc) • 2.58 kB
JavaScript
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs";
import { WorldStateObject } from "./WorldStateObject.mjs";
import { IsInt, IsNumber, IsString, Min } from "class-validator";
import { fromNow, languageString, timeDeltaToString } from "warframe-worldstate-data/utilities";
//#region lib/models/DailyDeal.ts
/**
* Represents a daily deal
*/
var DailyDeal = class extends WorldStateObject {
/**
* The item that is being offered in the sale
*/
item;
/**
* The uniqueName for the item on sale
*/
uniqueName;
/**
* The item's original price
*/
originalPrice;
/**
* The item's discounted price
*/
salePrice;
/**
* The number of available items on sale
*/
total;
/**
* The number of items that have already been sold
*/
sold;
/**
* Unique identifier for this deal built from the end time and item
*/
id;
/**
* Percent discount
*/
discount;
/**
* @param data The deal data
* @param deps The dependencies object
* @param deps.locale Locale to use for translations
*/
constructor(data, { locale = "en" } = { locale: "en" }) {
super(data);
this.item = languageString(data.StoreItem, locale);
this.uniqueName = data.StoreItem;
this.originalPrice = data.OriginalPrice;
this.salePrice = data.SalePrice;
this.total = data.AmountTotal;
this.sold = data.AmountSold;
this.id = `${data.StoreItem.split("/").slice(-1)[0]}${this.expiry.getTime()}`;
this.discount = data.Discount;
}
/**
* Get a string indicating how much time is left before the deal expires
*/
get eta() {
return timeDeltaToString(fromNow(this.expiry));
}
};
__decorate([IsString(), __decorateMetadata("design:type", String)], DailyDeal.prototype, "item", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], DailyDeal.prototype, "uniqueName", void 0);
__decorate([
IsInt(),
Min(0),
__decorateMetadata("design:type", Number)
], DailyDeal.prototype, "originalPrice", void 0);
__decorate([
IsInt(),
Min(0),
__decorateMetadata("design:type", Number)
], DailyDeal.prototype, "salePrice", void 0);
__decorate([
IsInt(),
Min(0),
__decorateMetadata("design:type", Number)
], DailyDeal.prototype, "total", void 0);
__decorate([
IsInt(),
Min(0),
__decorateMetadata("design:type", Number)
], DailyDeal.prototype, "sold", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], DailyDeal.prototype, "id", void 0);
__decorate([
IsNumber(),
Min(0),
__decorateMetadata("design:type", Number)
], DailyDeal.prototype, "discount", void 0);
//#endregion
export { DailyDeal };