feat: basic implementation of endlessXp.php we can play The Circuit (#596)
This commit is contained in:
parent
9fd6ed3b21
commit
b84258a893
60
src/controllers/api/endlessXpController.ts
Normal file
60
src/controllers/api/endlessXpController.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { getInventory } from "@/src/services/inventoryService";
|
||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||
import { TEndlessXpCategory } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
|
||||
export const endlessXpController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const inventory = await getInventory(accountId);
|
||||
const payload = getJSONfromString(String(req.body)) as IEndlessXpRequest;
|
||||
|
||||
inventory.EndlessXP ??= [];
|
||||
const entry = inventory.EndlessXP.find(x => x.Category == payload.Category);
|
||||
if (entry) {
|
||||
entry.Choices = payload.Choices;
|
||||
} else {
|
||||
inventory.EndlessXP.push({
|
||||
Category: payload.Category,
|
||||
Choices: payload.Choices
|
||||
});
|
||||
}
|
||||
await inventory.save();
|
||||
|
||||
res.json({
|
||||
NewProgress: {
|
||||
Category: payload.Category,
|
||||
Earn: 0,
|
||||
Claim: 0,
|
||||
BonusAvailable: {
|
||||
$date: {
|
||||
$numberLong: "9999999999999"
|
||||
}
|
||||
},
|
||||
Expiry: {
|
||||
$date: {
|
||||
$numberLong: "9999999999999"
|
||||
}
|
||||
},
|
||||
Choices: payload.Choices,
|
||||
PendingRewards: [
|
||||
{
|
||||
RequiredTotalXp: 190,
|
||||
Rewards: [
|
||||
{
|
||||
StoreItem: "/Lotus/StoreItems/Upgrades/Mods/Aura/PlayerHealthAuraMod",
|
||||
ItemCount: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
// ...
|
||||
]
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
interface IEndlessXpRequest {
|
||||
Mode: string; // "r"
|
||||
Category: TEndlessXpCategory;
|
||||
Choices: string[];
|
||||
}
|
@ -37,7 +37,8 @@ import {
|
||||
IPeriodicMissionCompletionDatabase,
|
||||
IPeriodicMissionCompletionResponse,
|
||||
ILoreFragmentScan,
|
||||
IEvolutionProgress
|
||||
IEvolutionProgress,
|
||||
IEndlessXpProgress
|
||||
} from "../../types/inventoryTypes/inventoryTypes";
|
||||
import { IOid } from "../../types/commonTypes";
|
||||
import {
|
||||
@ -581,6 +582,14 @@ const evolutionProgressSchema = new Schema<IEvolutionProgress>(
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const endlessXpProgressSchema = new Schema<IEndlessXpProgress>(
|
||||
{
|
||||
Category: String,
|
||||
Choices: [String]
|
||||
},
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
{
|
||||
accountOwnerId: Schema.Types.ObjectId,
|
||||
@ -938,7 +947,9 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
//Zanuka
|
||||
Harvestable: Boolean,
|
||||
//Grustag three
|
||||
DeathSquadable: Boolean
|
||||
DeathSquadable: Boolean,
|
||||
|
||||
EndlessXP: { type: [endlessXpProgressSchema], default: undefined }
|
||||
},
|
||||
{ timestamps: { createdAt: "Created" } }
|
||||
);
|
||||
|
@ -8,6 +8,7 @@ import { createGuildController } from "@/src/controllers/api/createGuildControll
|
||||
import { deleteSessionController } from "@/src/controllers/api/deleteSessionController";
|
||||
import { dojoController } from "@/src/controllers/api/dojoController";
|
||||
import { dronesController } from "@/src/controllers/api/dronesController";
|
||||
import { endlessXpController } from "@/src/controllers/api/endlessXpController";
|
||||
import { evolveWeaponController } from "@/src/controllers/api/evolveWeaponController";
|
||||
import { findSessionsController } from "@/src/controllers/api/findSessionsController";
|
||||
import { focusController } from "@/src/controllers/api/focusController";
|
||||
@ -108,6 +109,7 @@ apiRouter.post("/arcaneCommon.php", arcaneCommonController);
|
||||
apiRouter.post("/artifacts.php", artifactsController);
|
||||
apiRouter.post("/claimCompletedRecipe.php", claimCompletedRecipeController);
|
||||
apiRouter.post("/createGuild.php", createGuildController);
|
||||
apiRouter.post("/endlessXp.php", endlessXpController);
|
||||
apiRouter.post("/evolveWeapon.php", evolveWeaponController);
|
||||
apiRouter.post("/findSessions.php", findSessionsController);
|
||||
apiRouter.post("/focus.php", focusController);
|
||||
|
@ -301,6 +301,7 @@ export interface IInventoryResponse {
|
||||
PendingCoupon: IPendingCoupon;
|
||||
Harvestable: boolean;
|
||||
DeathSquadable: boolean;
|
||||
EndlessXP?: IEndlessXpProgress[];
|
||||
}
|
||||
|
||||
export interface IAffiliation {
|
||||
@ -932,3 +933,10 @@ export interface IEvolutionProgress {
|
||||
Rank: number;
|
||||
ItemType: string;
|
||||
}
|
||||
|
||||
export type TEndlessXpCategory = "EXC_NORMAL" | "EXC_HARD";
|
||||
|
||||
export interface IEndlessXpProgress {
|
||||
Category: TEndlessXpCategory;
|
||||
Choices: string[];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user