feat: dojo room energy & capacity costs & gains

This commit is contained in:
Sainan 2024-12-23 22:42:25 +01:00
parent eeaac6f07e
commit b0e6b843c3
7 changed files with 31 additions and 11 deletions

8
package-lock.json generated
View File

@ -12,7 +12,7 @@
"copyfiles": "^2.4.1",
"express": "^5",
"mongoose": "^8.9.2",
"warframe-public-export-plus": "^0.5.13",
"warframe-public-export-plus": "^0.5.14",
"warframe-riven-info": "^0.1.2",
"winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0"
@ -3877,9 +3877,9 @@
}
},
"node_modules/warframe-public-export-plus": {
"version": "0.5.13",
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.13.tgz",
"integrity": "sha512-iyiaEsgZGQMU29jDag+Pq1z2q0/Zj4bCzTMtoZCSFtNUiZOPYwzjBmbYsDN0FO/yUoHu2dboW0lEYsdaofTEDQ=="
"version": "0.5.14",
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.14.tgz",
"integrity": "sha512-G6Jrs1PoETheYQjN2Mm6qVZeiIS5h2U8e+nHC3fPDVhLz3gZkbZShDOTCJ3JNAlP1NFrFYoBqUc6gMmN0Z9Acg=="
},
"node_modules/warframe-riven-info": {
"version": "0.1.2",

View File

@ -16,7 +16,7 @@
"copyfiles": "^2.4.1",
"express": "^5",
"mongoose": "^8.9.2",
"warframe-public-export-plus": "^0.5.13",
"warframe-public-export-plus": "^0.5.14",
"warframe-riven-info": "^0.1.2",
"winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0"

View File

@ -33,8 +33,8 @@ export const getGuildDojoController: RequestHandler = async (req, res) => {
FixedContributions: true,
DojoRevision: 1,
RevisionTime: Math.round(Date.now() / 1000),
Energy: 5,
Capacity: 100,
Energy: guild.DojoEnergy,
Capacity: guild.DojoCapacity,
DojoRequestStatus: 0,
DojoComponents: []
};

View File

@ -1,13 +1,21 @@
import { 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!.splice(
const component = guild.DojoComponents!.splice(
guild.DojoComponents!.findIndex(x => x._id.toString() === componentId),
1
);
)[0];
if (component) {
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({
DojoRequestStatus: 1

View File

@ -2,6 +2,7 @@ import { RequestHandler } from "express";
import { IDojoComponentClient } from "@/src/types/guildTypes";
import { getGuildForRequest } from "@/src/services/guildService";
import { Types } from "mongoose";
import { ExportDojoRecipes } from "warframe-public-export-plus";
interface IStartDojoRecipeRequest {
PlacedComponent: IDojoComponentClient;
@ -12,6 +13,13 @@ export const startDojoRecipeController: RequestHandler = async (req, res) => {
const guild = await getGuildForRequest(req);
// At this point, we know that a member of the guild is making this request. Assuming they are allowed to start a build.
const request = JSON.parse(String(req.body)) as IStartDojoRecipeRequest;
const room = Object.values(ExportDojoRecipes.rooms).find(x => x.resultType == request.PlacedComponent.pf);
if (room) {
guild.DojoCapacity += room.capacity;
guild.DojoEnergy += room.energy;
}
guild.DojoComponents!.push({
_id: new Types.ObjectId(),
pf: request.PlacedComponent.pf,

View File

@ -13,7 +13,9 @@ const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
const guildSchema = new Schema<IGuildDatabase>(
{
Name: { type: String, required: true },
DojoComponents: [dojoComponentSchema]
DojoComponents: [dojoComponentSchema],
DojoCapacity: { type: Number, default: 100 },
DojoEnergy: { type: Number, default: 5 }
},
{ id: false }
);

View File

@ -9,6 +9,8 @@ export interface IGuild {
export interface IGuildDatabase extends IGuild {
_id: Types.ObjectId;
DojoComponents?: IDojoComponentDatabase[];
DojoCapacity: number;
DojoEnergy: number;
}
export interface ICreateGuildRequest {
@ -30,7 +32,7 @@ export interface IDojoClient {
export interface IDojoComponentClient {
id: IOid;
pf: string;
pf: string; // Prefab (.level)
ppf: string;
pi?: IOid; // Parent ID. N/A to root.
op?: string; // "Open Portal"? N/A to root.