@mann-conomy/tf-particle-effects
Version:
A Node.js wrapper for Team Fortress 2's in-game particle effects.
59 lines • 1.98 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const not_found_1 = __importDefault(require("./errors/not-found"));
const utils_1 = require("../lib/utils");
const enums_1 = require("../resources/enums");
const shared_1 = require("../lib/shared");
class ParticleEffect {
constructor(effect = {}, particles) {
this.particles = particles;
this.id = effect.id || enums_1.InvalidParticle.Id;
this.name = effect.name || enums_1.InvalidParticle.Name;
this.language = effect.language || enums_1.LanguageTranslation.English;
if ((0, utils_1.isUndefinedOrEmpty)(this.particles[this.language])) {
throw new not_found_1.default("No particle effects were found matching the provided language code.");
}
}
eval(strict = false) {
return (0, shared_1.evaluate)(this.particles, this.json(), strict);
}
find(strict = false) {
return (0, shared_1.find)(this.particles, this.json(), strict);
}
translate(language, strict = false) {
return (0, shared_1.translate)(this.particles, this.json(), language, strict);
}
all() {
return (0, shared_1.getAllAttributesOrThrow)(this.particles, this.language);
}
getId() {
return this.id;
}
getName() {
return this.name;
}
getLanguage() {
return this.language;
}
json() {
return {
id: this.id,
name: this.name,
language: this.language
};
}
stringify() {
return JSON.stringify(this.json());
}
toString() {
return [this.id, this.name, this.language].join(";");
}
copy() {
return new ParticleEffect(this.json(), this.particles);
}
}
exports.default = ParticleEffect;
//# sourceMappingURL=particle-effect.js.map