XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

fix: defer resolving of StrippedItems in bounties to extraction (#2972)

Re #2970 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2972 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

bc271216
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +60 -55
Modified src/services/missionInventoryUpdateService.ts +60 -55
@@ -1133,7 +1133,8 @@ export const addMissionRewards = async (
1133 1133 VoidTearParticipantsCurrWave: voidTearWave,
1134 1134 StrippedItems: strippedItems,
1135 1135 AffiliationChanges: AffiliationMods,
1136 InvasionProgress: invasionProgress
1136 InvasionProgress: invasionProgress,
1137 EndOfMatchUpload: endOfMatchUpload
1137 1138 }: IMissionInventoryUpdateRequest,
1138 1139 firstCompletion: boolean
1139 1140 ): Promise<AddMissionRewardsReturnType> => {
@@ -1392,73 +1393,77 @@ export const addMissionRewards = async (
1392 1393 }
1393 1394
1394 1395 if (strippedItems) {
1395 for (const si of strippedItems) {
1396 if (si.DropTable in droptableAliases) {
1397 logger.debug(`rewriting ${si.DropTable} to ${droptableAliases[si.DropTable]}`);
1398 si.DropTable = droptableAliases[si.DropTable];
1399 }
1400 const droptables = ExportEnemies.droptables[si.DropTable] ?? [];
1401 if (si.DROP_MOD) {
1402 const modDroptable = droptables.find(x => x.type == "mod");
1403 if (modDroptable) {
1404 for (let i = 0; i != si.DROP_MOD.length; ++i) {
1405 const reward = getRandomReward(modDroptable.items)!;
1406 logger.debug(`stripped droptable (mods pool) rolled`, reward);
1407 await addItem(inventory, reward.type);
1408 MissionRewards.push({
1409 StoreItem: toStoreItem(reward.type),
1410 ItemCount: 1,
1411 FromEnemyCache: true // to show "identified"
1412 });
1413 }
1414 } else {
1415 logger.error(`unknown droptable ${si.DropTable} for DROP_MOD`);
1396 if (endOfMatchUpload) {
1397 for (const si of strippedItems) {
1398 if (si.DropTable in droptableAliases) {
1399 logger.debug(`rewriting ${si.DropTable} to ${droptableAliases[si.DropTable]}`);
1400 si.DropTable = droptableAliases[si.DropTable];
1416 1401 }
1417 }
1418 if (si.DROP_BLUEPRINT) {
1419 const blueprintDroptable = droptables.find(x => x.type == "blueprint");
1420 if (blueprintDroptable) {
1421 for (let i = 0; i != si.DROP_BLUEPRINT.length; ++i) {
1422 const reward = getRandomReward(blueprintDroptable.items)!;
1423 logger.debug(`stripped droptable (blueprints pool) rolled`, reward);
1424 await addItem(inventory, reward.type);
1425 MissionRewards.push({
1426 StoreItem: toStoreItem(reward.type),
1427 ItemCount: 1,
1428 FromEnemyCache: true // to show "identified"
1429 });
1402 const droptables = ExportEnemies.droptables[si.DropTable] ?? [];
1403 if (si.DROP_MOD) {
1404 const modDroptable = droptables.find(x => x.type == "mod");
1405 if (modDroptable) {
1406 for (let i = 0; i != si.DROP_MOD.length; ++i) {
1407 const reward = getRandomReward(modDroptable.items)!;
1408 logger.debug(`stripped droptable (mods pool) rolled`, reward);
1409 await addItem(inventory, reward.type);
1410 MissionRewards.push({
1411 StoreItem: toStoreItem(reward.type),
1412 ItemCount: 1,
1413 FromEnemyCache: true // to show "identified"
1414 });
1415 }
1416 } else {
1417 logger.error(`unknown droptable ${si.DropTable} for DROP_MOD`);
1430 1418 }
1431 } else {
1432 logger.error(`unknown droptable ${si.DropTable} for DROP_BLUEPRINT`);
1433 1419 }
1434 }
1435 // e.g. H-09 Apex Turret Sumdali
1436 if (si.DROP_MISC_ITEM) {
1437 const resourceDroptable = droptables.find(x => x.type == "resource");
1438 if (resourceDroptable) {
1439 for (let i = 0; i != si.DROP_MISC_ITEM.length; ++i) {
1440 const reward = getRandomReward(resourceDroptable.items)!;
1441 logger.debug(`stripped droptable (resources pool) rolled`, reward);
1442 if (Object.keys(await addItem(inventory, reward.type)).length == 0) {
1443 logger.debug(`item already owned, skipping`);
1444 } else {
1420 if (si.DROP_BLUEPRINT) {
1421 const blueprintDroptable = droptables.find(x => x.type == "blueprint");
1422 if (blueprintDroptable) {
1423 for (let i = 0; i != si.DROP_BLUEPRINT.length; ++i) {
1424 const reward = getRandomReward(blueprintDroptable.items)!;
1425 logger.debug(`stripped droptable (blueprints pool) rolled`, reward);
1426 await addItem(inventory, reward.type);
1445 1427 MissionRewards.push({
1446 1428 StoreItem: toStoreItem(reward.type),
1447 1429 ItemCount: 1,
1448 1430 FromEnemyCache: true // to show "identified"
1449 1431 });
1450 1432 }
1433 } else {
1434 logger.error(`unknown droptable ${si.DropTable} for DROP_BLUEPRINT`);
1435 }
1436 }
1437 // e.g. H-09 Apex Turret Sumdali
1438 if (si.DROP_MISC_ITEM) {
1439 const resourceDroptable = droptables.find(x => x.type == "resource");
1440 if (resourceDroptable) {
1441 for (let i = 0; i != si.DROP_MISC_ITEM.length; ++i) {
1442 const reward = getRandomReward(resourceDroptable.items)!;
1443 logger.debug(`stripped droptable (resources pool) rolled`, reward);
1444 if (Object.keys(await addItem(inventory, reward.type)).length == 0) {
1445 logger.debug(`item already owned, skipping`);
1446 } else {
1447 MissionRewards.push({
1448 StoreItem: toStoreItem(reward.type),
1449 ItemCount: 1,
1450 FromEnemyCache: true // to show "identified"
1451 });
1452 }
1453 }
1454 } else {
1455 logger.error(`unknown droptable ${si.DropTable} for DROP_MISC_ITEM`);
1451 1456 }
1452 } else {
1453 logger.error(`unknown droptable ${si.DropTable} for DROP_MISC_ITEM`);
1454 1457 }
1455 }
1456 1458
1457 if (si.DropTable == "/Lotus/Types/DropTables/ContainerDropTables/VoidVaultMissionRewardsDropTable") {
1458 // Consume netracells search pulse; only when the container reward was picked up. Discussed in https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2673
1459 updateEntratiVault(inventory);
1460 inventory.EntratiVaultCountLastPeriod! += 1;
1459 if (si.DropTable == "/Lotus/Types/DropTables/ContainerDropTables/VoidVaultMissionRewardsDropTable") {
1460 // Consume netracells search pulse; only when the container reward was picked up. Discussed in https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2673
1461 updateEntratiVault(inventory);
1462 inventory.EntratiVaultCountLastPeriod! += 1;
1463 }
1461 1464 }
1465 } else {
1466 logger.debug(`ignoring StrippedItems in intermediate inventory update, deferring until extraction`);
1462 1467 }
1463 1468 }
1464 1469