fix: check addItems quantity for Drones & EmailItems (#1612)
Some checks failed
Build Docker image / docker (push) Has been cancelled
Build / build (push) Has been cancelled

Closes #1610

Reviewed-on: #1612
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
Sainan 2025-04-14 07:13:51 -07:00 committed by Sainan
parent 9472f855b6
commit 4a971841a1

View File

@ -381,7 +381,7 @@ export const addItem = async (
} else if (ExportResources[typeName].productCategory == "KubrowPetEggs") { } else if (ExportResources[typeName].productCategory == "KubrowPetEggs") {
const changes: IKubrowPetEggClient[] = []; const changes: IKubrowPetEggClient[] = [];
if (quantity < 0 || quantity > 100) { if (quantity < 0 || quantity > 100) {
throw new Error(`unexpected acquisition quantity of KubrowPetEggs: ${quantity}`); throw new Error(`unexpected acquisition quantity of KubrowPetEggs: got ${quantity}, expected 0..100`);
} }
for (let i = 0; i != quantity; ++i) { for (let i = 0; i != quantity; ++i) {
const egg: IKubrowPetEggDatabase = { const egg: IKubrowPetEggDatabase = {
@ -548,9 +548,18 @@ export const addItem = async (
} }
} }
if (typeName in ExportDrones) { if (typeName in ExportDrones) {
// Can only get 1 at a time from crafting, but for convenience's sake, allow up 100 to via the WebUI.
if (quantity < 0 || quantity > 100) {
throw new Error(`unexpected acquisition quantity of Drones: got ${quantity}, expected 0..100`);
}
for (let i = 0; i != quantity; ++i) {
return addDrone(inventory, typeName); return addDrone(inventory, typeName);
} }
}
if (typeName in ExportEmailItems) { if (typeName in ExportEmailItems) {
if (quantity != 1) {
throw new Error(`unexpected acquisition quantity of EmailItems: got ${quantity}, expected 1`);
}
return await addEmailItem(inventory, typeName); return await addEmailItem(inventory, typeName);
} }