Skip to content

Commit

Permalink
Clamp mix quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Oct 13, 2023
1 parent b32ea45 commit c7310a0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/mahoji/commands/mix.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stringMatches } from '@oldschoolgg/toolkit';
import { Time } from 'e';
import { clamp, Time } from 'e';
import { ApplicationCommandOptionType, CommandRunOptions } from 'mahoji';
import { Bank } from 'oldschooljs';

Expand Down Expand Up @@ -99,6 +99,7 @@ export const mixCommand: OSBMahojiCommand = {
const maxCanDo = user.bankWithGP.fits(baseCost);

if (maxCanDo < quantity) quantity = maxCanDo;
quantity = clamp(quantity, 1, maxCanDo);
if (quantity * timeToMixSingleItem > maxTripLength)
return `${user.minionName} can't go on trips longer than ${formatDuration(
maxTripLength
Expand Down

0 comments on commit c7310a0

Please sign in to comment.