diff --git a/config.json b/config.json index 3a184df..2138fea 100644 --- a/config.json +++ b/config.json @@ -96,8 +96,9 @@ "autoSplitOnLastQuestion": false, "autoLife": true, "autoLifeQuestionThreshold": 9, - "splitThreshold": 0.65, + "splitThreshold": 0.6, "autoCheckpoints": true, - "checkpointThreshold": 0.40 + "checkpointThreshold": 0.40, + "maxLivesPerGame": 2 } } \ No newline at end of file diff --git a/src/discord.js b/src/discord.js index c3e0b30..b09c00d 100644 --- a/src/discord.js +++ b/src/discord.js @@ -132,30 +132,38 @@ client.on('message', async (msg) => { const index = numberEmojis.indexOf(collected.array()[0].emoji.name); const tokens = getTokens(tokenFiles[index]); const message = await msg.channel.send(`Checking ${tokens.length} tokens...`); - let i = 1; + const startTime = Date.now(); let unlockedBalance = 0; let unlockedAccounts = 0; let lockedBalance = 0; let lockedAccounts = 0; let noBalance = 0; + let i = 1; + const tasks = []; for (const token of tokens) { - const hq = new HQClient(token, i); - await hq.login(); - const { balance, eligibleForPayout } = await hq.getBalance(); - if (eligibleForPayout) { - unlockedAccounts += 1; - unlockedBalance += balance; - tokens[i - 1].locked = false; - } - if (!eligibleForPayout && balance > 0) { - lockedAccounts += 1; - lockedBalance += balance; - tokens[i - 1].locked = true; - } - if (balance === 0) noBalance += 1; - i += 1; + // eslint-disable-next-line no-loop-func + const promise = async () => { + const hq = new HQClient(token, i); + await hq.login(); + const { balance, eligibleForPayout } = await hq.getBalance(); + if (eligibleForPayout) { + unlockedAccounts += 1; + unlockedBalance += balance; + tokens[i - 1].locked = false; + } + if (!eligibleForPayout && balance > 0) { + lockedAccounts += 1; + lockedBalance += balance; + tokens[i - 1].locked = true; + } + if (balance === 0) noBalance += 1; + i += 1; + return balance; + }; + tasks.push(promise()); } - message.edit('Finished Checking Accounts!'); + await Promise.all(tasks); + message.edit(`Finished Checking ${tokens.length} Accounts in ${(Date.now() - startTime) / 1000}s!`); const embed = new MessageEmbed() .setTitle('Balance') .addField('Unlocked Balance', `$${unlockedBalance.toFixed(2)} across ${unlockedAccounts} accounts`) diff --git a/src/modules/hq-cashout.js b/src/modules/hq-cashout.js index 52e4672..965e97b 100644 --- a/src/modules/hq-cashout.js +++ b/src/modules/hq-cashout.js @@ -15,26 +15,33 @@ export default async () => { let livesCount = 0; let erasersCount = 0; let index = 0; + const tasks = []; + const startTime = Date.now(); + console.edit(`Checking ${tokens.length} accounts...`.yellow); for (const token of tokens) { - index += 1; - const client = new Client(token, index - 1); - await client.login(); - clients.push(client); - const { balance, eligibleForPayout } = await client.getBalance(); - const { lives, erase1s } = await client.getUserData(); - livesCount += lives; - erasersCount += erase1s; - if (balance === 0) noBalanceCount += 1; - if (eligibleForPayout) { - unlockedCount += 1; - unlockedBalance += balance; - } else if (!eligibleForPayout && balance > 0) { - lockedCount += 1; - lockedBalance += balance; - } - console.edit(`Checked ${index}/${tokens.length} accounts.`.yellow); + // eslint-disable-next-line no-loop-func + const promise = async () => { + index += 1; + const client = new Client(token, index - 1); + await client.login(); + clients.push(client); + const { balance, eligibleForPayout } = await client.getBalance(); + const { lives, erase1s } = await client.getUserData(); + livesCount += lives; + erasersCount += erase1s; + if (balance === 0) noBalanceCount += 1; + if (eligibleForPayout) { + unlockedCount += 1; + unlockedBalance += balance; + } else if (!eligibleForPayout && balance > 0) { + lockedCount += 1; + lockedBalance += balance; + } + }; + tasks.push(promise()); } - console.edit(`Finished checking ${tokens.length} accounts!`.green, true); + await Promise.all(tasks); + console.edit(`Finished checking ${tokens.length} accounts in ${(Date.now() - startTime) / 1000}s!`.green, true); if (unlockedCount) console.log(`${' Unlocked Balance '.bgGreen.black} $${unlockedBalance.toFixed(2)} across ${unlockedCount} accounts`); if (lockedCount) console.log(`${' Locked Balance '.bgRed.black} $${lockedBalance.toFixed(2)} across ${lockedCount} accounts`); if (noBalanceCount) console.log(`${' No Balance '.bgYellow.black} ${noBalanceCount}`); diff --git a/src/modules/hq-discord.js b/src/modules/hq-discord.js index b12c979..e9415d0 100644 --- a/src/modules/hq-discord.js +++ b/src/modules/hq-discord.js @@ -159,7 +159,7 @@ export default async (client, prize) => { }); master.ws.on('close', async () => { if (!emuOnly) channels.forEach(c => c.send('**GAME OVER!**')); - const image = genResults('HQ Trivia', winners || 0, winnings || 0, `${correctCount}/${master.questionCount || 0}`); + const image = genResults('HQ Trivia', winners || 0, winnings || 0, `${correctCount}/${master.questionNumber || 0}`); const attachment = new MessageAttachment(image); if (!emuOnly) channels.forEach(c => c.send(attachment)); if (discord.logs) client.channels.get(discord.logChannel).send(attachment);