UNPKG

tf2-item-format

Version:
37 lines 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isPart = isPart; exports.getPart = getPart; /** * Checks if description includes part */ function isPart(description, econ) { /** * Two types of part descriptions: * 1) '(Airborne Enemy Kills: 4)' * 2) ' Airborne Enemy Kill: 4' */ // type === 'Strange' // type === 'Points Scored' // if (!/^( {5}(.+): \d+)|(\((.+): \d+\))$/.test(description.value)) return false; const part = getPart(description); if (['Kills', 'Assists'].includes(part)) { return isCosmetic(econ); } // Regex matches and now we just check for color. return description.color === '756b5e'; } /** * Gets part from description */ function getPart(description) { const match = description.value.match(/^ {5}(.+): \d+|\((.+): \d+\)$/) || []; return match[1] || match[2]; } function isCosmetic(econ) { return (econ.item.type.includes('Strange') && econ.item.type.includes('Points Scored')); } //# sourceMappingURL=part.js.map