Skip to content
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

Items stack listing #233

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Changes from 2 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
27 changes: 20 additions & 7 deletions code.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@
appid: item.appid,
contextid: item.contextid,
assetid: item.assetid || item.id,
amount: 1,
amount: item.amount,
price: price
},
responseType: 'json'
Expand Down Expand Up @@ -1294,6 +1294,14 @@
}
}

function getAmountString(amount) {
if (amount == 1) {
return '';
}

return ` [x${amount}]`;
}

const sellQueue = async.queue(
(task, next) => {
market.sellItem(
Expand All @@ -1313,11 +1321,11 @@
const callback = () => setTimeout(() => next(), getRandomInt(1000, 1500));

if (success) {
logDOM(`${padLeft} - ${itemName} listed for ${formatPrice(market.getPriceIncludingFees(task.sellPrice))}, you will receive ${formatPrice(task.sellPrice)}.`);
logDOM(`${padLeft} - ${itemName}${getAmountString(task.item.amount)} listed for ${formatPrice(market.getPriceIncludingFees(task.sellPrice) * task.item.amount)}, you will receive ${formatPrice(task.sellPrice * task.item.amount)}.`);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be better to have in front. In your example: 34x Hexagonana
We can probably also avoid the function, it's pretty much a one-liner, e.g. const amount = task.item.amount == 1 ? '' : task.item.amount + 'x ';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nuklon, done
image

Commit 494a094

$(`#${task.item.appid}_${task.item.contextid}_${itemId}`).css('background', COLOR_SUCCESS);

totalPriceWithoutFeesOnMarket += task.sellPrice;
totalPriceWithFeesOnMarket += market.getPriceIncludingFees(task.sellPrice);
totalPriceWithoutFeesOnMarket += task.sellPrice * task.item.amount;
totalPriceWithFeesOnMarket += market.getPriceIncludingFees(task.sellPrice) * task.item.amount;

updateTotals();
callback()
Expand Down Expand Up @@ -3048,17 +3056,19 @@

let totalPriceBuyer = 0;
let totalPriceSeller = 0;
let totalAmount = 0;
// Add the listings to the queue to be checked for the price.
for (let i = 0; i < marketLists.length; i++) {
for (let j = 0; j < marketLists[i].items.length; j++) {
const listingid = replaceNonNumbers(marketLists[i].items[j].values().market_listing_item_name);
const assetInfo = getAssetInfoFromListingId(listingid);

totalAmount += assetInfo.amount
if (!isNaN(assetInfo.priceBuyer)) {
totalPriceBuyer += assetInfo.priceBuyer;
totalPriceBuyer += assetInfo.priceBuyer * assetInfo.amount;
}
if (!isNaN(assetInfo.priceSeller)) {
totalPriceSeller += assetInfo.priceSeller;
totalPriceSeller += assetInfo.priceSeller * assetInfo.amount;
}

marketListingsQueue.push({
Expand All @@ -3071,7 +3081,8 @@
}
}

$('#my_market_selllistings_number').append(`<span id="my_market_sellistings_total_price">, ${formatPrice(totalPriceBuyer)} ➤ ${formatPrice(totalPriceSeller)}</span>`);
$('#my_market_selllistings_number').append(`<span id="my_market_sellistings_total_amount"> [${totalAmount}]</span>`)
.append(`<span id="my_market_sellistings_total_price">, ${formatPrice(totalPriceBuyer)} ➤ ${formatPrice(totalPriceSeller)}</span>`);
}


Expand All @@ -3094,10 +3105,12 @@
const appid = replaceNonNumbers(itemIds[2]);
const contextid = replaceNonNumbers(itemIds[3]);
const assetid = replaceNonNumbers(itemIds[4]);
const amount = Number(unsafeWindow.g_rgAssets[appid][contextid][assetid].amount);
return {
appid,
contextid,
assetid,
amount,
priceBuyer,
priceSeller
};
Expand Down
Loading