forked from OpenWF/SpaceNinjaServer
Compare commits
3 Commits
main
...
mission-Em
Author | SHA1 | Date | |
---|---|---|---|
514e306394 | |||
26ad8fceff | |||
1341b71177 |
@ -33,7 +33,6 @@
|
||||
"noDailyStandingLimits": true,
|
||||
"instantResourceExtractorDrones": false,
|
||||
"noDojoRoomBuildStage": true,
|
||||
"fastDojoRoomDestruction": true,
|
||||
"noDojoResearchCosts": true,
|
||||
"noDojoResearchTime": true,
|
||||
"spoofMasteryRank": -1
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getDojoClient, getGuildForRequestEx, removeDojoDeco, removeDojoRoom } from "@/src/services/guildService";
|
||||
import { getDojoClient, getGuildForRequestEx } from "@/src/services/guildService";
|
||||
import { getInventory } from "@/src/services/inventoryService";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { RequestHandler } from "express";
|
||||
@ -8,19 +8,12 @@ export const abortDojoComponentController: RequestHandler = async (req, res) =>
|
||||
const inventory = await getInventory(accountId);
|
||||
const guild = await getGuildForRequestEx(req, inventory);
|
||||
const request = JSON.parse(String(req.body)) as IAbortDojoComponentRequest;
|
||||
|
||||
if (request.DecoId) {
|
||||
removeDojoDeco(guild, request.ComponentId, request.DecoId);
|
||||
} else {
|
||||
removeDojoRoom(guild, request.ComponentId);
|
||||
}
|
||||
|
||||
// TODO: Move already-contributed credits & items to the clan vault
|
||||
guild.DojoComponents.pull({ _id: request.ComponentId });
|
||||
await guild.save();
|
||||
res.json(await getDojoClient(guild, 0, request.ComponentId));
|
||||
res.json(getDojoClient(guild, 0));
|
||||
};
|
||||
|
||||
interface IAbortDojoComponentRequest {
|
||||
DecoType?: string;
|
||||
export interface IAbortDojoComponentRequest {
|
||||
ComponentId: string;
|
||||
DecoId?: string;
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
import { getDojoClient, getGuildForRequest } from "@/src/services/guildService";
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
export const abortDojoComponentDestructionController: RequestHandler = async (req, res) => {
|
||||
const guild = await getGuildForRequest(req);
|
||||
const componentId = req.query.componentId as string;
|
||||
|
||||
guild.DojoComponents.id(componentId)!.DestructionTime = undefined;
|
||||
|
||||
await guild.save();
|
||||
res.json(await getDojoClient(guild, 0, componentId));
|
||||
};
|
@ -58,7 +58,7 @@ export const changeDojoRootController: RequestHandler = async (req, res) => {
|
||||
|
||||
await guild.save();
|
||||
|
||||
res.json(await getDojoClient(guild, 0));
|
||||
res.json(getDojoClient(guild, 0));
|
||||
};
|
||||
|
||||
interface INode {
|
||||
|
@ -1,26 +1,10 @@
|
||||
import { TGuildDatabaseDocument } from "@/src/models/guildModel";
|
||||
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
|
||||
import { getDojoClient, getGuildForRequestEx, scaleRequiredCount } from "@/src/services/guildService";
|
||||
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { IDojoContributable } from "@/src/types/guildTypes";
|
||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||
import { RequestHandler } from "express";
|
||||
import { ExportDojoRecipes, IDojoRecipe } from "warframe-public-export-plus";
|
||||
|
||||
interface IContributeToDojoComponentRequest {
|
||||
ComponentId: string;
|
||||
DecoId?: string;
|
||||
DecoType?: string;
|
||||
IngredientContributions: {
|
||||
ItemType: string;
|
||||
ItemCount: number;
|
||||
}[];
|
||||
RegularCredits: number;
|
||||
VaultIngredientContributions: [];
|
||||
VaultCredits: number;
|
||||
}
|
||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
||||
|
||||
export const contributeToDojoComponentController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
@ -29,54 +13,21 @@ export const contributeToDojoComponentController: RequestHandler = async (req, r
|
||||
// Any clan member should have permission to contribute although notably permission is denied if they have not crafted the dojo key and were simply invited in.
|
||||
const request = JSON.parse(String(req.body)) as IContributeToDojoComponentRequest;
|
||||
const component = guild.DojoComponents.id(request.ComponentId)!;
|
||||
const componentMeta = Object.values(ExportDojoRecipes.rooms).find(x => x.resultType == component.pf)!;
|
||||
|
||||
const inventoryChanges: IInventoryChanges = {};
|
||||
if (!component.CompletionTime) {
|
||||
// Room is in "Collecting Materials" state
|
||||
if (request.DecoId) {
|
||||
throw new Error("attempt to contribute to a deco in an unfinished room?!");
|
||||
}
|
||||
const meta = Object.values(ExportDojoRecipes.rooms).find(x => x.resultType == component.pf)!;
|
||||
await processContribution(guild, request, inventory, inventoryChanges, meta, component);
|
||||
} else {
|
||||
// Room is past "Collecting Materials"
|
||||
if (request.DecoId) {
|
||||
const deco = component.Decos!.find(x => x._id.equals(request.DecoId))!;
|
||||
const meta = Object.values(ExportDojoRecipes.decos).find(x => x.resultType == deco.Type)!;
|
||||
await processContribution(guild, request, inventory, inventoryChanges, meta, deco);
|
||||
}
|
||||
}
|
||||
|
||||
await guild.save();
|
||||
await inventory.save();
|
||||
res.json({
|
||||
...(await getDojoClient(guild, 0, component._id)),
|
||||
InventoryChanges: inventoryChanges
|
||||
});
|
||||
};
|
||||
|
||||
const processContribution = async (
|
||||
guild: TGuildDatabaseDocument,
|
||||
request: IContributeToDojoComponentRequest,
|
||||
inventory: TInventoryDatabaseDocument,
|
||||
inventoryChanges: IInventoryChanges,
|
||||
meta: IDojoRecipe,
|
||||
component: IDojoContributable
|
||||
): Promise<void> => {
|
||||
component.RegularCredits ??= 0;
|
||||
if (component.RegularCredits + request.RegularCredits > scaleRequiredCount(meta.price)) {
|
||||
request.RegularCredits = scaleRequiredCount(meta.price) - component.RegularCredits;
|
||||
if (component.RegularCredits + request.RegularCredits > scaleRequiredCount(componentMeta.price)) {
|
||||
request.RegularCredits = scaleRequiredCount(componentMeta.price) - component.RegularCredits;
|
||||
}
|
||||
component.RegularCredits += request.RegularCredits;
|
||||
inventoryChanges.RegularCredits = -request.RegularCredits;
|
||||
updateCurrency(inventory, request.RegularCredits, false);
|
||||
const inventoryChanges: IInventoryChanges = updateCurrency(inventory, request.RegularCredits, false);
|
||||
|
||||
component.MiscItems ??= [];
|
||||
const miscItemChanges: IMiscItem[] = [];
|
||||
for (const ingredientContribution of request.IngredientContributions) {
|
||||
const componentMiscItem = component.MiscItems.find(x => x.ItemType == ingredientContribution.ItemType);
|
||||
if (componentMiscItem) {
|
||||
const ingredientMeta = meta.ingredients.find(x => x.ItemType == ingredientContribution.ItemType)!;
|
||||
const ingredientMeta = componentMeta.ingredients.find(x => x.ItemType == ingredientContribution.ItemType)!;
|
||||
if (
|
||||
componentMiscItem.ItemCount + ingredientContribution.ItemCount >
|
||||
scaleRequiredCount(ingredientMeta.ItemCount)
|
||||
@ -96,9 +47,9 @@ const processContribution = async (
|
||||
addMiscItems(inventory, miscItemChanges);
|
||||
inventoryChanges.MiscItems = miscItemChanges;
|
||||
|
||||
if (component.RegularCredits >= scaleRequiredCount(meta.price)) {
|
||||
if (component.RegularCredits >= scaleRequiredCount(componentMeta.price)) {
|
||||
let fullyFunded = true;
|
||||
for (const ingredient of meta.ingredients) {
|
||||
for (const ingredient of componentMeta.ingredients) {
|
||||
const componentMiscItem = component.MiscItems.find(x => x.ItemType == ingredient.ItemType);
|
||||
if (!componentMiscItem || componentMiscItem.ItemCount < scaleRequiredCount(ingredient.ItemCount)) {
|
||||
fullyFunded = false;
|
||||
@ -106,13 +57,27 @@ const processContribution = async (
|
||||
}
|
||||
}
|
||||
if (fullyFunded) {
|
||||
if (request.IngredientContributions.length) {
|
||||
// We've already updated subpaths of MiscItems, we need to allow MongoDB to save this before we remove MiscItems.
|
||||
await guild.save();
|
||||
}
|
||||
component.RegularCredits = undefined;
|
||||
component.MiscItems = undefined;
|
||||
component.CompletionTime = new Date(Date.now() + meta.time * 1000);
|
||||
component.CompletionTime = new Date(Date.now() + componentMeta.time * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
await guild.save();
|
||||
await inventory.save();
|
||||
res.json({
|
||||
...getDojoClient(guild, 0, component._id),
|
||||
InventoryChanges: inventoryChanges
|
||||
});
|
||||
};
|
||||
|
||||
export interface IContributeToDojoComponentRequest {
|
||||
ComponentId: string;
|
||||
IngredientContributions: {
|
||||
ItemType: string;
|
||||
ItemCount: number;
|
||||
}[];
|
||||
RegularCredits: number;
|
||||
VaultIngredientContributions: [];
|
||||
VaultCredits: number;
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
import { getDojoClient, getGuildForRequest, removeDojoDeco } from "@/src/services/guildService";
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
export const destroyDojoDecoController: RequestHandler = async (req, res) => {
|
||||
const guild = await getGuildForRequest(req);
|
||||
const request = JSON.parse(String(req.body)) as IDestroyDojoDecoRequest;
|
||||
|
||||
removeDojoDeco(guild, request.ComponentId, request.DecoId);
|
||||
|
||||
await guild.save();
|
||||
res.json(await getDojoClient(guild, 0, request.ComponentId));
|
||||
};
|
||||
|
||||
interface IDestroyDojoDecoRequest {
|
||||
DecoType: string;
|
||||
ComponentId: string;
|
||||
DecoId: string;
|
||||
}
|
@ -1,18 +1,8 @@
|
||||
import { getDojoClient, getGuildForRequestEx, scaleRequiredCount } from "@/src/services/guildService";
|
||||
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { IDojoContributable } from "@/src/types/guildTypes";
|
||||
import { RequestHandler } from "express";
|
||||
import { ExportDojoRecipes, IDojoRecipe } from "warframe-public-export-plus";
|
||||
|
||||
interface IDojoComponentRushRequest {
|
||||
DecoType?: string;
|
||||
DecoId?: string;
|
||||
ComponentId: string;
|
||||
Amount: number;
|
||||
VaultAmount: number;
|
||||
AllianceVaultAmount: number;
|
||||
}
|
||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
||||
|
||||
export const dojoComponentRushController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
@ -20,31 +10,27 @@ export const dojoComponentRushController: RequestHandler = async (req, res) => {
|
||||
const guild = await getGuildForRequestEx(req, inventory);
|
||||
const request = JSON.parse(String(req.body)) as IDojoComponentRushRequest;
|
||||
const component = guild.DojoComponents.id(request.ComponentId)!;
|
||||
const componentMeta = Object.values(ExportDojoRecipes.rooms).find(x => x.resultType == component.pf)!;
|
||||
|
||||
if (request.DecoId) {
|
||||
const deco = component.Decos!.find(x => x._id.equals(request.DecoId))!;
|
||||
const meta = Object.values(ExportDojoRecipes.decos).find(x => x.resultType == deco.Type)!;
|
||||
processContribution(deco, meta, request.Amount);
|
||||
} else {
|
||||
const meta = Object.values(ExportDojoRecipes.rooms).find(x => x.resultType == component.pf)!;
|
||||
processContribution(component, meta, request.Amount);
|
||||
}
|
||||
|
||||
const fullPlatinumCost = scaleRequiredCount(componentMeta.skipTimePrice);
|
||||
const fullDurationSeconds = componentMeta.time;
|
||||
const secondsPerPlatinum = fullDurationSeconds / fullPlatinumCost;
|
||||
component.CompletionTime = new Date(
|
||||
component.CompletionTime!.getTime() - secondsPerPlatinum * request.Amount * 1000
|
||||
);
|
||||
const inventoryChanges = updateCurrency(inventory, request.Amount, true);
|
||||
|
||||
await guild.save();
|
||||
await inventory.save();
|
||||
res.json({
|
||||
...(await getDojoClient(guild, 0, component._id)),
|
||||
...getDojoClient(guild, 0, component._id),
|
||||
InventoryChanges: inventoryChanges
|
||||
});
|
||||
};
|
||||
|
||||
const processContribution = (component: IDojoContributable, meta: IDojoRecipe, platinumDonated: number): void => {
|
||||
const fullPlatinumCost = scaleRequiredCount(meta.skipTimePrice);
|
||||
const fullDurationSeconds = meta.time;
|
||||
const secondsPerPlatinum = fullDurationSeconds / fullPlatinumCost;
|
||||
component.CompletionTime = new Date(
|
||||
component.CompletionTime!.getTime() - secondsPerPlatinum * platinumDonated * 1000
|
||||
);
|
||||
};
|
||||
interface IDojoComponentRushRequest {
|
||||
ComponentId: string;
|
||||
Amount: number;
|
||||
VaultAmount: number;
|
||||
AllianceVaultAmount: number;
|
||||
}
|
||||
|
@ -18,11 +18,10 @@ export const getGuildDojoController: RequestHandler = async (req, res) => {
|
||||
_id: new Types.ObjectId(),
|
||||
pf: "/Lotus/Levels/ClanDojo/DojoHall.level",
|
||||
ppf: "",
|
||||
CompletionTime: new Date(Date.now()),
|
||||
DecoCapacity: 600
|
||||
CompletionTime: new Date(Date.now())
|
||||
});
|
||||
await guild.save();
|
||||
}
|
||||
|
||||
res.json(await getDojoClient(guild, 0));
|
||||
res.json(getDojoClient(guild, 0));
|
||||
};
|
||||
|
@ -54,7 +54,7 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
|
||||
logger.debug("mission report:", missionReport);
|
||||
|
||||
const inventory = await getInventory(accountId);
|
||||
const inventoryUpdates = addMissionInventoryUpdates(inventory, missionReport);
|
||||
const inventoryUpdates = await addMissionInventoryUpdates(inventory, missionReport);
|
||||
|
||||
if (missionReport.MissionStatus !== "GS_SUCCESS") {
|
||||
await inventory.save();
|
||||
|
@ -1,43 +0,0 @@
|
||||
import { getDojoClient, getGuildForRequest } from "@/src/services/guildService";
|
||||
import { RequestHandler } from "express";
|
||||
import { Types } from "mongoose";
|
||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
||||
|
||||
export const placeDecoInComponentController: RequestHandler = async (req, res) => {
|
||||
const guild = await getGuildForRequest(req);
|
||||
const request = JSON.parse(String(req.body)) as IPlaceDecoInComponentRequest;
|
||||
// At this point, we know that a member of the guild is making this request. Assuming they are allowed to place decorations.
|
||||
const component = guild.DojoComponents.id(request.ComponentId)!;
|
||||
|
||||
if (component.DecoCapacity === undefined) {
|
||||
component.DecoCapacity = Object.values(ExportDojoRecipes.rooms).find(
|
||||
x => x.resultType == component.pf
|
||||
)!.decoCapacity;
|
||||
}
|
||||
|
||||
component.Decos ??= [];
|
||||
component.Decos.push({
|
||||
_id: new Types.ObjectId(),
|
||||
Type: request.Type,
|
||||
Pos: request.Pos,
|
||||
Rot: request.Rot,
|
||||
Name: request.Name
|
||||
});
|
||||
|
||||
const meta = Object.values(ExportDojoRecipes.decos).find(x => x.resultType == request.Type);
|
||||
if (meta && meta.capacityCost) {
|
||||
component.DecoCapacity -= meta.capacityCost;
|
||||
}
|
||||
|
||||
await guild.save();
|
||||
res.json(await getDojoClient(guild, 0, component._id));
|
||||
};
|
||||
|
||||
interface IPlaceDecoInComponentRequest {
|
||||
ComponentId: string;
|
||||
Revision: number;
|
||||
Type: string;
|
||||
Pos: number[];
|
||||
Rot: number[];
|
||||
Name?: string;
|
||||
}
|
@ -1,15 +1,19 @@
|
||||
import { config } from "@/src/services/configService";
|
||||
import { getDojoClient, getGuildForRequest } from "@/src/services/guildService";
|
||||
import { RequestHandler } from "express";
|
||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
||||
|
||||
export const queueDojoComponentDestructionController: RequestHandler = async (req, res) => {
|
||||
const guild = await getGuildForRequest(req);
|
||||
const componentId = req.query.componentId as string;
|
||||
|
||||
guild.DojoComponents.id(componentId)!.DestructionTime = new Date(
|
||||
Date.now() + (config.fastDojoRoomDestruction ? 5_000 : 2 * 3600_000)
|
||||
);
|
||||
|
||||
const component = guild.DojoComponents.splice(
|
||||
guild.DojoComponents.findIndex(x => x._id.toString() === componentId),
|
||||
1
|
||||
)[0];
|
||||
const room = Object.values(ExportDojoRecipes.rooms).find(x => x.resultType == component.pf);
|
||||
if (room) {
|
||||
guild.DojoCapacity -= room.capacity;
|
||||
guild.DojoEnergy -= room.energy;
|
||||
}
|
||||
await guild.save();
|
||||
res.json(await getDojoClient(guild, 0, componentId));
|
||||
res.json(getDojoClient(guild, 1));
|
||||
};
|
||||
|
@ -12,7 +12,7 @@ export const setDojoComponentMessageController: RequestHandler = async (req, res
|
||||
component.Message = payload.Message;
|
||||
}
|
||||
await guild.save();
|
||||
res.json(await getDojoClient(guild, 0, component._id));
|
||||
res.json(getDojoClient(guild, 0, component._id));
|
||||
};
|
||||
|
||||
type SetDojoComponentMessageRequest = { Name: string } | { Message: string };
|
||||
|
@ -29,13 +29,12 @@ export const startDojoRecipeController: RequestHandler = async (req, res) => {
|
||||
ppf: request.PlacedComponent.ppf,
|
||||
pi: new Types.ObjectId(request.PlacedComponent.pi!.$oid),
|
||||
op: request.PlacedComponent.op,
|
||||
pp: request.PlacedComponent.pp,
|
||||
DecoCapacity: room?.decoCapacity
|
||||
pp: request.PlacedComponent.pp
|
||||
}) - 1
|
||||
];
|
||||
if (config.noDojoRoomBuildStage) {
|
||||
component.CompletionTime = new Date(Date.now());
|
||||
}
|
||||
await guild.save();
|
||||
res.json(await getDojoClient(guild, 0));
|
||||
res.json(getDojoClient(guild, 0));
|
||||
};
|
||||
|
@ -2,23 +2,12 @@ import {
|
||||
IGuildDatabase,
|
||||
IDojoComponentDatabase,
|
||||
ITechProjectDatabase,
|
||||
ITechProjectClient,
|
||||
IDojoDecoDatabase
|
||||
ITechProjectClient
|
||||
} from "@/src/types/guildTypes";
|
||||
import { Document, Model, model, Schema, Types } from "mongoose";
|
||||
import { typeCountSchema } from "./inventoryModels/inventoryModel";
|
||||
import { toMongoDate } from "../helpers/inventoryHelpers";
|
||||
|
||||
const dojoDecoSchema = new Schema<IDojoDecoDatabase>({
|
||||
Type: String,
|
||||
Pos: [Number],
|
||||
Rot: [Number],
|
||||
Name: String,
|
||||
RegularCredits: Number,
|
||||
MiscItems: { type: [typeCountSchema], default: undefined },
|
||||
CompletionTime: Date
|
||||
});
|
||||
|
||||
const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
||||
pf: { type: String, required: true },
|
||||
ppf: String,
|
||||
@ -29,10 +18,7 @@ const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
||||
Message: String,
|
||||
RegularCredits: Number,
|
||||
MiscItems: { type: [typeCountSchema], default: undefined },
|
||||
CompletionTime: Date,
|
||||
DestructionTime: Date,
|
||||
Decos: [dojoDecoSchema],
|
||||
DecoCapacity: Number
|
||||
CompletionTime: Date
|
||||
});
|
||||
|
||||
const techProjectSchema = new Schema<ITechProjectDatabase>(
|
||||
|
@ -1,7 +1,6 @@
|
||||
import express from "express";
|
||||
import { abandonLibraryDailyTaskController } from "@/src/controllers/api/abandonLibraryDailyTaskController";
|
||||
import { abortDojoComponentController } from "@/src/controllers/api/abortDojoComponentController";
|
||||
import { abortDojoComponentDestructionController } from "@/src/controllers/api/abortDojoComponentDestructionController";
|
||||
import { activateRandomModController } from "@/src/controllers/api/activateRandomModController";
|
||||
import { addFriendImageController } from "@/src/controllers/api/addFriendImageController";
|
||||
import { arcaneCommonController } from "@/src/controllers/api/arcaneCommonController";
|
||||
@ -17,7 +16,6 @@ import { contributeToDojoComponentController } from "@/src/controllers/api/contr
|
||||
import { createGuildController } from "@/src/controllers/api/createGuildController";
|
||||
import { creditsController } from "@/src/controllers/api/creditsController";
|
||||
import { deleteSessionController } from "@/src/controllers/api/deleteSessionController";
|
||||
import { destroyDojoDecoController } from "@/src/controllers/api/destroyDojoDecoController";
|
||||
import { dojoComponentRushController } from "@/src/controllers/api/dojoComponentRushController";
|
||||
import { dojoController } from "@/src/controllers/api/dojoController";
|
||||
import { dronesController } from "@/src/controllers/api/dronesController";
|
||||
@ -61,7 +59,6 @@ import { missionInventoryUpdateController } from "@/src/controllers/api/missionI
|
||||
import { modularWeaponCraftingController } from "@/src/controllers/api/modularWeaponCraftingController";
|
||||
import { modularWeaponSaleController } from "@/src/controllers/api/modularWeaponSaleController";
|
||||
import { nameWeaponController } from "@/src/controllers/api/nameWeaponController";
|
||||
import { placeDecoInComponentController } from "@/src/controllers/api/placeDecoInComponentController";
|
||||
import { playerSkillsController } from "@/src/controllers/api/playerSkillsController";
|
||||
import { projectionManagerController } from "@/src/controllers/api/projectionManagerController";
|
||||
import { purchaseController } from "@/src/controllers/api/purchaseController";
|
||||
@ -106,7 +103,6 @@ const apiRouter = express.Router();
|
||||
|
||||
// get
|
||||
apiRouter.get("/abandonLibraryDailyTask.php", abandonLibraryDailyTaskController);
|
||||
apiRouter.get("/abortDojoComponentDestruction.php", abortDojoComponentDestructionController);
|
||||
apiRouter.get("/checkDailyMissionBonus.php", checkDailyMissionBonusController);
|
||||
apiRouter.get("/claimLibraryDailyTaskReward.php", claimLibraryDailyTaskRewardController);
|
||||
apiRouter.get("/credits.php", creditsController);
|
||||
@ -154,7 +150,6 @@ apiRouter.post("/clearDialogueHistory.php", clearDialogueHistoryController);
|
||||
apiRouter.post("/completeRandomModChallenge.php", completeRandomModChallengeController);
|
||||
apiRouter.post("/contributeToDojoComponent.php", contributeToDojoComponentController);
|
||||
apiRouter.post("/createGuild.php", createGuildController);
|
||||
apiRouter.post("/destroyDojoDeco.php", destroyDojoDecoController);
|
||||
apiRouter.post("/dojoComponentRush.php", dojoComponentRushController);
|
||||
apiRouter.post("/drones.php", dronesController);
|
||||
apiRouter.post("/endlessXp.php", endlessXpController);
|
||||
@ -180,7 +175,6 @@ apiRouter.post("/login.php", loginController);
|
||||
apiRouter.post("/missionInventoryUpdate.php", missionInventoryUpdateController);
|
||||
apiRouter.post("/modularWeaponCrafting.php", modularWeaponCraftingController);
|
||||
apiRouter.post("/nameWeapon.php", nameWeaponController);
|
||||
apiRouter.post("/placeDecoInComponent.php", placeDecoInComponentController);
|
||||
apiRouter.post("/playerSkills.php", playerSkillsController);
|
||||
apiRouter.post("/projectionManager.php", projectionManagerController);
|
||||
apiRouter.post("/purchase.php", purchaseController);
|
||||
|
@ -59,7 +59,6 @@ interface IConfig {
|
||||
noDailyStandingLimits?: boolean;
|
||||
instantResourceExtractorDrones?: boolean;
|
||||
noDojoRoomBuildStage?: boolean;
|
||||
fastDojoRoomDestruction?: boolean;
|
||||
noDojoResearchCosts?: boolean;
|
||||
noDojoResearchTime?: boolean;
|
||||
spoofMasteryRank?: number;
|
||||
|
@ -6,8 +6,6 @@ import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/invento
|
||||
import { IDojoClient, IDojoComponentClient } from "@/src/types/guildTypes";
|
||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
|
||||
import { Types } from "mongoose";
|
||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
export const getGuildForRequest = async (req: Request): Promise<TGuildDatabaseDocument> => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
@ -30,11 +28,11 @@ export const getGuildForRequestEx = async (
|
||||
return guild;
|
||||
};
|
||||
|
||||
export const getDojoClient = async (
|
||||
export const getDojoClient = (
|
||||
guild: TGuildDatabaseDocument,
|
||||
status: number,
|
||||
componentId: Types.ObjectId | string | undefined = undefined
|
||||
): Promise<IDojoClient> => {
|
||||
componentId: Types.ObjectId | undefined = undefined
|
||||
): IDojoClient => {
|
||||
const dojo: IDojoClient = {
|
||||
_id: { $oid: guild._id.toString() },
|
||||
Name: guild.Name,
|
||||
@ -47,16 +45,15 @@ export const getDojoClient = async (
|
||||
DojoRequestStatus: status,
|
||||
DojoComponents: []
|
||||
};
|
||||
const roomsToRemove: Types.ObjectId[] = [];
|
||||
guild.DojoComponents.forEach(dojoComponent => {
|
||||
if (!componentId || dojoComponent._id.equals(componentId)) {
|
||||
if (!componentId || componentId == dojoComponent._id) {
|
||||
const clientComponent: IDojoComponentClient = {
|
||||
id: toOid(dojoComponent._id),
|
||||
pf: dojoComponent.pf,
|
||||
ppf: dojoComponent.ppf,
|
||||
Name: dojoComponent.Name,
|
||||
Message: dojoComponent.Message,
|
||||
DecoCapacity: dojoComponent.DecoCapacity ?? 600
|
||||
DecoCapacity: 600
|
||||
};
|
||||
if (dojoComponent.pi) {
|
||||
clientComponent.pi = toOid(dojoComponent.pi);
|
||||
@ -65,41 +62,13 @@ export const getDojoClient = async (
|
||||
}
|
||||
if (dojoComponent.CompletionTime) {
|
||||
clientComponent.CompletionTime = toMongoDate(dojoComponent.CompletionTime);
|
||||
if (dojoComponent.DestructionTime) {
|
||||
if (Date.now() >= dojoComponent.DestructionTime.getTime()) {
|
||||
roomsToRemove.push(dojoComponent._id);
|
||||
return;
|
||||
}
|
||||
clientComponent.DestructionTime = toMongoDate(dojoComponent.DestructionTime);
|
||||
}
|
||||
} else {
|
||||
clientComponent.RegularCredits = dojoComponent.RegularCredits;
|
||||
clientComponent.MiscItems = dojoComponent.MiscItems;
|
||||
}
|
||||
if (dojoComponent.Decos) {
|
||||
clientComponent.Decos = [];
|
||||
for (const deco of dojoComponent.Decos) {
|
||||
clientComponent.Decos.push({
|
||||
id: toOid(deco._id),
|
||||
Type: deco.Type,
|
||||
Pos: deco.Pos,
|
||||
Rot: deco.Rot,
|
||||
CompletionTime: deco.CompletionTime ? toMongoDate(deco.CompletionTime) : undefined,
|
||||
RegularCredits: deco.RegularCredits,
|
||||
MiscItems: deco.MiscItems
|
||||
});
|
||||
}
|
||||
}
|
||||
dojo.DojoComponents.push(clientComponent);
|
||||
}
|
||||
});
|
||||
if (roomsToRemove.length) {
|
||||
logger.debug(`removing now-destroyed rooms`, roomsToRemove);
|
||||
for (const id of roomsToRemove) {
|
||||
removeDojoRoom(guild, id);
|
||||
}
|
||||
await guild.save();
|
||||
}
|
||||
return dojo;
|
||||
};
|
||||
|
||||
@ -107,33 +76,3 @@ export const scaleRequiredCount = (count: number): number => {
|
||||
// The recipes in the export are for Moon clans. For now we'll just assume we only have Ghost clans.
|
||||
return Math.max(1, Math.trunc(count / 100));
|
||||
};
|
||||
|
||||
export const removeDojoRoom = (guild: TGuildDatabaseDocument, componentId: Types.ObjectId | string): void => {
|
||||
const component = guild.DojoComponents.splice(
|
||||
guild.DojoComponents.findIndex(x => x._id.equals(componentId)),
|
||||
1
|
||||
)[0];
|
||||
const meta = Object.values(ExportDojoRecipes.rooms).find(x => x.resultType == component.pf);
|
||||
if (meta) {
|
||||
guild.DojoCapacity -= meta.capacity;
|
||||
guild.DojoEnergy -= meta.energy;
|
||||
}
|
||||
// TODO: Add resources spent to the clan vault
|
||||
};
|
||||
|
||||
export const removeDojoDeco = (
|
||||
guild: TGuildDatabaseDocument,
|
||||
componentId: Types.ObjectId | string,
|
||||
decoId: Types.ObjectId | string
|
||||
): void => {
|
||||
const component = guild.DojoComponents.id(componentId)!;
|
||||
const deco = component.Decos!.splice(
|
||||
component.Decos!.findIndex(x => x._id.equals(decoId)),
|
||||
1
|
||||
)[0];
|
||||
const meta = Object.values(ExportDojoRecipes.decos).find(x => x.resultType == deco.Type);
|
||||
if (meta && meta.capacityCost) {
|
||||
component.DecoCapacity! += meta.capacityCost;
|
||||
}
|
||||
// TODO: Add resources spent to the clan vault
|
||||
};
|
||||
|
@ -428,10 +428,8 @@ export const addItem = async (
|
||||
};
|
||||
}
|
||||
if (typeName in ExportEmailItems) {
|
||||
const emailItem = ExportEmailItems[typeName];
|
||||
await createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(emailItem.message)]);
|
||||
return {
|
||||
InventoryChanges: {}
|
||||
InventoryChanges: await addEmailItem(inventory, typeName)
|
||||
};
|
||||
}
|
||||
|
||||
@ -943,6 +941,28 @@ const addDrone = (
|
||||
return inventoryChanges;
|
||||
};
|
||||
|
||||
export const addEmailItem = async (
|
||||
inventory: TInventoryDatabaseDocument,
|
||||
typeName: string,
|
||||
inventoryChanges: IInventoryChanges = {}
|
||||
): Promise<IInventoryChanges> => {
|
||||
const meta = ExportEmailItems[typeName];
|
||||
const emailItem = inventory.EmailItems.find(x => x.ItemType == typeName);
|
||||
if (!emailItem || !meta.sendOnlyOnce) {
|
||||
await createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(meta.message)]);
|
||||
|
||||
if (emailItem) {
|
||||
emailItem.ItemCount += 1;
|
||||
} else {
|
||||
inventory.EmailItems.push({ ItemType: typeName, ItemCount: 1 });
|
||||
}
|
||||
|
||||
inventoryChanges.EmailItems ??= [];
|
||||
inventoryChanges.EmailItems.push({ ItemType: typeName, ItemCount: 1 });
|
||||
}
|
||||
return inventoryChanges;
|
||||
};
|
||||
|
||||
//TODO: wrong id is not erroring
|
||||
export const addGearExpByCategory = (
|
||||
inventory: TInventoryDatabaseDocument,
|
||||
|
@ -14,6 +14,7 @@ import {
|
||||
addConsumables,
|
||||
addCrewShipAmmo,
|
||||
addCrewShipRawSalvage,
|
||||
addEmailItem,
|
||||
addFocusXpIncreases,
|
||||
addFusionTreasures,
|
||||
addGearExpByCategory,
|
||||
@ -61,10 +62,10 @@ const getRandomRewardByChance = (pool: IReward[]): IRngResult | undefined => {
|
||||
//type TignoredInventoryUpdateKeys = (typeof ignoredInventoryUpdateKeys)[number];
|
||||
//const knownUnhandledKeys: readonly string[] = ["test"] as const; // for unimplemented but important keys
|
||||
|
||||
export const addMissionInventoryUpdates = (
|
||||
export const addMissionInventoryUpdates = async (
|
||||
inventory: HydratedDocument<IInventoryDatabase, InventoryDocumentProps>,
|
||||
inventoryUpdates: IMissionInventoryUpdateRequest
|
||||
): Partial<IInventoryDatabase> | undefined => {
|
||||
): Promise<Partial<IInventoryDatabase> | undefined> => {
|
||||
//TODO: type this properly
|
||||
const inventoryChanges: Partial<IInventoryDatabase> = {};
|
||||
if (inventoryUpdates.MissionFailed === true) {
|
||||
@ -156,6 +157,12 @@ export const addMissionInventoryUpdates = (
|
||||
inventoryChanges.FusionPoints = fusionPoints;
|
||||
break;
|
||||
}
|
||||
case "EmailItems": {
|
||||
for (const tc of value) {
|
||||
await addEmailItem(inventory, tc.ItemType);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "FocusXpIncreases": {
|
||||
addFocusXpIncreases(inventory, value);
|
||||
break;
|
||||
@ -206,32 +213,32 @@ export const addMissionInventoryUpdates = (
|
||||
});
|
||||
break;
|
||||
case "CollectibleScans":
|
||||
value.forEach(scan => {
|
||||
for (const scan of value) {
|
||||
const entry = inventory.CollectibleSeries?.find(x => x.CollectibleType == scan.CollectibleType);
|
||||
if (entry) {
|
||||
entry.Count = scan.Count;
|
||||
entry.Tracking = scan.Tracking;
|
||||
if (entry.CollectibleType == "/Lotus/Objects/Orokin/Props/CollectibleSeriesOne") {
|
||||
const progress = entry.Count / entry.ReqScans;
|
||||
entry.IncentiveStates.forEach(gate => {
|
||||
for (const gate of entry.IncentiveStates) {
|
||||
gate.complete = progress >= gate.threshold;
|
||||
if (gate.complete && !gate.sent) {
|
||||
gate.sent = true;
|
||||
if (gate.threshold == 0.5) {
|
||||
void createMessage(inventory.accountOwnerId.toString(), [kuriaMessage50]);
|
||||
await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage50]);
|
||||
} else {
|
||||
void createMessage(inventory.accountOwnerId.toString(), [kuriaMessage75]);
|
||||
await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage75]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (progress >= 1.0) {
|
||||
void createMessage(inventory.accountOwnerId.toString(), [kuriaMessage100]);
|
||||
await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage100]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger.warn(`${scan.CollectibleType} was not found in inventory, ignoring scans`);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "Upgrades":
|
||||
value.forEach(clientUpgrade => {
|
||||
|
@ -41,33 +41,18 @@ export interface IDojoComponentClient {
|
||||
CompletionTime?: IMongoDate;
|
||||
RushPlatinum?: number;
|
||||
DestructionTime?: IMongoDate;
|
||||
Decos?: IDojoDecoClient[];
|
||||
DecoCapacity?: number;
|
||||
}
|
||||
|
||||
export interface IDojoComponentDatabase
|
||||
extends Omit<IDojoComponentClient, "id" | "pi" | "CompletionTime" | "RushPlatinum" | "DestructionTime" | "Decos"> {
|
||||
extends Omit<
|
||||
IDojoComponentClient,
|
||||
"id" | "pi" | "CompletionTime" | "RushPlatinum" | "DestructionTime" | "DecoCapacity"
|
||||
> {
|
||||
_id: Types.ObjectId;
|
||||
pi?: Types.ObjectId;
|
||||
CompletionTime?: Date;
|
||||
DestructionTime?: Date;
|
||||
Decos?: IDojoDecoDatabase[];
|
||||
}
|
||||
|
||||
export interface IDojoDecoClient {
|
||||
id: IOid;
|
||||
Type: string;
|
||||
Pos: number[];
|
||||
Rot: number[];
|
||||
Name?: string; // for teleporters
|
||||
RegularCredits?: number;
|
||||
MiscItems?: IMiscItem[];
|
||||
CompletionTime?: IMongoDate;
|
||||
}
|
||||
|
||||
export interface IDojoDecoDatabase extends Omit<IDojoDecoClient, "id" | "CompletionTime"> {
|
||||
_id: Types.ObjectId;
|
||||
CompletionTime?: Date;
|
||||
//DestructionTime?: Date;
|
||||
}
|
||||
|
||||
export interface ITechProjectClient {
|
||||
@ -81,9 +66,3 @@ export interface ITechProjectClient {
|
||||
export interface ITechProjectDatabase extends Omit<ITechProjectClient, "CompletionDate"> {
|
||||
CompletionDate?: Date;
|
||||
}
|
||||
|
||||
export interface IDojoContributable {
|
||||
RegularCredits?: number;
|
||||
MiscItems?: IMiscItem[];
|
||||
CompletionTime?: Date;
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes";
|
||||
import { IDroneClient, IInfestedFoundryClient, IMiscItem, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
|
||||
import {
|
||||
IDroneClient,
|
||||
IInfestedFoundryClient,
|
||||
IMiscItem,
|
||||
ITypeCount,
|
||||
TEquipmentKey
|
||||
} from "./inventoryTypes/inventoryTypes";
|
||||
|
||||
export interface IPurchaseRequest {
|
||||
PurchaseParams: IPurchaseParams;
|
||||
@ -33,6 +39,7 @@ export type IInventoryChanges = {
|
||||
InfestedFoundry?: IInfestedFoundryClient;
|
||||
Drones?: IDroneClient[];
|
||||
MiscItems?: IMiscItem[];
|
||||
EmailItems?: ITypeCount[];
|
||||
} & Record<
|
||||
Exclude<
|
||||
string,
|
||||
@ -44,6 +51,7 @@ export type IInventoryChanges = {
|
||||
| "InfestedFoundry"
|
||||
| "Drones"
|
||||
| "MiscItems"
|
||||
| "EmailItems"
|
||||
>,
|
||||
number | object[]
|
||||
>;
|
||||
|
@ -46,6 +46,7 @@ export type IMissionInventoryUpdateRequest = {
|
||||
CrewShipRawSalvage?: ITypeCount[];
|
||||
CrewShipAmmo?: ITypeCount[];
|
||||
BonusMiscItems?: ITypeCount[];
|
||||
EmailItems?: ITypeCount[];
|
||||
|
||||
SyndicateId?: string;
|
||||
SortieId?: string;
|
||||
|
@ -525,10 +525,6 @@
|
||||
<input class="form-check-input" type="checkbox" id="noDojoRoomBuildStage" />
|
||||
<label class="form-check-label" for="noDojoRoomBuildStage" data-loc="cheats_noDojoRoomBuildStage"></label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="fastDojoRoomDestruction" />
|
||||
<label class="form-check-label" for="fastDojoRoomDestruction" data-loc="cheats_fastDojoRoomDestruction"></label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" id="noDojoResearchCosts" />
|
||||
<label class="form-check-label" for="noDojoResearchCosts" data-loc="cheats_noDojoResearchCosts"></label>
|
||||
|
@ -111,7 +111,6 @@ dict = {
|
||||
cheats_noDailyStandingLimits: `No Daily Standing Limits`,
|
||||
cheats_instantResourceExtractorDrones: `Instant Resource Extractor Drones`,
|
||||
cheats_noDojoRoomBuildStage: `No Dojo Room Build Stage`,
|
||||
cheats_fastDojoRoomDestruction: `Fast Dojo Room Destruction`,
|
||||
cheats_noDojoResearchCosts: `No Dojo Research Costs`,
|
||||
cheats_noDojoResearchTime: `No Dojo Research Time`,
|
||||
cheats_spoofMasteryRank: `Spoofed Mastery Rank (-1 to disable)`,
|
||||
|
@ -1,4 +1,3 @@
|
||||
// French translation by Vitruvio
|
||||
dict = {
|
||||
general_inventoryUpdateNote: `Note : Les changements effectués ici seront appliqués lors de la syncrhonisation. Visiter la navigation appliquera les changements apportés à l'inventaire.`,
|
||||
general_addButton: `Ajouter`,
|
||||
@ -95,6 +94,8 @@ dict = {
|
||||
cheats_skipAllDialogue: `Passer les dialogues`,
|
||||
cheats_unlockAllScans: `Débloquer tous les scans`,
|
||||
cheats_unlockAllMissions: `Débloquer toutes les missions`,
|
||||
cheats_unlockAllQuests: `Débloquer toutes les quêtes`,
|
||||
cheats_completeAllQuests: `Compléter toutes les quêtes`,
|
||||
cheats_infiniteCredits: `Crédits infinis`,
|
||||
cheats_infinitePlatinum: `Platinum infini`,
|
||||
cheats_infiniteEndo: `Endo infini`,
|
||||
@ -112,7 +113,6 @@ dict = {
|
||||
cheats_noDailyStandingLimits: `Pas de limite de réputation journalière`,
|
||||
cheats_instantResourceExtractorDrones: `Ressources de drone d'extraction instantannées`,
|
||||
cheats_noDojoRoomBuildStage: `No Dojo Room Build Stage`,
|
||||
cheats_fastDojoRoomDestruction: `[UNTRANSLATED] Fast Dojo Room Destruction`,
|
||||
cheats_noDojoResearchCosts: `Aucun coût de recherche (Dojo)`,
|
||||
cheats_noDojoResearchTime: `Aucun temps de recherche (Dojo)`,
|
||||
cheats_spoofMasteryRank: `Spoofed Mastery Rank (-1 to disable)`,
|
||||
|
@ -112,7 +112,6 @@ dict = {
|
||||
cheats_noDailyStandingLimits: `Без ежедневных ограничений репутации`,
|
||||
cheats_instantResourceExtractorDrones: `[UNTRANSLATED] Instant Resource Extractor Drones`,
|
||||
cheats_noDojoRoomBuildStage: `[UNTRANSLATED] No Dojo Room Build Stage`,
|
||||
cheats_fastDojoRoomDestruction: `[UNTRANSLATED] Fast Dojo Room Destruction`,
|
||||
cheats_noDojoResearchCosts: `[UNTRANSLATED] No Dojo Research Costs`,
|
||||
cheats_noDojoResearchTime: `[UNTRANSLATED] No Dojo Research Time`,
|
||||
cheats_spoofMasteryRank: `Подделанный ранг мастерства (-1 для отключения)`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user