feat: updateAlignment (#1039)
Closes #1038 may need some more information about how this endpoint works. had to make a few assumptions. Reviewed-on: OpenWF/SpaceNinjaServer#1039 Co-authored-by: Sainan <sainan@calamity.inc> Co-committed-by: Sainan <sainan@calamity.inc>
This commit is contained in:
parent
8c662fa1ec
commit
c971a484ef
25
src/controllers/api/updateAlignmentController.ts
Normal file
25
src/controllers/api/updateAlignmentController.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||
import { getInventory } from "@/src/services/inventoryService";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { IAlignment } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
export const updateAlignmentController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const inventory = await getInventory(accountId);
|
||||
const body = getJSONfromString<IUpdateAlignmentRequest>(String(req.body));
|
||||
inventory.Alignment = {
|
||||
Alignment: body.Alignment,
|
||||
Wisdom: body.Wisdom
|
||||
};
|
||||
await inventory.save();
|
||||
res.json(inventory.Alignment);
|
||||
};
|
||||
|
||||
interface IUpdateAlignmentRequest {
|
||||
Wisdom: number;
|
||||
Alignment: number;
|
||||
PreviousAlignment: IAlignment;
|
||||
AlignmentAction: string; // e.g. "/Lotus/Language/Game/MawCinematicDualChoice"
|
||||
KeyChainName: string;
|
||||
}
|
@ -70,7 +70,8 @@ import {
|
||||
IPendingCouponClient,
|
||||
ILibraryDailyTaskInfo,
|
||||
IDroneDatabase,
|
||||
IDroneClient
|
||||
IDroneClient,
|
||||
IAlignment
|
||||
} from "../../types/inventoryTypes/inventoryTypes";
|
||||
import { IOid } from "../../types/commonTypes";
|
||||
import {
|
||||
@ -970,6 +971,14 @@ const libraryDailyTaskInfoSchema = new Schema<ILibraryDailyTaskInfo>(
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const alignmentSchema = new Schema<IAlignment>(
|
||||
{
|
||||
Alignment: Number,
|
||||
Wisdom: Number
|
||||
},
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
{
|
||||
accountOwnerId: Schema.Types.ObjectId,
|
||||
@ -1171,8 +1180,8 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
|
||||
//https://warframe.fandom.com/wiki/Alignment
|
||||
//like "Alignment": { "Wisdom": 9, "Alignment": 1 },
|
||||
Alignment: Schema.Types.Mixed,
|
||||
AlignmentReplay: Schema.Types.Mixed,
|
||||
Alignment: alignmentSchema,
|
||||
AlignmentReplay: alignmentSchema,
|
||||
|
||||
//https://warframe.fandom.com/wiki/Sortie
|
||||
CompletedSorties: [String],
|
||||
|
@ -87,6 +87,7 @@ import { syndicateStandingBonusController } from "@/src/controllers/api/syndicat
|
||||
import { tauntHistoryController } from "@/src/controllers/api/tauntHistoryController";
|
||||
import { trainingResultController } from "@/src/controllers/api/trainingResultController";
|
||||
import { unlockShipFeatureController } from "@/src/controllers/api/unlockShipFeatureController";
|
||||
import { updateAlignmentController } from "@/src/controllers/api/updateAlignmentController";
|
||||
import { updateChallengeProgressController } from "@/src/controllers/api/updateChallengeProgressController";
|
||||
import { updateQuestController } from "@/src/controllers/api/updateQuestController";
|
||||
import { updateSessionGetController, updateSessionPostController } from "@/src/controllers/api/updateSessionController";
|
||||
@ -188,6 +189,7 @@ apiRouter.post("/syndicateStandingBonus.php", syndicateStandingBonusController);
|
||||
apiRouter.post("/tauntHistory.php", tauntHistoryController);
|
||||
apiRouter.post("/trainingResult.php", trainingResultController);
|
||||
apiRouter.post("/unlockShipFeature.php", unlockShipFeatureController);
|
||||
apiRouter.post("/updateAlignment.php", updateAlignmentController);
|
||||
apiRouter.post("/updateChallengeProgress.php", updateChallengeProgressController);
|
||||
apiRouter.post("/updateNodeIntros.php", genericUpdateController);
|
||||
apiRouter.post("/updateQuest.php", updateQuestController);
|
||||
|
@ -253,7 +253,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
|
||||
CompletedSyndicates: string[];
|
||||
FocusXP?: IFocusXP;
|
||||
Wishlist: string[];
|
||||
Alignment: IAlignment;
|
||||
Alignment?: IAlignment;
|
||||
CompletedSorties: string[];
|
||||
LastSortieReward: ILastSortieReward[];
|
||||
Drones: IDroneClient[];
|
||||
@ -267,7 +267,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
|
||||
HasContributedToDojo?: boolean;
|
||||
HWIDProtectEnabled?: boolean;
|
||||
KubrowPetPrints: IKubrowPetPrint[];
|
||||
AlignmentReplay: IAlignment;
|
||||
AlignmentReplay?: IAlignment;
|
||||
PersonalGoalProgress: IPersonalGoalProgress[];
|
||||
ThemeStyle: string;
|
||||
ThemeBackground: string;
|
||||
|
Loading…
x
Reference in New Issue
Block a user