forked from OpenWF/SpaceNinjaServer
Compare commits
3 Commits
mission-Em
...
main
Author | SHA1 | Date | |
---|---|---|---|
77aa1caa8f | |||
6daa8ab5da | |||
c4ab496aa3 |
@ -33,6 +33,7 @@
|
||||
"noDailyStandingLimits": true,
|
||||
"instantResourceExtractorDrones": false,
|
||||
"noDojoRoomBuildStage": true,
|
||||
"fastDojoRoomDestruction": true,
|
||||
"noDojoResearchCosts": true,
|
||||
"noDojoResearchTime": true,
|
||||
"spoofMasteryRank": -1
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getDojoClient, getGuildForRequestEx } from "@/src/services/guildService";
|
||||
import { getDojoClient, getGuildForRequestEx, removeDojoDeco, removeDojoRoom } from "@/src/services/guildService";
|
||||
import { getInventory } from "@/src/services/inventoryService";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { RequestHandler } from "express";
|
||||
@ -8,12 +8,19 @@ 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;
|
||||
// TODO: Move already-contributed credits & items to the clan vault
|
||||
guild.DojoComponents.pull({ _id: request.ComponentId });
|
||||
|
||||
if (request.DecoId) {
|
||||
removeDojoDeco(guild, request.ComponentId, request.DecoId);
|
||||
} else {
|
||||
removeDojoRoom(guild, request.ComponentId);
|
||||
}
|
||||
|
||||
await guild.save();
|
||||
res.json(getDojoClient(guild, 0));
|
||||
res.json(await getDojoClient(guild, 0, request.ComponentId));
|
||||
};
|
||||
|
||||
export interface IAbortDojoComponentRequest {
|
||||
interface IAbortDojoComponentRequest {
|
||||
DecoType?: string;
|
||||
ComponentId: string;
|
||||
DecoId?: string;
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
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(getDojoClient(guild, 0));
|
||||
res.json(await getDojoClient(guild, 0));
|
||||
};
|
||||
|
||||
interface INode {
|
||||
|
@ -1,10 +1,26 @@
|
||||
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 } from "warframe-public-export-plus";
|
||||
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;
|
||||
}
|
||||
|
||||
export const contributeToDojoComponentController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
@ -13,21 +29,54 @@ 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(componentMeta.price)) {
|
||||
request.RegularCredits = scaleRequiredCount(componentMeta.price) - component.RegularCredits;
|
||||
if (component.RegularCredits + request.RegularCredits > scaleRequiredCount(meta.price)) {
|
||||
request.RegularCredits = scaleRequiredCount(meta.price) - component.RegularCredits;
|
||||
}
|
||||
component.RegularCredits += request.RegularCredits;
|
||||
const inventoryChanges: IInventoryChanges = updateCurrency(inventory, request.RegularCredits, false);
|
||||
inventoryChanges.RegularCredits = -request.RegularCredits;
|
||||
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 = componentMeta.ingredients.find(x => x.ItemType == ingredientContribution.ItemType)!;
|
||||
const ingredientMeta = meta.ingredients.find(x => x.ItemType == ingredientContribution.ItemType)!;
|
||||
if (
|
||||
componentMiscItem.ItemCount + ingredientContribution.ItemCount >
|
||||
scaleRequiredCount(ingredientMeta.ItemCount)
|
||||
@ -47,9 +96,9 @@ export const contributeToDojoComponentController: RequestHandler = async (req, r
|
||||
addMiscItems(inventory, miscItemChanges);
|
||||
inventoryChanges.MiscItems = miscItemChanges;
|
||||
|
||||
if (component.RegularCredits >= scaleRequiredCount(componentMeta.price)) {
|
||||
if (component.RegularCredits >= scaleRequiredCount(meta.price)) {
|
||||
let fullyFunded = true;
|
||||
for (const ingredient of componentMeta.ingredients) {
|
||||
for (const ingredient of meta.ingredients) {
|
||||
const componentMiscItem = component.MiscItems.find(x => x.ItemType == ingredient.ItemType);
|
||||
if (!componentMiscItem || componentMiscItem.ItemCount < scaleRequiredCount(ingredient.ItemCount)) {
|
||||
fullyFunded = false;
|
||||
@ -57,27 +106,13 @@ export const contributeToDojoComponentController: RequestHandler = async (req, r
|
||||
}
|
||||
}
|
||||
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() + componentMeta.time * 1000);
|
||||
component.CompletionTime = new Date(Date.now() + meta.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;
|
||||
}
|
||||
|
18
src/controllers/api/destroyDojoDecoController.ts
Normal file
18
src/controllers/api/destroyDojoDecoController.ts
Normal file
@ -0,0 +1,18 @@
|
||||
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,8 +1,18 @@
|
||||
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 } from "warframe-public-export-plus";
|
||||
import { ExportDojoRecipes, IDojoRecipe } from "warframe-public-export-plus";
|
||||
|
||||
interface IDojoComponentRushRequest {
|
||||
DecoType?: string;
|
||||
DecoId?: string;
|
||||
ComponentId: string;
|
||||
Amount: number;
|
||||
VaultAmount: number;
|
||||
AllianceVaultAmount: number;
|
||||
}
|
||||
|
||||
export const dojoComponentRushController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
@ -10,27 +20,31 @@ 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)!;
|
||||
|
||||
const fullPlatinumCost = scaleRequiredCount(componentMeta.skipTimePrice);
|
||||
const fullDurationSeconds = componentMeta.time;
|
||||
const secondsPerPlatinum = fullDurationSeconds / fullPlatinumCost;
|
||||
component.CompletionTime = new Date(
|
||||
component.CompletionTime!.getTime() - secondsPerPlatinum * request.Amount * 1000
|
||||
);
|
||||
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 inventoryChanges = updateCurrency(inventory, request.Amount, true);
|
||||
|
||||
await guild.save();
|
||||
await inventory.save();
|
||||
res.json({
|
||||
...getDojoClient(guild, 0, component._id),
|
||||
...(await getDojoClient(guild, 0, component._id)),
|
||||
InventoryChanges: inventoryChanges
|
||||
});
|
||||
};
|
||||
|
||||
interface IDojoComponentRushRequest {
|
||||
ComponentId: string;
|
||||
Amount: number;
|
||||
VaultAmount: number;
|
||||
AllianceVaultAmount: number;
|
||||
}
|
||||
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
|
||||
);
|
||||
};
|
||||
|
@ -18,10 +18,11 @@ export const getGuildDojoController: RequestHandler = async (req, res) => {
|
||||
_id: new Types.ObjectId(),
|
||||
pf: "/Lotus/Levels/ClanDojo/DojoHall.level",
|
||||
ppf: "",
|
||||
CompletionTime: new Date(Date.now())
|
||||
CompletionTime: new Date(Date.now()),
|
||||
DecoCapacity: 600
|
||||
});
|
||||
await guild.save();
|
||||
}
|
||||
|
||||
res.json(getDojoClient(guild, 0));
|
||||
res.json(await getDojoClient(guild, 0));
|
||||
};
|
||||
|
43
src/controllers/api/placeDecoInComponentController.ts
Normal file
43
src/controllers/api/placeDecoInComponentController.ts
Normal file
@ -0,0 +1,43 @@
|
||||
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,19 +1,15 @@
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
guild.DojoComponents.id(componentId)!.DestructionTime = new Date(
|
||||
Date.now() + (config.fastDojoRoomDestruction ? 5_000 : 2 * 3600_000)
|
||||
);
|
||||
|
||||
await guild.save();
|
||||
res.json(getDojoClient(guild, 1));
|
||||
res.json(await getDojoClient(guild, 0, componentId));
|
||||
};
|
||||
|
@ -12,7 +12,7 @@ export const setDojoComponentMessageController: RequestHandler = async (req, res
|
||||
component.Message = payload.Message;
|
||||
}
|
||||
await guild.save();
|
||||
res.json(getDojoClient(guild, 0, component._id));
|
||||
res.json(await getDojoClient(guild, 0, component._id));
|
||||
};
|
||||
|
||||
type SetDojoComponentMessageRequest = { Name: string } | { Message: string };
|
||||
|
@ -29,12 +29,13 @@ 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
|
||||
pp: request.PlacedComponent.pp,
|
||||
DecoCapacity: room?.decoCapacity
|
||||
}) - 1
|
||||
];
|
||||
if (config.noDojoRoomBuildStage) {
|
||||
component.CompletionTime = new Date(Date.now());
|
||||
}
|
||||
await guild.save();
|
||||
res.json(getDojoClient(guild, 0));
|
||||
res.json(await getDojoClient(guild, 0));
|
||||
};
|
||||
|
@ -2,12 +2,23 @@ import {
|
||||
IGuildDatabase,
|
||||
IDojoComponentDatabase,
|
||||
ITechProjectDatabase,
|
||||
ITechProjectClient
|
||||
ITechProjectClient,
|
||||
IDojoDecoDatabase
|
||||
} 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,
|
||||
@ -18,7 +29,10 @@ const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
||||
Message: String,
|
||||
RegularCredits: Number,
|
||||
MiscItems: { type: [typeCountSchema], default: undefined },
|
||||
CompletionTime: Date
|
||||
CompletionTime: Date,
|
||||
DestructionTime: Date,
|
||||
Decos: [dojoDecoSchema],
|
||||
DecoCapacity: Number
|
||||
});
|
||||
|
||||
const techProjectSchema = new Schema<ITechProjectDatabase>(
|
||||
|
@ -1,6 +1,7 @@
|
||||
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";
|
||||
@ -16,6 +17,7 @@ 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";
|
||||
@ -59,6 +61,7 @@ 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";
|
||||
@ -103,6 +106,7 @@ 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);
|
||||
@ -150,6 +154,7 @@ 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);
|
||||
@ -175,6 +180,7 @@ 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,6 +59,7 @@ interface IConfig {
|
||||
noDailyStandingLimits?: boolean;
|
||||
instantResourceExtractorDrones?: boolean;
|
||||
noDojoRoomBuildStage?: boolean;
|
||||
fastDojoRoomDestruction?: boolean;
|
||||
noDojoResearchCosts?: boolean;
|
||||
noDojoResearchTime?: boolean;
|
||||
spoofMasteryRank?: number;
|
||||
|
@ -6,6 +6,8 @@ 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);
|
||||
@ -28,11 +30,11 @@ export const getGuildForRequestEx = async (
|
||||
return guild;
|
||||
};
|
||||
|
||||
export const getDojoClient = (
|
||||
export const getDojoClient = async (
|
||||
guild: TGuildDatabaseDocument,
|
||||
status: number,
|
||||
componentId: Types.ObjectId | undefined = undefined
|
||||
): IDojoClient => {
|
||||
componentId: Types.ObjectId | string | undefined = undefined
|
||||
): Promise<IDojoClient> => {
|
||||
const dojo: IDojoClient = {
|
||||
_id: { $oid: guild._id.toString() },
|
||||
Name: guild.Name,
|
||||
@ -45,15 +47,16 @@ export const getDojoClient = (
|
||||
DojoRequestStatus: status,
|
||||
DojoComponents: []
|
||||
};
|
||||
const roomsToRemove: Types.ObjectId[] = [];
|
||||
guild.DojoComponents.forEach(dojoComponent => {
|
||||
if (!componentId || componentId == dojoComponent._id) {
|
||||
if (!componentId || dojoComponent._id.equals(componentId)) {
|
||||
const clientComponent: IDojoComponentClient = {
|
||||
id: toOid(dojoComponent._id),
|
||||
pf: dojoComponent.pf,
|
||||
ppf: dojoComponent.ppf,
|
||||
Name: dojoComponent.Name,
|
||||
Message: dojoComponent.Message,
|
||||
DecoCapacity: 600
|
||||
DecoCapacity: dojoComponent.DecoCapacity ?? 600
|
||||
};
|
||||
if (dojoComponent.pi) {
|
||||
clientComponent.pi = toOid(dojoComponent.pi);
|
||||
@ -62,13 +65,41 @@ export const getDojoClient = (
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
||||
@ -76,3 +107,33 @@ 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
|
||||
};
|
||||
|
@ -41,18 +41,33 @@ export interface IDojoComponentClient {
|
||||
CompletionTime?: IMongoDate;
|
||||
RushPlatinum?: number;
|
||||
DestructionTime?: IMongoDate;
|
||||
Decos?: IDojoDecoClient[];
|
||||
DecoCapacity?: number;
|
||||
}
|
||||
|
||||
export interface IDojoComponentDatabase
|
||||
extends Omit<
|
||||
IDojoComponentClient,
|
||||
"id" | "pi" | "CompletionTime" | "RushPlatinum" | "DestructionTime" | "DecoCapacity"
|
||||
> {
|
||||
extends Omit<IDojoComponentClient, "id" | "pi" | "CompletionTime" | "RushPlatinum" | "DestructionTime" | "Decos"> {
|
||||
_id: Types.ObjectId;
|
||||
pi?: Types.ObjectId;
|
||||
CompletionTime?: Date;
|
||||
//DestructionTime?: 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;
|
||||
}
|
||||
|
||||
export interface ITechProjectClient {
|
||||
@ -66,3 +81,9 @@ export interface ITechProjectClient {
|
||||
export interface ITechProjectDatabase extends Omit<ITechProjectClient, "CompletionDate"> {
|
||||
CompletionDate?: Date;
|
||||
}
|
||||
|
||||
export interface IDojoContributable {
|
||||
RegularCredits?: number;
|
||||
MiscItems?: IMiscItem[];
|
||||
CompletionTime?: Date;
|
||||
}
|
||||
|
@ -525,6 +525,10 @@
|
||||
<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,6 +111,7 @@ 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,3 +1,4 @@
|
||||
// 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`,
|
||||
@ -94,8 +95,6 @@ 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`,
|
||||
@ -113,6 +112,7 @@ 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,6 +112,7 @@ 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