UNPKG

tf2-item-format

Version:
79 lines 2.85 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TEXTURE_EFFECT_EXCEPTION = void 0; exports.default = default_1; const isNumber_1 = __importDefault(require("../../util/isNumber")); const EFFECT_EXCEPTIONS = [ ['Orbiting Fire', 'Eerie Orbiting Fire'], ['Spellbound', 'Spellbound Aspect'], ['Haunted Phantasm', 'Haunted Phantasm Jr'], ['Ghastly Ghosts', 'Ghastly Ghosts Jr'], ]; /** * Iterates over effects object to get matching effect. */ // eslint-disable-next-line consistent-return function default_1(name, attributes) { const effects = attributes.schema.getEffects(); const effectsKeys = Object.keys(effects); for (let i = 0; i < effectsKeys.length; i++) { let effect = effectsKeys[i]; if (!name.includes(`${effect} `)) { continue; } // New type of exception if (effect === 'Smoking' && name.includes('Smoking Smoking Skid Lid')) { return 'Smoking'; } if (isEffectTexture(attributes, effect)) { continue; } for (let j = 0; j < EFFECT_EXCEPTIONS.length; j++) { const exception = EFFECT_EXCEPTIONS[j]; if (effect === exception[0] && name.includes(`${exception[1]} `)) return exception[1]; } if (!(0, isNumber_1.default)(effect) && !isHatNameException(name, effect)) { return effect; } } } /** * Which item and effect cannot exist together. */ const HAT_NAME_EXCEPTIONS = [ ['Cool Breeze', 'Cool'], ['Cool Cat Cardigan', 'Cool'], ['Hot Heels', 'Hot'], ['Hot Case', 'Hot'], ['A Head Full of Hot Air', 'Hot'], ['Bonk Atomic Punch', 'Atomic'], ['Hot Hand', 'Hot'], ['Smoking Jacket', 'Smoking'], ['Smoking Skid Lid', 'Smoking'], ['Hot Huaraches', 'Hot'], ['Cool Capuchon', 'Cool'], ['Hot Dogger', 'Hot'], ['Atomic Accolade', 'Atomic'], ['Bonk! Atomic Punch', 'Atomic'], ['Accursed Apparition', 'Accursed'], ['Taunt: The Hot Wheeler', 'Hot'], ['Frostbite Bonnet', 'Frostbite'], ['Cool Warm Sweater', 'Cool'], ['Frostbite Fit', 'Frostbite'], ['Hot Spaniel', 'Hot'], ]; function isHatNameException(name, effect) { return HAT_NAME_EXCEPTIONS.some((exception) => { const [exceptionName, exceptionEffect] = exception; return name.includes(exceptionName) && effect === exceptionEffect; }); } exports.TEXTURE_EFFECT_EXCEPTION = ['Haunted Ghosts', 'Pumpkin Patch', 'Stardust']; function isEffectTexture(attributes, effectOrTexture) { return !!(exports.TEXTURE_EFFECT_EXCEPTION.includes(effectOrTexture) && attributes.wear); } //# sourceMappingURL=getEffect.js.map