tf2-item-format
Version:
Format's TF2 items like backpack.tf does
71 lines • 3.13 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const festivized_1 = require("./getDescriptions/festivized");
const effect_1 = require("./getDescriptions/effect");
const spell_1 = require("./getDescriptions/spell");
const part_1 = require("./getDescriptions/part");
const paint_1 = require("./getDescriptions/paint");
const craftable_1 = require("./getDescriptions/craftable");
const texture_1 = require("./getDescriptions/texture");
const item_number_1 = require("./getDescriptions/item-number");
const Killstreak_1 = __importDefault(require("./getDescriptions/Killstreak"));
/**
* Gets all important attributes from descriptions.
* Checked in order from steam.
*/
function default_1(econ) {
const { tags } = econ;
const { descriptions = [] } = econ.item;
const killstreak = new Killstreak_1.default(econ.schema);
/**
* @type {descriptionAttributes}
*/
const attributes = {
craftable: true,
effect: '',
killstreak,
spells: [],
parts: [],
};
for (let i = 0; i < descriptions.length; i++) {
const description = descriptions[i];
if ((0, item_number_1.isMedal)(description))
attributes.itemNumber = {
type: 'medal',
value: (0, item_number_1.getMedal)(description),
};
else if ((0, item_number_1.isCrate)(description))
attributes.itemNumber = {
type: 'crate',
value: (0, item_number_1.getCrate)(description),
};
else if ((0, part_1.isPart)(description, econ))
attributes.parts.push((0, part_1.getPart)(description));
else if ((0, paint_1.isPaint)(description))
attributes.paint = (0, paint_1.getPaint)(description);
else if ((0, effect_1.isEffect)(description, tags))
attributes.effect = (0, effect_1.getEffect)(description);
else if ((0, festivized_1.isFestivized)(description))
attributes.festivized = true;
else if ((0, spell_1.isSpell)(description))
attributes.spells.push((0, spell_1.getSpell)(description));
else if (Killstreak_1.default.isKillstreakerSheenDescription(description))
killstreak.setKillstreakerSheen(description);
else if (Killstreak_1.default.isKillstreaker(description))
killstreak.setKillstreaker(description);
else if (Killstreak_1.default.isSheen(description))
killstreak.setSheen(description);
else if (Killstreak_1.default.isKillstreak(description))
killstreak.setKillstreak();
else if ((0, texture_1.isItemsTexture)(description, econ))
attributes.texture = (0, texture_1.getTexture)(description, econ.schema);
else if (!(0, craftable_1.isCraftable)(description))
attributes.craftable = false;
}
return attributes;
}
//# sourceMappingURL=getDescriptions.js.map