From d40f6db2e8880fdc77348727044be396d63f21e9 Mon Sep 17 00:00:00 2001 From: themrrobert <10122432+themrrobert@users.noreply.github.com> Date: Sun, 17 Nov 2024 09:08:23 -0800 Subject: [PATCH] Fix cox issues --- src/lib/data/cox.ts | 10 +++++++--- src/mahoji/lib/abstracted_commands/coxCommand.ts | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/data/cox.ts b/src/lib/data/cox.ts index 88c98d274b..3809b23837 100644 --- a/src/lib/data/cox.ts +++ b/src/lib/data/cox.ts @@ -627,11 +627,15 @@ export async function calcCoxDuration( let totalReduction = 0; const reductions: Record = {}; - // Track degradeable items (fakemass works properly with this code, it wont remove 5x charges): const degradeableItems: { item: Item; user: MUser; chargesToDegrade: number }[] = []; + // Map to ensure we only charge/refund users one time. + const uniqueUsers = new Map(); + for (const u of team) { let userPercentChange = 0; + const isUserReal = !uniqueUsers.has(u.id); + uniqueUsers.set(u.id, true); // Reduce time for gear const { total } = calculateUserGearPercents(u); @@ -656,7 +660,7 @@ export async function calcCoxDuration( const canDegrade = checkUserCanUseDegradeableItem(testItem); if (canDegrade.hasEnough) { userPercentChange += item.boost; - degradeableItems.push(testItem); + if (isUserReal) degradeableItems.push(testItem); break; } } @@ -670,7 +674,7 @@ export async function calcCoxDuration( const canDegrade = checkUserCanUseDegradeableItem(testItem); if (canDegrade.hasEnough) { userPercentChange += item.boost; - degradeableItems.push(testItem); + if (isUserReal) degradeableItems.push(testItem); break; } } diff --git a/src/mahoji/lib/abstracted_commands/coxCommand.ts b/src/mahoji/lib/abstracted_commands/coxCommand.ts index 85f5ba450b..367009c2ed 100644 --- a/src/mahoji/lib/abstracted_commands/coxCommand.ts +++ b/src/mahoji/lib/abstracted_commands/coxCommand.ts @@ -207,9 +207,12 @@ export async function coxCommand( if (!channelIsSendable(channel)) return 'No channel found.'; let users: MUser[] = []; + let isFakeMass = false; + const fakeUsers = Math.min(maxSizeInput ?? 5, maxSize); if (type === 'fakemass') { users = new Array(fakeUsers).fill(user); + isFakeMass = true; } else if (type === 'mass') { users = (await setupParty(channel, user, partyOptions)).filter(u => !u.minionIsBusy); } else { @@ -240,7 +243,6 @@ export async function coxCommand( let debugStr = ''; const isSolo = users.length === 1; - const isFakeMass = users.length > 1 && new Set(users).size === 1; for (const d of degradeables) { d.chargesToDegrade *= quantity;