fix: handle fake jobs without syndicateMissionId #2982

Open
AMelonInsideLemon wants to merge 2 commits from AMelonInsideLemon/SpaceNinjaServer:fix-fake-jobs into main

View File

@ -1517,7 +1517,38 @@ export const addMissionRewards = async (
syndicateEntry = Goals.find(m => m._id.$oid === syndicateMissionId);
if (syndicateEntry) syndicateEntry.Tag = syndicateEntry.JobAffiliationTag!;
}
if (syndicateEntry && syndicateEntry.Jobs && !jobType.startsWith("/Lotus/Types/Gameplay/NokkoColony/Jobs")) {
const specialCase = [
{
endings: ["Heists/HeistProfitTakerBountyOne"],
stage: 2,
amount: 1000,
tag: "SolarisSyndicate"
},
{
endings: [
"Heists/HeistProfitTakerBountyTwo",
"Heists/HeistProfitTakerBountyThree",
"Heists/HeistProfitTakerBountyFour",
"Heists/HeistExploiterBountyOne"
],
amount: 1000,
tag: "SolarisSyndicate"
},
{ endings: ["Hunts/AllTeralystsHunt"], stage: 2, amount: 5000, tag: "CetusSyndicate" },
{
endings: ["Hunts/TeralystHunt"],
amount: 1000,
tag: "CetusSyndicate"
},
{ endings: ["Jobs/NewbieJob"], amount: 200, tag: "CetusSyndicate" }
];
const match = specialCase.find(rule => rule.endings.some(e => jobType.endsWith(e)));
if (match) {
AMelonInsideLemon marked this conversation as resolved Outdated

specialCase.find after specialCase.some seems wasteful as you're linearlly iterating over the array twice.

`specialCase.find` after `specialCase.some` seems wasteful as you're linearlly iterating over the array twice.
const specialCaseReward = match.stage === undefined || rewardInfo.JobStage === match.stage ? match : null;
if (specialCaseReward) {
addStanding(inventory, match.tag, Math.floor(match.amount / (rewardInfo.Q ? 0.8 : 1)), AffiliationMods);
}
} else if (syndicateEntry && syndicateEntry.Jobs) {
let currentJob = syndicateEntry.Jobs[rewardInfo.JobTier!];
if (
[
@ -1575,30 +1606,7 @@ export const addMissionRewards = async (
);
logger.warning(`currentJob`, { currentJob: currentJob });
}
} else {
const specialCase = [
{ endings: ["Heists/HeistProfitTakerBountyOne"], stage: 2, amount: 1000 },
{ endings: ["Hunts/AllTeralystsHunt"], stage: 2, amount: 5000 },
{
endings: [
"Hunts/TeralystHunt",
"Heists/HeistProfitTakerBountyTwo",
"Heists/HeistProfitTakerBountyThree",
"Heists/HeistProfitTakerBountyFour",
"Heists/HeistExploiterBountyOne"
],
amount: 1000
}
];
const specialCaseReward = specialCase.find(
rule =>
rule.endings.some(e => jobType.endsWith(e)) &&
(rule.stage === undefined || rewardInfo.JobStage === rule.stage)
);
if (specialCaseReward) {
addStanding(inventory, syndicateEntry.Tag, specialCaseReward.amount, AffiliationMods);
} else {
} else if (!jobType.startsWith("/Lotus/Types/Gameplay/NokkoColony/Jobs")) {
addStanding(
inventory,
syndicateEntry.Tag,
@ -1608,10 +1616,6 @@ export const addMissionRewards = async (
}
}
}
if (jobType == "/Lotus/Types/Gameplay/Eidolon/Jobs/NewbieJob") {
addStanding(inventory, "CetusSyndicate", Math.floor(200 / (rewardInfo.Q ? 0.8 : 1)), AffiliationMods);
}
}
if (rewardInfo.challengeMissionId) {
const [syndicateTag, tierStr, chemistryBuddyStr] = rewardInfo.challengeMissionId.split("_");
@ -1964,7 +1968,8 @@ function getRandomMissionDrops(
if (syndicateEntry) syndicateEntry.Tag = syndicateEntry.JobAffiliationTag!;
}
if (syndicateEntry && syndicateEntry.Jobs) {
let job = syndicateEntry.Jobs[RewardInfo.JobTier!];
let job;
if (RewardInfo.JobTier && RewardInfo.JobTier > 0) job = syndicateEntry.Jobs[RewardInfo.JobTier];
if (syndicateEntry.Tag === "EntratiSyndicate") {
if (
@ -2068,6 +2073,7 @@ function getRandomMissionDrops(
) {
job = syndicateEntry.Jobs.find(j => j.jobType === jobType)!;
}
if (job) {
rewardManifests = [job.rewards];
if (job.xpAmounts.length > 1) {
const curentStage = RewardInfo.JobStage! + 1;
@ -2103,6 +2109,7 @@ function getRandomMissionDrops(
}
}
}
}
if (jobType == "/Lotus/Types/Gameplay/Eidolon/Jobs/NewbieJob") {
rewardManifests = ["/Lotus/Types/Game/MissionDecks/EidolonJobMissionRewards/TierATableARewards"];
rotations = [3];