Skip to content

Commit

Permalink
Fix cox issues
Browse files Browse the repository at this point in the history
  • Loading branch information
themrrobert committed Nov 17, 2024
1 parent 3af2561 commit d40f6db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/lib/data/cox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,15 @@ export async function calcCoxDuration(
let totalReduction = 0;
const reductions: Record<string, number> = {};

// 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);
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/mahoji/lib/abstracted_commands/coxCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d40f6db

Please sign in to comment.