SENPAY98K Posted September 29, 2022 Report Posted September 29, 2022 Hi, How would you check sets in the incoming trade offers which contains random cards? There is already a database that is used by level up bots to define how much card in the set of game. Quote
PonyExpress Posted September 30, 2022 Report Posted September 30, 2022 If I remember correctly, you can specify language in Options ( https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/wiki/TradeOfferManager#language ) In this case, you will receive all data like name and tags. This can take up a lot of memory. (in my case, this required several gigabytes with a large number of trading offers / items in offers) If language disabled, you can check only classid. I don't know of any database that gives any additional information by classid. Quote
SENPAY98K Posted September 30, 2022 Author Report Posted September 30, 2022 1 minute ago, PonyExpress said: If I remember correctly, you can specify language in Options ( https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/wiki/TradeOfferManager#language ) In this case, you will receive all data like name and tags. This can take up a lot of memory. (in my case, this required several gigabytes with a large number of trading offers / items in offers) If language disabled, you can check only classid. I don't know of any database that gives any additional information by classid. The language is not the problem here, I receive the offer, i check the offer details, then filter items for trading cards only, after that i have a database of {appid, number of cards in set} which i need to compare against it and retrun the amount of sets Im lacking the idea of how to process it! Quote
PonyExpress Posted September 30, 2022 Report Posted September 30, 2022 In my case it works like this. Maybe this will help you. // lodash // cards = { "<appid>": ["<classid>": [ {<item>}, ... ], ... ], ... } // cardData = {"220":{"amount":8,"name":"Half-Life 2"} ... } function getSets(cards, callback) { let cardSets = {} let extraCards = [] let unknownCards = [] lodash.forOwn(cards, (cards, id) => { id = id.toString() if (cardData[id]) { let cardCount = lodash.mapValues(cards, array => array.length) cardCount = Object.keys(cardCount).map(number => cardCount[number]) let min = Math.min(...cardCount) let max = Math.max(...cardCount) // There is at least one full set. if (Object.keys(cards).length == cardData[id].amount) { cardSets[id] = [] for (let i = 0; i < min; i++) { let set = [] lodash.forOwn(cards, item => { set.push(item[i]) }) cardSets[id].push(set) } // There are no full sets. } else { min = 0 } // Extra cards: for (let i = min; i < max; i++) { lodash.forOwn(cards, item => { if (item[i]) { extraCards.push(item[i]) } }) } // Unknown cards: } else { lodash.forOwn(cards, item => { unknownCards.push(item) }) } }) callback(cardSets, extraCards, unknownCards) } Quote
SENPAY98K Posted September 30, 2022 Author Report Posted September 30, 2022 2 minutes ago, PonyExpress said: In my case it works like this. Maybe this will help you. // lodash // cards = { "<appid>": ["<classid>": [ {<item>}, ... ], ... ], ... } // cardData = {"220":{"amount":8,"name":"Half-Life 2"} ... } function getSets(cards, callback) { let cardSets = {} let extraCards = [] let unknownCards = [] lodash.forOwn(cards, (cards, id) => { id = id.toString() if (cardData[id]) { let cardCount = lodash.mapValues(cards, array => array.length) cardCount = Object.keys(cardCount).map(number => cardCount[number]) let min = Math.min(...cardCount) let max = Math.max(...cardCount) // There is at least one full set. if (Object.keys(cards).length == cardData[id].amount) { cardSets[id] = [] for (let i = 0; i < min; i++) { let set = [] lodash.forOwn(cards, item => { set.push(item[i]) }) cardSets[id].push(set) } // There are no full sets. } else { min = 0 } // Extra cards: for (let i = min; i < max; i++) { lodash.forOwn(cards, item => { if (item[i]) { extraCards.push(item[i]) } }) } // Unknown cards: } else { lodash.forOwn(cards, item => { unknownCards.push(item) }) } }) callback(cardSets, extraCards, unknownCards) } I will try it, thank you Quote
SENPAY98K Posted October 2, 2022 Author Report Posted October 2, 2022 (edited) @PonyExpress Does not work i guess, returns empty object and arrays const database = { "730": { "amount": 5}, "603750": { "amount": 5}, ... } const cards = OFFER.itemsToGive; await getSets(cards, (cardSets, extraCards, unknownCards) => { if (cardSets) console.log(cardSets); if (extraCards) console.log(extraCards); if (unknownCards) console.log(unknownCards); }) Edited October 4, 2022 by SENPAY98K added code Quote
That Guy From 199x Posted February 25, 2023 Report Posted February 25, 2023 You have to pass the client's/bot's trade window to your getSets function that you use to sort your bot's/client's inventory when making an offer. And yes, you need to set your language to get the appid's of items in trade window otherwise you will end up with "0" sets. Also, you need to check if there are extra cards on the trade-offer as it will be not counted as a set. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.