Skip to content

code field & tournament, team, player for stickers #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions services/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const parseItem = (item) => {
return {
id: `agent-${item.object_id}`,
name: $t(item.item_name),
code: item.name,
description: $t(item.item_description),
rarity: {
id: `rarity_${item.item_rarity}_character`,
Expand Down
1 change: 1 addition & 0 deletions services/collectibles.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const parseItem = (item) => {
item_name: $t(item.item_name),
})
: $t(item.item_name),
code: item.item_name,
description: item.item_description
? $t(item.item_description)
: item.item_description_prefab
Expand Down
1 change: 1 addition & 0 deletions services/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const parseItem = (item) => {
...i,
name: $t(i.name),
})),
code: item.name,
contains: skinsByCollections?.[item.name.replace("#CSGO_", "")].map(
(i) => ({
...i,
Expand Down
1 change: 1 addition & 0 deletions services/crates.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const parseItem = (item, prefabs) => {
return {
id: `crate-${item.object_id}`,
name: $t(item.item_name),
code: item.item_name,
description:
$t(item.item_description) ?? $t(item.item_description_prefab),
type: getCrateType(item),
Expand Down
2 changes: 2 additions & 0 deletions services/graffiti.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const parseItemSealedGraffiti = (item) => {
name: `${$t("csgo_tool_spray")} | ${$t(item.item_name)} (${$t(
colorKey
)})`,
code: item.item_name,
description: getDescription(item),
rarity: {
id: `rarity_${item.item_rarity}`,
Expand All @@ -75,6 +76,7 @@ const parseItemSealedGraffiti = (item) => {
return {
id: `graffiti-${item.object_id}`,
name: `${$t("csgo_tool_spray")} | ${$t(item.item_name)}`,
code: item.name,
description: getDescription(item),
rarity: {
id: `rarity_${item.item_rarity}`,
Expand Down
1 change: 1 addition & 0 deletions services/keychains.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const parseItem = (item) => {
return {
id: `keychain-${item.object_id}`,
name: `${$t("CSGO_Tool_Keychain")} | ${$t(item.loc_name)}`,
code: item.loc_name,
description: $t("csgo_tool_keychain_desc"),
rarity: {
id: `rarity_${item.item_rarity}`,
Expand Down
1 change: 1 addition & 0 deletions services/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const parseItem = (item) => {
return {
id: `key-${item.object_id}`,
name: $t(item.item_name),
code: item.item_name,
description:
$t(item.item_description) ?? $t(item.item_description_prefab),
crates,
Expand Down
26 changes: 26 additions & 0 deletions services/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,30 @@ export const loadStattrakSkins = () => {
state.stattTrakSkins = result;
};

export const loadProTeams = () => {
state.proTeams = Object.entries(state.itemsGame.pro_teams)
.map(([key, item]) => ({
...item,
object_id: key,
}));

state.proTeams = Object.fromEntries(
state.proTeams.map((item) => [item.object_id, item])
);
};

export const loadProPlayers = () => {
state.proPlayers = Object.entries(state.itemsGame.pro_players)
.map(([key, item]) => ({
...item,
object_id: key,
}));

state.proPlayers = Object.fromEntries(
state.proPlayers.map((item) => [item.object_id, item])
);
};

const getItemFromKey = (key) => {
const {
items,
Expand Down Expand Up @@ -895,4 +919,6 @@ export const loadData = async () => {
loadCollectionsBySkins();
loadSouvenirSkins();
loadStattrakSkins();
loadProTeams();
loadProPlayers();
};
2 changes: 2 additions & 0 deletions services/musicKits.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const parseItem = (item) => {
const normalMusicKit = {
id: `music_kit-${item.object_id}`,
name: (exclusive || valve) ? $t(item.loc_name) : $t(item.coupon_name),
code: item.name,
description: $t(item.loc_description),
rarity: {
id: "rarity_rare",
Expand All @@ -51,6 +52,7 @@ const parseItem = (item) => {
const stattrakMusicKit = {
id: `music_kit-${item.object_id}_st`,
name: $t(`${item.coupon_name}_stattrak`),
code: item.name,
description: $t(item.loc_description),
rarity: {
id: "rarity_rare",
Expand Down
1 change: 1 addition & 0 deletions services/patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const parseItem = (item) => {
return {
id: `patch-${item.object_id}`,
name: `${$t("csgo_tool_patch")} | ${$t(item.item_name)}`,
code: item.name,
description: getDescription(item),
rarity: {
id: `rarity_${item.item_rarity}`,
Expand Down
2 changes: 2 additions & 0 deletions services/skins.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const parseItem = (item, items) => {
pattern: $t(paintKits[pattern]?.description_tag),
})
: `${translatedName} | ${$t(paintKits[pattern]?.description_tag)}`,
code: items[weapon].name,
description: getDescription(translatedDescription, paintKits, pattern),
weapon: {
id: weapon,
Expand Down Expand Up @@ -181,6 +182,7 @@ export const getSkins = () => {
name: $tc("rare_special_vanilla", {
item_name: $t(knife.item_name),
}),
code: knife.name,
description: $t(knife.item_description),
weapon: {
id: knife.item_name,
Expand Down
3 changes: 3 additions & 0 deletions services/skinsNotGrouped.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const parseItem = (item, items) => {
pattern: $t(paintKits[pattern]?.description_tag),
wear: $t(wear),
}),
code: items[weapon].name,
description: getDescription(
translatedDescription,
paintKits,
Expand Down Expand Up @@ -254,6 +255,7 @@ export const getSkinsNotGrouped = () => {
name: $tc(type, {
item_name: $t(knife.item_name),
}),
code: knife.name,
description: getVanillaDescription($t(knife.item_description), type === "rare_special_vanilla_stattrak"),
weapon: {
id: knife.item_name,
Expand All @@ -270,6 +272,7 @@ export const getSkinsNotGrouped = () => {
color: getRarityColor(`rarity_ancient_weapon`),
},
stattrak: type === "rare_special_vanilla_stattrak",
paint_index: null,
market_hash_name: skinMarketHashName({
itemName: $t(knife.item_name, true),
pattern: null,
Expand Down
36 changes: 35 additions & 1 deletion services/stickers.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const getMarketHashName = (item) => {
};

const parseItem = (item) => {
const { cratesBySkins } = state;
const { cratesBySkins, proTeams, proPlayers } = state;

const image = getImageUrl(
`econ/stickers/${item.sticker_material.toLowerCase()}`
Expand All @@ -156,9 +156,40 @@ const parseItem = (item) => {
item.item_name = "#StickerKit_dhw2014_teamdignitas_gold";
}

let tournament = null;
let team = null;
let player = null;

if (item.tournament_event_id) {
tournament = {
id: item.tournament_event_id,
name: $t(`CSGO_Tournament_Event_NameShort_${item.tournament_event_id}`)
};
}

if (item.tournament_team_id && proTeams[item.tournament_team_id]) {
team = {
id: item.tournament_team_id,
tag: proTeams[item.tournament_team_id].tag,
geo: proTeams[item.tournament_team_id].geo,
name: $t(`CSGO_TeamID_${item.tournament_team_id}`)
};
}

if (item.tournament_player_id && proPlayers[item.tournament_player_id]) {
player = {
id: item.tournament_player_id,
code: proPlayers[item.tournament_player_id].code,
geo: proPlayers[item.tournament_player_id].geo,
dob: proPlayers[item.tournament_player_id].dob,
name: proPlayers[item.tournament_player_id].name,
};
}

return {
id: `sticker-${item.object_id}`,
name: `${$t("csgo_tool_sticker")} | ${$t(item.item_name)}`,
code: item.name,
description: getDescription(item),
rarity: item.item_rarity
? {
Expand Down Expand Up @@ -188,6 +219,9 @@ const parseItem = (item) => {
type: getType(item),
market_hash_name: getMarketHashName(item),
effect: getEffect(item),
tournament,
team,
player,
image,
};
};
Expand Down