move archimedea handling to addMissionRewards
Some checks failed
Build / build (pull_request) Failing after 1m10s
Some checks failed
Build / build (pull_request) Failing after 1m10s
This commit is contained in:
parent
7e23810cad
commit
64de3e2bd5
@ -72,60 +72,29 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { MissionRewards, inventoryChanges, credits, AffiliationMods, SyndicateXPItemReward } =
|
const {
|
||||||
await addMissionRewards(inventory, missionReport, firstCompletion);
|
MissionRewards,
|
||||||
|
inventoryChanges,
|
||||||
|
credits,
|
||||||
|
AffiliationMods,
|
||||||
|
SyndicateXPItemReward,
|
||||||
|
ConquestCompletedMissionsCount
|
||||||
|
} = await addMissionRewards(inventory, missionReport, firstCompletion);
|
||||||
|
|
||||||
//TODO: figure out when to send inventory. it is needed for many cases.
|
await inventory.save();
|
||||||
const response: IMissionInventoryUpdateResponse = {
|
const inventoryResponse = await getInventoryResponse(inventory, true);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
InventoryJson: JSON.stringify(inventoryResponse),
|
||||||
InventoryChanges: inventoryChanges,
|
InventoryChanges: inventoryChanges,
|
||||||
MissionRewards,
|
MissionRewards,
|
||||||
...credits,
|
...credits,
|
||||||
...inventoryUpdates,
|
...inventoryUpdates,
|
||||||
//FusionPoints: inventoryChanges?.FusionPoints, // This in combination with InventoryJson or InventoryChanges seems to just double the number of endo shown, so unsure when this is needed.
|
//FusionPoints: inventoryChanges?.FusionPoints, // This in combination with InventoryJson or InventoryChanges seems to just double the number of endo shown, so unsure when this is needed.
|
||||||
SyndicateXPItemReward,
|
SyndicateXPItemReward,
|
||||||
AffiliationMods
|
AffiliationMods,
|
||||||
};
|
ConquestCompletedMissionsCount
|
||||||
|
});
|
||||||
if (missionReport.ConquestMissionsCompleted !== undefined) {
|
|
||||||
response.ConquestCompletedMissionsCount =
|
|
||||||
missionReport.ConquestMissionsCompleted == 2 ? 0 : missionReport.ConquestMissionsCompleted + 1;
|
|
||||||
|
|
||||||
let score = 1;
|
|
||||||
if (missionReport.RewardInfo?.ConquestHardModeActive === 1) score += 3;
|
|
||||||
|
|
||||||
if (missionReport.RewardInfo?.ConquestPersonalModifiersActive !== undefined)
|
|
||||||
score += missionReport.RewardInfo?.ConquestPersonalModifiersActive;
|
|
||||||
if (missionReport.RewardInfo?.ConquestEquipmentSuggestionsFulfilled !== undefined)
|
|
||||||
score += missionReport.RewardInfo?.ConquestEquipmentSuggestionsFulfilled;
|
|
||||||
|
|
||||||
score *= missionReport.ConquestMissionsCompleted + 1;
|
|
||||||
|
|
||||||
if (missionReport.ConquestMissionsCompleted == 2 && missionReport.RewardInfo?.ConquestHardModeActive === 1)
|
|
||||||
score += 1;
|
|
||||||
|
|
||||||
const conquestType = missionReport.RewardInfo?.ConquestType;
|
|
||||||
const conquestNode =
|
|
||||||
conquestType == "HexConquest" ? "EchoesHexConquestHardModeUnlocked" : "EntratiLabConquestHardModeUnlocked";
|
|
||||||
if (score >= 25 && inventory.NodeIntrosCompleted.find(x => x == conquestNode) === undefined)
|
|
||||||
inventory.NodeIntrosCompleted.push(conquestNode);
|
|
||||||
|
|
||||||
if (conquestType == "HexConquest") {
|
|
||||||
inventory.EchoesHexConquestCacheScoreMission ??= 0;
|
|
||||||
|
|
||||||
if (score > inventory.EchoesHexConquestCacheScoreMission)
|
|
||||||
inventory.EchoesHexConquestCacheScoreMission = score;
|
|
||||||
} else {
|
|
||||||
inventory.EntratiLabConquestCacheScoreMission ??= 0;
|
|
||||||
|
|
||||||
if (score > inventory.EntratiLabConquestCacheScoreMission)
|
|
||||||
inventory.EntratiLabConquestCacheScoreMission = score;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await inventory.save();
|
|
||||||
const inventoryResponse = await getInventoryResponse(inventory, true);
|
|
||||||
response.InventoryJson = JSON.stringify(inventoryResponse);
|
|
||||||
res.json(response);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -586,6 +586,7 @@ interface AddMissionRewardsReturnType {
|
|||||||
credits?: IMissionCredits;
|
credits?: IMissionCredits;
|
||||||
AffiliationMods?: IAffiliationMods[];
|
AffiliationMods?: IAffiliationMods[];
|
||||||
SyndicateXPItemReward?: number;
|
SyndicateXPItemReward?: number;
|
||||||
|
ConquestCompletedMissionsCount?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: return type of partial missioninventoryupdate response
|
//TODO: return type of partial missioninventoryupdate response
|
||||||
@ -620,6 +621,7 @@ export const addMissionRewards = async (
|
|||||||
const inventoryChanges: IInventoryChanges = {};
|
const inventoryChanges: IInventoryChanges = {};
|
||||||
const AffiliationMods: IAffiliationMods[] = [];
|
const AffiliationMods: IAffiliationMods[] = [];
|
||||||
let SyndicateXPItemReward;
|
let SyndicateXPItemReward;
|
||||||
|
let ConquestCompletedMissionsCount;
|
||||||
|
|
||||||
let missionCompletionCredits = 0;
|
let missionCompletionCredits = 0;
|
||||||
//inventory change is what the client has not rewarded itself, also the client needs to know the credit changes for display
|
//inventory change is what the client has not rewarded itself, also the client needs to know the credit changes for display
|
||||||
@ -882,7 +884,48 @@ export const addMissionRewards = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { inventoryChanges, MissionRewards, credits, AffiliationMods, SyndicateXPItemReward };
|
if (rewardInfo.ConquestCompleted !== undefined) {
|
||||||
|
let score = 1;
|
||||||
|
if (rewardInfo.ConquestHardModeActive === 1) score += 3;
|
||||||
|
|
||||||
|
if (rewardInfo.ConquestPersonalModifiersActive !== undefined)
|
||||||
|
score += rewardInfo.ConquestPersonalModifiersActive;
|
||||||
|
if (rewardInfo.ConquestEquipmentSuggestionsFulfilled !== undefined)
|
||||||
|
score += rewardInfo.ConquestEquipmentSuggestionsFulfilled;
|
||||||
|
|
||||||
|
score *= rewardInfo.ConquestCompleted + 1;
|
||||||
|
|
||||||
|
if (rewardInfo.ConquestCompleted == 2 && rewardInfo.ConquestHardModeActive === 1) score += 1;
|
||||||
|
|
||||||
|
const conquestType = rewardInfo.ConquestType;
|
||||||
|
const conquestNode =
|
||||||
|
conquestType == "HexConquest" ? "EchoesHexConquestHardModeUnlocked" : "EntratiLabConquestHardModeUnlocked";
|
||||||
|
if (score >= 25 && inventory.NodeIntrosCompleted.find(x => x == conquestNode) === undefined)
|
||||||
|
inventory.NodeIntrosCompleted.push(conquestNode);
|
||||||
|
|
||||||
|
if (conquestType == "HexConquest") {
|
||||||
|
inventory.EchoesHexConquestCacheScoreMission ??= 0;
|
||||||
|
|
||||||
|
if (score > inventory.EchoesHexConquestCacheScoreMission)
|
||||||
|
inventory.EchoesHexConquestCacheScoreMission = score;
|
||||||
|
} else {
|
||||||
|
inventory.EntratiLabConquestCacheScoreMission ??= 0;
|
||||||
|
|
||||||
|
if (score > inventory.EntratiLabConquestCacheScoreMission)
|
||||||
|
inventory.EntratiLabConquestCacheScoreMission = score;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConquestCompletedMissionsCount = rewardInfo.ConquestCompleted == 2 ? 0 : rewardInfo.ConquestCompleted + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
inventoryChanges,
|
||||||
|
MissionRewards,
|
||||||
|
credits,
|
||||||
|
AffiliationMods,
|
||||||
|
SyndicateXPItemReward,
|
||||||
|
ConquestCompletedMissionsCount
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
//creditBonus is not entirely accurate.
|
//creditBonus is not entirely accurate.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user