warframe-worldstate-parser
Version:
An Open parser for Warframe's Worldstate in Javascript
106 lines (105 loc) • 3.45 kB
JavaScript
import { n as __decorateMetadata, t as __decorate } from "../../decorate-BCC26nnB.mjs";
import { WorldStateObject } from "./WorldStateObject.mjs";
import { IsBoolean, IsInt, IsOptional, IsString, Min } from "class-validator";
import { conclaveCategory, conclaveChallenge, conclaveMode, fromNow, parseDate, timeDeltaToString } from "warframe-worldstate-data/utilities";
//#region lib/models/ConclaveChallenge.ts
/**
* Represents a Conclave challenge
* @augments {WorldStateObject}
*/
var ConclaveChallenge = class extends WorldStateObject {
/**
* The number of times that the challenge's objective needs to be completed
*/
amount;
/**
* The PVP mode that the challenge must be completed in
*/
mode;
/**
* The challenge's category (daily, weekly...)
*/
category;
/**
* The challenge category unlocalized
*/
categoryKey;
/**
* The challenge's description text
*/
description;
/**
* Title of the challenge
*/
title;
/**
* Standing granted by completing challenge.
*/
standing;
/**
* Whether this is a daily conclave challenge.
*/
daily;
/**
* Whether this is the root challenge
*/
rootChallenge;
/**
* @param {object} data The challenge data
* @param {object} deps The dependencies object
* @param {string} deps.locale Locale to use for translations
*/
constructor(data, { locale = "en" } = { locale: "en" }) {
super(data);
this.expiry = parseDate(data.endDate);
this.activation = parseDate(data.startDate);
this.amount = data.params[0].v;
this.mode = conclaveMode(data.PVPMode, locale);
this.category = conclaveCategory(data.Category, locale);
this.categoryKey = conclaveCategory(data.Category, "en");
this.daily = this.categoryKey.toLowerCase() === "day";
this.rootChallenge = this.categoryKey.toLowerCase() === "week_root";
const challenge = conclaveChallenge(data.challengeTypeRefID, locale);
({title: this.title, description: this.description, standing: this.standing} = challenge);
}
/**
* Whether or not this is expired (at time of object creation)
*/
get expired() {
return fromNow(this.expiry) < 0;
}
/**
* ETA string (at time of object creation)
*/
get eta() {
return timeDeltaToString(fromNow(this.expiry));
}
};
__decorate([
IsInt(),
Min(0),
__decorateMetadata("design:type", Number)
], ConclaveChallenge.prototype, "amount", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], ConclaveChallenge.prototype, "mode", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], ConclaveChallenge.prototype, "category", void 0);
__decorate([IsString(), __decorateMetadata("design:type", String)], ConclaveChallenge.prototype, "categoryKey", void 0);
__decorate([
IsOptional(),
IsString(),
__decorateMetadata("design:type", String)
], ConclaveChallenge.prototype, "description", void 0);
__decorate([
IsOptional(),
IsString(),
__decorateMetadata("design:type", String)
], ConclaveChallenge.prototype, "title", void 0);
__decorate([
IsOptional(),
IsInt(),
Min(0),
__decorateMetadata("design:type", Number)
], ConclaveChallenge.prototype, "standing", void 0);
__decorate([IsBoolean(), __decorateMetadata("design:type", Boolean)], ConclaveChallenge.prototype, "daily", void 0);
__decorate([IsBoolean(), __decorateMetadata("design:type", Boolean)], ConclaveChallenge.prototype, "rootChallenge", void 0);
//#endregion
export { ConclaveChallenge };