Skip to content

Commit

Permalink
🔀 Merge pull request #835 from TF2Autobot/development
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 authored Jul 24, 2021
2 parents 468010c + 2c6c2c0 commit 33de199
Showing 1 changed file with 61 additions and 6 deletions.
67 changes: 61 additions & 6 deletions src/classes/Commands/sub-classes/Crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class CraftingCommands {
if (opt.manual === false) {
return this.bot.sendMessage(
steamID,
'❌ Please set crafting.manual option to false in order to use this command.'
'❌ Please set crafting.manual option to true in order to use this command.'
);
}

Expand Down Expand Up @@ -130,7 +130,7 @@ export default class CraftingCommands {

let crafted = 0;
let callbackIndex = 0;
for (let i = 0; i < amountCanCraft; i++) {
for (let i = 0; i < amount; i++) {
const assetidsToCraft = assetids.splice(0, 3);
this.bot.tf2gc.craftToken(assetidsToCraft, tokenType as TokenType, subTokenType as SubTokenType, err => {
if (err) {
Expand All @@ -143,15 +143,15 @@ export default class CraftingCommands {
callbackIndex++;
crafted++;

if (amountCanCraft - callbackIndex === 0) {
if (amount - callbackIndex === 0) {
this.isCrafting = false;

this.bot.client.gamesPlayed([]);
this.bot.client.gamesPlayed(
this.bot.options.miscSettings.game.playOnlyTF2 ? 440 : [this.bot.handler.customGameName, 440]
);

if (crafted < amountCanCraft) {
if (crafted < amount) {
return this.bot.sendMessage(
steamID,
`✅ Successfully crafted ${crafted} ${capTokenType} Token - ${capSubTokenType} (there were some error while crafting).`
Expand All @@ -172,6 +172,7 @@ export default class CraftingCommands {

const reply: string[] = [];
const craftWeaponsByClass = this.bot.craftWeaponsByClass;
const inventory = this.bot.inventoryManager.getInventory;

for (const charClass in craftWeaponsByClass) {
if (!Object.prototype.hasOwnProperty.call(craftWeaponsByClass, charClass)) {
Expand Down Expand Up @@ -202,7 +203,41 @@ export default class CraftingCommands {
const amountCanCraft = Math.floor(availableAmount / 3);
const capSubTokenType = capitalize(charClass);

reply.push(`Class Token - ${capSubTokenType}: can craft ${amountCanCraft} (${availableAmount} items)`);
let sku: string;
switch (charClass) {
case 'scout':
sku = '5003;6';
break;
case 'soldier':
sku = '5005;6';
break;
case 'pyro':
sku = '5009;6';
break;
case 'demoman':
sku = '5006;6';
break;
case 'heavy':
sku = '5007;6';
break;
case 'engineer':
sku = '5011;6';
break;
case 'medic':
sku = '5008;6';
break;
case 'sniper':
sku = '5004;6';
break;
case 'spy':
sku = '5010;6';
}

const currentTokenStock = inventory.getAmount(sku, false, true);

reply.push(
`Class Token - ${capSubTokenType}: can craft ${amountCanCraft} (${availableAmount} items), token stock: ${currentTokenStock}`
);
}

const craftWeaponsBySlots = this.craftWeaponsBySlot;
Expand Down Expand Up @@ -236,7 +271,27 @@ export default class CraftingCommands {
const amountCanCraft = Math.floor(availableAmount / 3);
const capSubTokenType = slot === 'pda2' ? 'PDA2' : capitalize(slot);

reply.push(`Slot Token - ${capSubTokenType}: can craft ${amountCanCraft} (${availableAmount} items)`);
let sku: string;
switch (slot) {
case 'primary':
sku = '5012;6';
break;
case 'secondary':
sku = '5013;6';
break;
case 'melee':
sku = '5014;6';
break;
case 'pda2':
sku = '5018;6';
break;
}

const currentTokenStock = inventory.getAmount(sku, false, true);

reply.push(
`Slot Token - ${capSubTokenType}: can craft ${amountCanCraft} (${availableAmount} items), token stock: ${currentTokenStock}`
);
}

this.bot.sendMessage(steamID, '🔨 Crafting token info:\n\n- ' + reply.join('\n- '));
Expand Down

0 comments on commit 33de199

Please sign in to comment.