返回提交历史
Added
src/controllers/api/updateAlignmentController.ts
+25
-0
Modified
src/models/inventoryModels/inventoryModel.ts
+12
-3
Modified
src/routes/api.ts
+2
-0
Modified
src/types/inventoryTypes/inventoryTypes.ts
+2
-2
XFEstudio/XFESpaceNinjaServer
feat: updateAlignment (#1039)
Closes #1038 may need some more information about how this endpoint works. had to make a few assumptions. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1039 Co-authored-by: Sainan <sainan@calamity.inc> Co-committed-by: Sainan <sainan@calamity.inc>
c971a484
代码差异
4 个文件
+41
-5
@@ -0,0 +1,25 @@
1
import { getJSONfromString } from "@/src/helpers/stringHelpers";
2
import { getInventory } from "@/src/services/inventoryService";
3
import { getAccountIdForRequest } from "@/src/services/loginService";
4
import { IAlignment } from "@/src/types/inventoryTypes/inventoryTypes";
5
import { RequestHandler } from "express";
6
7
export const updateAlignmentController: RequestHandler = async (req, res) => {
8
const accountId = await getAccountIdForRequest(req);
9
const inventory = await getInventory(accountId);
10
const body = getJSONfromString<IUpdateAlignmentRequest>(String(req.body));
11
inventory.Alignment = {
12
Alignment: body.Alignment,
13
Wisdom: body.Wisdom
14
};
15
await inventory.save();
16
res.json(inventory.Alignment);
17
};
18
19
interface IUpdateAlignmentRequest {
20
Wisdom: number;
21
Alignment: number;
22
PreviousAlignment: IAlignment;
23
AlignmentAction: string; // e.g. "/Lotus/Language/Game/MawCinematicDualChoice"
24
KeyChainName: string;
25
}
@@ -70,7 +70,8 @@ import {
70
70
IPendingCouponClient,
71
71
ILibraryDailyTaskInfo,
72
72
IDroneDatabase,
73
IDroneClient
73
IDroneClient,
74
IAlignment
74
75
} from "../../types/inventoryTypes/inventoryTypes";
75
76
import { IOid } from "../../types/commonTypes";
76
77
import {
@@ -970,6 +971,14 @@ const libraryDailyTaskInfoSchema = new Schema<ILibraryDailyTaskInfo>(
970
971
{ _id: false }
971
972
);
972
973
974
const alignmentSchema = new Schema<IAlignment>(
975
{
976
Alignment: Number,
977
Wisdom: Number
978
},
979
{ _id: false }
980
);
981
973
982
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
974
983
{
975
984
accountOwnerId: Schema.Types.ObjectId,
@@ -1171,8 +1180,8 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
1171
1180
1172
1181
//https://warframe.fandom.com/wiki/Alignment
1173
1182
//like "Alignment": { "Wisdom": 9, "Alignment": 1 },
1174
Alignment: Schema.Types.Mixed,
1175
AlignmentReplay: Schema.Types.Mixed,
1183
Alignment: alignmentSchema,
1184
AlignmentReplay: alignmentSchema,
1176
1185
1177
1186
//https://warframe.fandom.com/wiki/Sortie
1178
1187
CompletedSorties: [String],
@@ -87,6 +87,7 @@ import { syndicateStandingBonusController } from "@/src/controllers/api/syndicat
87
87
import { tauntHistoryController } from "@/src/controllers/api/tauntHistoryController";
88
88
import { trainingResultController } from "@/src/controllers/api/trainingResultController";
89
89
import { unlockShipFeatureController } from "@/src/controllers/api/unlockShipFeatureController";
90
import { updateAlignmentController } from "@/src/controllers/api/updateAlignmentController";
90
91
import { updateChallengeProgressController } from "@/src/controllers/api/updateChallengeProgressController";
91
92
import { updateQuestController } from "@/src/controllers/api/updateQuestController";
92
93
import { updateSessionGetController, updateSessionPostController } from "@/src/controllers/api/updateSessionController";
@@ -188,6 +189,7 @@ apiRouter.post("/syndicateStandingBonus.php", syndicateStandingBonusController);
188
189
apiRouter.post("/tauntHistory.php", tauntHistoryController);
189
190
apiRouter.post("/trainingResult.php", trainingResultController);
190
191
apiRouter.post("/unlockShipFeature.php", unlockShipFeatureController);
192
apiRouter.post("/updateAlignment.php", updateAlignmentController);
191
193
apiRouter.post("/updateChallengeProgress.php", updateChallengeProgressController);
192
194
apiRouter.post("/updateNodeIntros.php", genericUpdateController);
193
195
apiRouter.post("/updateQuest.php", updateQuestController);
@@ -253,7 +253,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
253
253
CompletedSyndicates: string[];
254
254
FocusXP?: IFocusXP;
255
255
Wishlist: string[];
256
Alignment: IAlignment;
256
Alignment?: IAlignment;
257
257
CompletedSorties: string[];
258
258
LastSortieReward: ILastSortieReward[];
259
259
Drones: IDroneClient[];
@@ -267,7 +267,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
267
267
HasContributedToDojo?: boolean;
268
268
HWIDProtectEnabled?: boolean;
269
269
KubrowPetPrints: IKubrowPetPrint[];
270
AlignmentReplay: IAlignment;
270
AlignmentReplay?: IAlignment;
271
271
PersonalGoalProgress: IPersonalGoalProgress[];
272
272
ThemeStyle: string;
273
273
ThemeBackground: string;