feat: handle EmailItems received during mission #1088

Merged
Sainan merged 3 commits from mission-EmailItems into main 2025-03-07 00:41:19 -08:00
Showing only changes of commit 514e306394 - Show all commits

View File

@ -946,11 +946,16 @@ export const addEmailItem = async (
typeName: string,
inventoryChanges: IInventoryChanges = {}
): Promise<IInventoryChanges> => {
const emailItem = ExportEmailItems[typeName];
if (!emailItem.sendOnlyOnce || !inventory.EmailItems.find(x => x.ItemType == typeName)) {
await createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(emailItem.message)]);
const meta = ExportEmailItems[typeName];
const emailItem = inventory.EmailItems.find(x => x.ItemType == typeName);
if (!emailItem || !meta.sendOnlyOnce) {
await createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(meta.message)]);
inventory.EmailItems.push({ ItemType: typeName, ItemCount: 1 });
if (emailItem) {
emailItem.ItemCount += 1;
} else {
inventory.EmailItems.push({ ItemType: typeName, ItemCount: 1 });
}
inventoryChanges.EmailItems ??= [];
inventoryChanges.EmailItems.push({ ItemType: typeName, ItemCount: 1 });