feat: obtaining crewship related items on mission update #897

Merged
OrdisPrime merged 3 commits from AMelonInsideLemon/SpaceNinjaServer:crewship-rewards into main 2025-02-05 12:23:35 -08:00
4 changed files with 52 additions and 8 deletions

View File

@ -997,7 +997,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
ShipDecorations: [typeCountSchema], ShipDecorations: [typeCountSchema],
//Railjack/Components(https://warframe.fandom.com/wiki/Railjack/Components) //Railjack/Components(https://warframe.fandom.com/wiki/Railjack/Components)
CrewShipRawSalvage: [Schema.Types.Mixed], CrewShipRawSalvage: [typeCountSchema],
//Default RailJack //Default RailJack
CrewShipAmmo: [typeCountSchema], CrewShipAmmo: [typeCountSchema],

View File

@ -915,6 +915,37 @@ export const addConsumables = (inventory: TInventoryDatabaseDocument, itemsArray
}); });
}; };
export const addCrewShipRawSalvage = (
inventory: TInventoryDatabaseDocument,
itemsArray: ITypeCount[] | undefined
): void => {
const { CrewShipRawSalvage } = inventory;
itemsArray?.forEach(({ ItemCount, ItemType }) => {
const itemIndex = CrewShipRawSalvage.findIndex(i => i.ItemType === ItemType);
if (itemIndex !== -1) {
CrewShipRawSalvage[itemIndex].ItemCount += ItemCount;
} else {
Sainan marked this conversation as resolved
Review

markModified shouldn't be needed with a proper schema.

`markModified` shouldn't be needed with a proper schema.
CrewShipRawSalvage.push({ ItemCount, ItemType });
}
});
};
export const addCrewShipAmmo = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[] | undefined): void => {
const { CrewShipAmmo } = inventory;
itemsArray?.forEach(({ ItemCount, ItemType }) => {
const itemIndex = CrewShipAmmo.findIndex(i => i.ItemType === ItemType);
if (itemIndex !== -1) {
CrewShipAmmo[itemIndex].ItemCount += ItemCount;
} else {
CrewShipAmmo.push({ ItemCount, ItemType });
}
});
};
export const addRecipes = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[] | undefined): void => { export const addRecipes = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[] | undefined): void => {
const { Recipes } = inventory; const { Recipes } = inventory;

View File

@ -6,6 +6,8 @@ import { equipmentKeys, IInventoryDatabase, TEquipmentKey } from "@/src/types/in
import { import {
addChallenges, addChallenges,
addConsumables, addConsumables,
addCrewShipAmmo,
addCrewShipRawSalvage,
addFocusXpIncreases, addFocusXpIncreases,
addFusionTreasures, addFusionTreasures,
addGearExpByCategory, addGearExpByCategory,
@ -122,6 +124,7 @@ export const addMissionInventoryUpdates = (
addMods(inventory, value); addMods(inventory, value);
break; break;
case "MiscItems": case "MiscItems":
case "BonusMiscItems":
addMiscItems(inventory, value); addMiscItems(inventory, value);
break; break;
case "Consumables": case "Consumables":
@ -136,6 +139,12 @@ export const addMissionInventoryUpdates = (
case "FusionTreasures": case "FusionTreasures":
addFusionTreasures(inventory, value); addFusionTreasures(inventory, value);
break; break;
case "CrewShipRawSalvage":
addCrewShipRawSalvage(inventory, value);
break;
case "CrewShipAmmo":
addCrewShipAmmo(inventory, value);
break;
case "FusionBundles": { case "FusionBundles": {
let fusionPoints = 0; let fusionPoints = 0;
for (const fusionBundle of value) { for (const fusionBundle of value) {
@ -195,7 +204,6 @@ export const addMissionRewards = async (
) => { ) => {
if (!rewardInfo) { if (!rewardInfo) {
logger.warn("no reward info provided"); logger.warn("no reward info provided");
return;
} }
//TODO: check double reward merging //TODO: check double reward merging
@ -287,9 +295,9 @@ function getLevelCreditRewards(nodeName: string): number {
//TODO: get dark sektor fixed credit rewards and railjack bonus //TODO: get dark sektor fixed credit rewards and railjack bonus
} }
function getRandomMissionDrops(RewardInfo: IRewardInfo): IRngResult[] { function getRandomMissionDrops(RewardInfo: IRewardInfo | undefined): IRngResult[] {
const drops: IRngResult[] = []; const drops: IRngResult[] = [];

why was the return upon no rewardInfo removed and this check here added?
could you explain the logic behind it? In my testing I did not see game scenarios where random mission rewards would need to be applied when rewardInfo is missing. Could you name me the scenario?

why was the return upon no rewardInfo removed and this check here added? could you explain the logic behind it? In my testing I did not see game scenarios where random mission rewards would need to be applied when rewardInfo is missing. Could you name me the scenario?

Allowing undefined here and proceeding with the function upon undefined rewardInfo removes a lot of the control and leaves a possibility for hard to trace bugs I would think

Allowing undefined here and proceeding with the function upon undefined rewardInfo removes a lot of the control and leaves a possibility for hard to trace bugs I would think
if (RewardInfo.node in ExportRegions) { if (RewardInfo && RewardInfo.node in ExportRegions) {
const region = ExportRegions[RewardInfo.node]; const region = ExportRegions[RewardInfo.node];
const rewardManifests = region.rewardManifests ?? []; const rewardManifests = region.rewardManifests ?? [];

View File

@ -35,18 +35,23 @@ export interface IUpdateChallengeProgressRequest {
} }
export type IMissionInventoryUpdateRequest = { export type IMissionInventoryUpdateRequest = {
MiscItems?: ITypeCount[];
Recipes?: ITypeCount[];
FusionBundles?: ITypeCount[];
Consumables?: ITypeCount[];
FusionBundels?: ITypeCount[];
CrewShipRawSalvage?: ITypeCount[];
CrewShipAmmo?: ITypeCount[];
BonusMiscItems?: ITypeCount[];
AffiliationChanges?: IAffiliationChange[]; AffiliationChanges?: IAffiliationChange[];
crossPlaySetting?: string; crossPlaySetting?: string;
rewardsMultiplier?: number; rewardsMultiplier?: number;
GoalTag: string; GoalTag: string;
LevelKeyName: string; LevelKeyName: string;
ActiveBoosters?: IBooster[]; ActiveBoosters?: IBooster[];
FusionBundles?: ITypeCount[];
RawUpgrades?: IRawUpgrade[]; RawUpgrades?: IRawUpgrade[];
MiscItems?: ITypeCount[];
Consumables?: ITypeCount[];
FusionTreasures?: IFusionTreasure[]; FusionTreasures?: IFusionTreasure[];
Recipes?: ITypeCount[];
QuestKeys?: Omit<IQuestKeyDatabase, "CompletionDate">[]; QuestKeys?: Omit<IQuestKeyDatabase, "CompletionDate">[];
RegularCredits?: number; RegularCredits?: number;
MissionFailed: boolean; MissionFailed: boolean;