Skip to content

Commit

Permalink
Merge pull request #15 from Step7750/fix/graffiti-precedence
Browse files Browse the repository at this point in the history
Prefers Kits with Graffiti in the Name for Sealed Graffitis
  • Loading branch information
Step7750 authored Feb 24, 2019
2 parents c1c18d9 + f79f5a9 commit 0eb2c89
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,20 +593,35 @@ class CSGOCdn extends EventEmitter {

const stickerKits = this.itemsGame.sticker_kits;

const kitIndex = Object.keys(stickerKits).find((n) => {
const kitIndices = Object.keys(stickerKits).filter((n) => {
const k = stickerKits[n];

return k.item_name === stickerTag;
});

const kit = stickerKits[kitIndex];
// prefer kit indices with "graffiti" in the name
kitIndices.sort((a, b) => {
const index1 = !!stickerKits[a].name && stickerKits[a].name.indexOf('graffiti');
const index2 = !!stickerKits[b].name && stickerKits[b].name.indexOf('graffiti');
if (index1 === index2) {
return 0
} else if (index1 > -1) {
return -1
} else {
return 1
}
});

if (!kit || !kit.sticker_material) continue;
for (const kitIndex of kitIndices) {
const kit = stickerKits[kitIndex];

const url = this.getStickerURL(kit.sticker_material, true);
if (!kit || !kit.sticker_material) continue;

if (url) {
return url;
const url = this.getStickerURL(kit.sticker_material, true);

if (url) {
return url;
}
}
}
}
Expand Down

0 comments on commit 0eb2c89

Please sign in to comment.