fix: defer resolving of StrippedItems in bounties to extraction (#2972)
Some checks failed
Build / build (push) Has been cancelled
Build Docker image / docker (push) Has been cancelled

Re #2970

Reviewed-on: #2972
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-11-02 23:25:37 -08:00 committed by Sainan
parent c5463166a8
commit bc271216ac

View File

@ -1133,7 +1133,8 @@ export const addMissionRewards = async (
VoidTearParticipantsCurrWave: voidTearWave,
StrippedItems: strippedItems,
AffiliationChanges: AffiliationMods,
InvasionProgress: invasionProgress
InvasionProgress: invasionProgress,
EndOfMatchUpload: endOfMatchUpload
}: IMissionInventoryUpdateRequest,
firstCompletion: boolean
): Promise<AddMissionRewardsReturnType> => {
@ -1392,73 +1393,77 @@ export const addMissionRewards = async (
}
if (strippedItems) {
for (const si of strippedItems) {
if (si.DropTable in droptableAliases) {
logger.debug(`rewriting ${si.DropTable} to ${droptableAliases[si.DropTable]}`);
si.DropTable = droptableAliases[si.DropTable];
}
const droptables = ExportEnemies.droptables[si.DropTable] ?? [];
if (si.DROP_MOD) {
const modDroptable = droptables.find(x => x.type == "mod");
if (modDroptable) {
for (let i = 0; i != si.DROP_MOD.length; ++i) {
const reward = getRandomReward(modDroptable.items)!;
logger.debug(`stripped droptable (mods pool) rolled`, reward);
await addItem(inventory, reward.type);
MissionRewards.push({
StoreItem: toStoreItem(reward.type),
ItemCount: 1,
FromEnemyCache: true // to show "identified"
});
}
} else {
logger.error(`unknown droptable ${si.DropTable} for DROP_MOD`);
if (endOfMatchUpload) {
for (const si of strippedItems) {
if (si.DropTable in droptableAliases) {
logger.debug(`rewriting ${si.DropTable} to ${droptableAliases[si.DropTable]}`);
si.DropTable = droptableAliases[si.DropTable];
}
}
if (si.DROP_BLUEPRINT) {
const blueprintDroptable = droptables.find(x => x.type == "blueprint");
if (blueprintDroptable) {
for (let i = 0; i != si.DROP_BLUEPRINT.length; ++i) {
const reward = getRandomReward(blueprintDroptable.items)!;
logger.debug(`stripped droptable (blueprints pool) rolled`, reward);
await addItem(inventory, reward.type);
MissionRewards.push({
StoreItem: toStoreItem(reward.type),
ItemCount: 1,
FromEnemyCache: true // to show "identified"
});
}
} else {
logger.error(`unknown droptable ${si.DropTable} for DROP_BLUEPRINT`);
}
}
// e.g. H-09 Apex Turret Sumdali
if (si.DROP_MISC_ITEM) {
const resourceDroptable = droptables.find(x => x.type == "resource");
if (resourceDroptable) {
for (let i = 0; i != si.DROP_MISC_ITEM.length; ++i) {
const reward = getRandomReward(resourceDroptable.items)!;
logger.debug(`stripped droptable (resources pool) rolled`, reward);
if (Object.keys(await addItem(inventory, reward.type)).length == 0) {
logger.debug(`item already owned, skipping`);
} else {
const droptables = ExportEnemies.droptables[si.DropTable] ?? [];
if (si.DROP_MOD) {
const modDroptable = droptables.find(x => x.type == "mod");
if (modDroptable) {
for (let i = 0; i != si.DROP_MOD.length; ++i) {
const reward = getRandomReward(modDroptable.items)!;
logger.debug(`stripped droptable (mods pool) rolled`, reward);
await addItem(inventory, reward.type);
MissionRewards.push({
StoreItem: toStoreItem(reward.type),
ItemCount: 1,
FromEnemyCache: true // to show "identified"
});
}
} else {
logger.error(`unknown droptable ${si.DropTable} for DROP_MOD`);
}
} else {
logger.error(`unknown droptable ${si.DropTable} for DROP_MISC_ITEM`);
}
if (si.DROP_BLUEPRINT) {
const blueprintDroptable = droptables.find(x => x.type == "blueprint");
if (blueprintDroptable) {
for (let i = 0; i != si.DROP_BLUEPRINT.length; ++i) {
const reward = getRandomReward(blueprintDroptable.items)!;
logger.debug(`stripped droptable (blueprints pool) rolled`, reward);
await addItem(inventory, reward.type);
MissionRewards.push({
StoreItem: toStoreItem(reward.type),
ItemCount: 1,
FromEnemyCache: true // to show "identified"
});
}
} else {
logger.error(`unknown droptable ${si.DropTable} for DROP_BLUEPRINT`);
}
}
// e.g. H-09 Apex Turret Sumdali
if (si.DROP_MISC_ITEM) {
const resourceDroptable = droptables.find(x => x.type == "resource");
if (resourceDroptable) {
for (let i = 0; i != si.DROP_MISC_ITEM.length; ++i) {
const reward = getRandomReward(resourceDroptable.items)!;
logger.debug(`stripped droptable (resources pool) rolled`, reward);
if (Object.keys(await addItem(inventory, reward.type)).length == 0) {
logger.debug(`item already owned, skipping`);
} else {
MissionRewards.push({
StoreItem: toStoreItem(reward.type),
ItemCount: 1,
FromEnemyCache: true // to show "identified"
});
}
}
} else {
logger.error(`unknown droptable ${si.DropTable} for DROP_MISC_ITEM`);
}
}
if (si.DropTable == "/Lotus/Types/DropTables/ContainerDropTables/VoidVaultMissionRewardsDropTable") {
// Consume netracells search pulse; only when the container reward was picked up. Discussed in https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2673
updateEntratiVault(inventory);
inventory.EntratiVaultCountLastPeriod! += 1;
}
}
if (si.DropTable == "/Lotus/Types/DropTables/ContainerDropTables/VoidVaultMissionRewardsDropTable") {
// Consume netracells search pulse; only when the container reward was picked up. Discussed in https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2673
updateEntratiVault(inventory);
inventory.EntratiVaultCountLastPeriod! += 1;
}
} else {
logger.debug(`ignoring StrippedItems in intermediate inventory update, deferring until extraction`);
}
}