Skip to content

Commit 48f0994

Browse files
committed
feat: add new stickers_slab.json file.
1 parent fac6374 commit 48f0994

File tree

4 files changed

+218
-5
lines changed

4 files changed

+218
-5
lines changed

group.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const inputFilePathsTemplate = [
1717
"./public/api/{lang}/patches.json",
1818
"./public/api/{lang}/skins_not_grouped.json",
1919
"./public/api/{lang}/stickers.json",
20+
"./public/api/{lang}/stickers_slab.json",
2021
"./public/api/{lang}/keychains.json",
2122
"./public/api/{lang}/tools.json",
2223
];

services/stickers.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ const parseItem = item => {
155155
const image =
156156
cdnImages[`econ/stickers/${item.sticker_material.toLowerCase()}`] ??
157157
getImageUrl(`econ/stickers/${item.sticker_material.toLowerCase()}`);
158-
const image_slab =
159-
cdnImages[`econ/stickers/${item.sticker_material.toLowerCase()}_1355_37`] ??
160-
getImageUrl(`econ/stickers/${item.sticker_material.toLowerCase()}_1355_37`);
161158

162159
// items_game.txt is named as dignitas but in translation as teamdignitas.
163160
if (item.item_name === "#StickerKit_dhw2014_dignitas_gold") {
@@ -208,13 +205,11 @@ const parseItem = item => {
208205
: undefined,
209206
player: proPlayers[item.tournament_player_id] ?? undefined,
210207
image,
211-
image_slab,
212208

213209
// Return original attributes from item_game.json
214210
original: {
215211
name: item.name,
216212
image_inventory: `econ/stickers/${item.sticker_material.toLowerCase()}`,
217-
image_inventory_slab: `econ/stickers/${item.sticker_material.toLowerCase()}_1355_37`,
218213
},
219214
};
220215
};

services/stickersSlab.js

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
import { saveDataJson } from "../utils/saveDataJson.js";
2+
import { $t, languageData } from "./translations.js";
3+
import { state } from "./main.js";
4+
import specialNotes from "../utils/specialNotes.json" with { type: "json" };
5+
import { getRarityColor } from "../utils/index.js";
6+
import { getImageUrl } from "../constants.js";
7+
8+
const isSticker = item => {
9+
if (item.sticker_material === undefined) {
10+
return false;
11+
}
12+
13+
// https://github.com/ByMykel/CSGO-API/issues/208
14+
// Theses team roles stickers are not avaliable in the game, so we don't need to parse them
15+
if (
16+
item.sticker_material.startsWith("team_roles_capsule") &&
17+
item.sticker_material.endsWith("_foil") &&
18+
item.sticker_material !== "team_roles_capsule/pro_foil"
19+
) {
20+
return false;
21+
}
22+
23+
// https://github.com/ByMykel/CSGO-API/issues/209
24+
// These stickers are not avaliable in the game, so we don't need to parse them
25+
// Sticker | 3DMAX | DreamHack 2014
26+
// Sticker | dAT team | DreamHack 2014
27+
// Sticker | London Conspiracy | DreamHack 2014
28+
// Sticker | mousesports | DreamHack 2014
29+
if (["232", "234", "235", "236"].includes(item.object_id)) {
30+
return false;
31+
}
32+
33+
if (!item.item_name.toLowerCase().includes("stickerkit_")) {
34+
return false;
35+
}
36+
37+
if (item.name.includes("graffiti")) {
38+
return false;
39+
}
40+
41+
if (item.name.includes("spray_")) {
42+
return false;
43+
}
44+
45+
return true;
46+
};
47+
48+
const getDescription = () => {
49+
return `${$t("keychain_kc_sticker_display_case_desc")}<br><br>${$t("csgo_tool_keychain_desc")}`;
50+
};
51+
52+
const getType = item => {
53+
if (item.tournament_player_id) {
54+
return "Autograph";
55+
}
56+
57+
if (item.tournament_team_id) {
58+
return "Team";
59+
}
60+
61+
if (item.tournament_event_id) {
62+
return "Event";
63+
}
64+
65+
return "Other";
66+
};
67+
68+
const getEffect = item => {
69+
if ($t(item.item_name, true).includes("(Holo)") || $t(item.item_name, true).includes("(Holo, ")) {
70+
return "Holo";
71+
}
72+
73+
if ($t(item.item_name, true).includes("(Foil)")) {
74+
return "Foil";
75+
}
76+
77+
if ($t(item.item_name, true).includes("(Lenticular)")) {
78+
return "Lenticular";
79+
}
80+
81+
if ($t(item.item_name, true).includes("(Glitter)") || $t(item.item_name, true).includes("(Glitter, ")) {
82+
return "Glitter";
83+
}
84+
85+
if ($t(item.item_name, true).includes("(Gold)") || $t(item.item_name, true).includes("(Gold, ")) {
86+
return "Gold";
87+
}
88+
89+
return "Other";
90+
};
91+
92+
const getMarketHashName = item => {
93+
// 1 - DreamHack 2013
94+
if (item.tournament_event_id === 1) {
95+
return null;
96+
}
97+
98+
// 3 - Katowice 2014
99+
if (item.tournament_event_id === 3) {
100+
if (
101+
(getType(item) === "Event" && item.sticker_material.includes("gold_foil")) ||
102+
(getEffect(item) === "Foil" && getType(item) === "Team")
103+
) {
104+
return null;
105+
}
106+
}
107+
108+
// 4 - Cologne 2014
109+
if (item.tournament_event_id === 4) {
110+
if (getEffect(item) === "Foil" || item.sticker_material === "cologne2014/esl_c") {
111+
return null;
112+
}
113+
}
114+
115+
// 5 - DreamHack 2014,
116+
// 6 - Katowice 2015,
117+
// 7 - Cologne 2015,
118+
// 8 - Cluj-Napoca 2015
119+
// 9 - Columbus 2016
120+
// 10 - Cologne 2016
121+
// 11 - Atlanta 2017
122+
// 12 - Krakow 2017
123+
// 13 - Boston 2018
124+
// 14 - London 2018
125+
// 15 - Katowice 2019
126+
// 16 - Berlin 2019
127+
if ([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16].includes(item.tournament_event_id)) {
128+
if (item.item_rarity === "legendary" && getEffect(item) === "Gold") {
129+
return null;
130+
}
131+
}
132+
133+
if (
134+
item.sticker_material.startsWith("tournament_assets/") ||
135+
item.sticker_material.startsWith("danger_zone/")
136+
) {
137+
return null;
138+
}
139+
140+
return `${$t("keychain_kc_sticker_display_case", true)} | ${$t(item.item_name, true)}`;
141+
};
142+
143+
const parseItem = item => {
144+
const { cratesBySkins, proTeams, proPlayers, collectionsByStickers, cdnImages } = state;
145+
146+
const image =
147+
cdnImages[`econ/stickers/${item.sticker_material.toLowerCase()}_1355_37`] ??
148+
getImageUrl(`econ/stickers/${item.sticker_material.toLowerCase()}_1355_37`);
149+
150+
// items_game.txt is named as dignitas but in translation as teamdignitas.
151+
if (item.item_name === "#StickerKit_dhw2014_dignitas_gold") {
152+
item.item_name = "#StickerKit_dhw2014_teamdignitas_gold";
153+
}
154+
155+
return {
156+
id: `sticker-slab-${item.object_id}`,
157+
name: `${$t("keychain_kc_sticker_display_case")} | ${$t(item.item_name)}`,
158+
description: getDescription(),
159+
def_index: item.object_id,
160+
rarity: item.item_rarity
161+
? {
162+
id: `rarity_${item.item_rarity}`,
163+
name: $t(`rarity_${item.item_rarity}`),
164+
color: getRarityColor(`rarity_${item.item_rarity}`),
165+
}
166+
: {
167+
id: "rarity_default",
168+
name: $t("rarity_default"),
169+
color: getRarityColor("rarity_default"),
170+
},
171+
special_notes: specialNotes?.[`sticker-${item.object_id}`],
172+
crates:
173+
cratesBySkins?.[`sticker-${item.object_id}`]?.map(i => ({
174+
...i,
175+
name: $t(i.name),
176+
})) ?? [],
177+
collections:
178+
collectionsByStickers?.[`sticker-${item.object_id}`]?.map(i => ({
179+
...i,
180+
name: $t(i.name),
181+
})) ?? [],
182+
type: getType(item),
183+
market_hash_name: getMarketHashName(item),
184+
effect: getEffect(item),
185+
tournament: item.tournament_event_id
186+
? {
187+
id: item.tournament_event_id,
188+
name: $t(`csgo_tournament_event_nameshort_${item.tournament_event_id}`),
189+
}
190+
: undefined,
191+
team: proTeams[item.tournament_team_id]
192+
? {
193+
...proTeams[item.tournament_team_id],
194+
name: $t(`csgo_teamid_${item.tournament_team_id}`),
195+
}
196+
: undefined,
197+
player: proPlayers[item.tournament_player_id] ?? undefined,
198+
image,
199+
200+
// Return original attributes from item_game.json
201+
original: {
202+
name: item.name,
203+
image_inventory: `econ/stickers/${item.sticker_material.toLowerCase()}_1355_37`,
204+
},
205+
};
206+
};
207+
208+
export const getStickersSlab = () => {
209+
const { stickerKits } = state;
210+
const { folder } = languageData;
211+
212+
const stickers = stickerKits.filter(isSticker).map(parseItem);
213+
214+
saveDataJson(`./public/api/${folder}/stickers_slab.json`, stickers);
215+
};

update.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { loadTranslations } from "./services/translations.js";
1010
import { getGraffiti } from "./services/graffiti.js";
1111
import { getPatches } from "./services/patches.js";
1212
import { getStickers } from "./services/stickers.js";
13+
import { getStickersSlab } from "./services/stickersSlab.js";
1314
import { getKeychains } from "./services/keychains.js";
1415
import { getSkins } from "./services/skins.js";
1516
import { LANGUAGES_URL } from "./constants.js";
@@ -66,6 +67,7 @@ await Promise.all(
6667
getSkins();
6768
getSkinsNotGrouped();
6869
getStickers();
70+
getStickersSlab();
6971
getKeychains();
7072
getTools();
7173
getBaseWeapons();

0 commit comments

Comments
 (0)