Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error to decant singular dose potions #5700

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/minions/functions/decantPotionFromBank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
return { error: "That's not a valid potion that you can decant." };
}
if (potionToDecant.items.length === 2 && dose > 2) return { error: 'You can only decant mixes into 1 or 2 doses.' };
if (potionToDecant.items.length === 1) return { error: `You can't decant ${potionToDecant.name}.` };
const potionsToRemove = new Bank();
const potionsToAdd = new Bank();
let sumOfPots = 0;
Expand All @@ -39,16 +40,16 @@
}
}

if (!totalDosesToCreate) {

Check warning on line 43 in src/lib/minions/functions/decantPotionFromBank.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
return { error: `You don't have any **${potionToDecant.name}** to decant!` };
}

const newPotionDoseRequested = Math.floor(totalDosesToCreate / dose);
const leftOverDoses = totalDosesToCreate % dose;
if (newPotionDoseRequested) {

Check warning on line 49 in src/lib/minions/functions/decantPotionFromBank.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
potionsToAdd.add(potionToDecant.items[dose - 1], newPotionDoseRequested);
}
if (leftOverDoses) {

Check warning on line 52 in src/lib/minions/functions/decantPotionFromBank.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
potionsToAdd.add(potionToDecant.items[leftOverDoses - 1], 1);
}

Expand Down
Loading