返回提交历史
Modified
src/controllers/api/artifactsController.ts
+2
-8
Modified
src/models/inventoryModels/inventoryModel.ts
+11
-1
Modified
src/services/inventoryService.ts
+0
-7
Modified
src/types/inventoryTypes/inventoryTypes.ts
+5
-2
XFEstudio/SpaceNinjaServer
chore: get rid of instances of markModified (#908)
Closes #904 Reviewed-on: http://209.141.38.3/OpenWF/SpaceNinjaServer/pulls/908 Co-authored-by: Sainan <sainan@calamity.inc> Co-committed-by: Sainan <sainan@calamity.inc>
8175deb0
代码差异
4 个文件
+18
-18
@@ -12,7 +12,7 @@ export const artifactsController: RequestHandler = async (req, res) => {
12
12
const { Upgrade, LevelDiff, Cost, FusionPointCost } = artifactsData;
13
13
14
14
const inventory = await getInventory(accountId);
15
const { Upgrades, RawUpgrades } = inventory;
15
const { Upgrades } = inventory;
16
16
const { ItemType, UpgradeFingerprint, ItemId } = Upgrade;
17
17
18
18
const safeUpgradeFingerprint = UpgradeFingerprint || '{"lvl":0}';
@@ -32,13 +32,7 @@ export const artifactsController: RequestHandler = async (req, res) => {
32
32
ItemType
33
33
}) - 1;
34
34
35
const rawItemIndex = RawUpgrades.findIndex(rawUpgrade => rawUpgrade.ItemType === ItemType);
36
RawUpgrades[rawItemIndex].ItemCount--;
37
if (RawUpgrades[rawItemIndex].ItemCount > 0) {
38
inventory.markModified(`RawUpgrades.${rawItemIndex}.UpgradeFingerprint`);
39
} else {
40
RawUpgrades.splice(rawItemIndex, 1);
41
}
35
addMods(inventory, [{ ItemType, ItemCount: -1 }]);
42
36
}
43
37
44
38
if (!config.infiniteCredits) {
@@ -25,6 +25,7 @@ import {
25
25
ISettings,
26
26
IInfestedFoundryDatabase,
27
27
IHelminthResource,
28
IMissionDatabase,
28
29
IConsumedSuit,
29
30
IQuestStage,
30
31
IQuestKeyDatabase,
@@ -482,6 +483,15 @@ const helminthResourceSchema = new Schema<IHelminthResource>(
482
483
{ _id: false }
483
484
);
484
485
486
const missionSchema = new Schema<IMissionDatabase>(
487
{
488
Tag: String,
489
Completes: { type: Number, default: 0 },
490
Tier: { type: Number, required: false }
491
},
492
{ _id: false }
493
);
494
485
495
const questProgressSchema = new Schema<IQuestStage>(
486
496
{
487
497
c: Number,
@@ -1010,7 +1020,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1010
1020
CrewShipSalvagedWeapons: [Schema.Types.Mixed],
1011
1021
1012
1022
//Complete Mission\Quests
1013
Missions: [Schema.Types.Mixed],
1023
Missions: [missionSchema],
1014
1024
QuestKeys: [questKeysSchema],
1015
1025
ActiveQuest: { type: String, default: "/Lotus/Types/Keys/VorsPrize/VorsPrizeQuestKeyChain" }, //TODO: check after mission starting gear
1016
1026
//item like DojoKey or Boss missions key
@@ -906,7 +906,6 @@ export const addShipDecorations = (
906
906
907
907
if (itemIndex !== -1) {
908
908
ShipDecorations[itemIndex].ItemCount += ItemCount;
909
inventory.markModified(`ShipDecorations.${itemIndex}.ItemCount`);
910
909
} else {
911
910
ShipDecorations.push({ ItemCount, ItemType });
912
911
}
@@ -921,7 +920,6 @@ export const addConsumables = (inventory: TInventoryDatabaseDocument, itemsArray
921
920
922
921
if (itemIndex !== -1) {
923
922
Consumables[itemIndex].ItemCount += ItemCount;
924
inventory.markModified(`Consumables.${itemIndex}.ItemCount`);
925
923
} else {
926
924
Consumables.push({ ItemCount, ItemType });
927
925
}
@@ -967,7 +965,6 @@ export const addRecipes = (inventory: TInventoryDatabaseDocument, itemsArray: IT
967
965
968
966
if (itemIndex !== -1) {
969
967
Recipes[itemIndex].ItemCount += ItemCount;
970
inventory.markModified(`Recipes.${itemIndex}.ItemCount`);
971
968
} else {
972
969
Recipes.push({ ItemCount, ItemType });
973
970
}
@@ -1006,7 +1003,6 @@ export const addFusionTreasures = (
1006
1003
1007
1004
if (itemIndex !== -1) {
1008
1005
FusionTreasures[itemIndex].ItemCount += ItemCount;
1009
inventory.markModified(`FusionTreasures.${itemIndex}.ItemCount`);
1010
1006
} else {
1011
1007
FusionTreasures.push({ ItemCount, ItemType, Sockets });
1012
1008
}
@@ -1077,7 +1073,6 @@ export const addChallenges = (
1077
1073
1078
1074
if (itemIndex !== -1) {
1079
1075
category[itemIndex].Progress += Progress;
1080
inventory.markModified(`ChallengeProgress.${itemIndex}.ItemCount`);
1081
1076
} else {
1082
1077
category.push({ Name, Progress });
1083
1078
}
@@ -1090,7 +1085,6 @@ export const addMissionComplete = (inventory: TInventoryDatabaseDocument, { Tag,
1090
1085
1091
1086
if (itemIndex !== -1) {
1092
1087
Missions[itemIndex].Completes += Completes;
1093
inventory.markModified(`Missions.${itemIndex}.Completes`);
1094
1088
} else {
1095
1089
Missions.push({ Tag, Completes });
1096
1090
}
@@ -1106,7 +1100,6 @@ export const addBooster = (ItemType: string, time: number, inventory: TInventory
1106
1100
if (itemIndex !== -1) {
1107
1101
const existingBooster = Boosters[itemIndex];
1108
1102
existingBooster.ExpiryDate = Math.max(existingBooster.ExpiryDate, currentTime) + time;
1109
inventory.markModified(`Boosters.${itemIndex}.ExpiryDate`);
1110
1103
} else {
1111
1104
Boosters.push({ ItemType, ExpiryDate: currentTime + time });
1112
1105
}
@@ -753,10 +753,13 @@ export interface ILotusCustomization extends IItemConfig {
753
753
Persona: string;
754
754
}
755
755
756
export interface IMission {
756
export interface IMissionDatabase {
757
Tag: string;
757
758
Completes: number;
758
759
Tier?: number;
759
Tag: string;
760
}
761
762
export interface IMission extends IMissionDatabase {
760
763
RewardsCooldownTime?: IMongoDate;
761
764
}
762
765