feat: dojo room energy & capacity costs & gains (#633)

This commit is contained in:
Sainan 2024-12-23 23:12:21 +01:00 committed by GitHub
parent 063adb3519
commit 7fdb59f6c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 31 additions and 11 deletions

8
package-lock.json generated
View File

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

View File

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

View File

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

View File

@ -1,13 +1,21 @@
import { getGuildForRequest } from "@/src/services/guildService"; import { getGuildForRequest } from "@/src/services/guildService";
import { RequestHandler } from "express"; import { RequestHandler } from "express";
import { ExportDojoRecipes } from "warframe-public-export-plus";
export const queueDojoComponentDestructionController: RequestHandler = async (req, res) => { export const queueDojoComponentDestructionController: RequestHandler = async (req, res) => {
const guild = await getGuildForRequest(req); const guild = await getGuildForRequest(req);
const componentId = req.query.componentId as string; const componentId = req.query.componentId as string;
guild.DojoComponents!.splice( const component = guild.DojoComponents!.splice(
guild.DojoComponents!.findIndex(x => x._id.toString() === componentId), guild.DojoComponents!.findIndex(x => x._id.toString() === componentId),
1 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(); await guild.save();
res.json({ res.json({
DojoRequestStatus: 1 DojoRequestStatus: 1

View File

@ -2,6 +2,7 @@ import { RequestHandler } from "express";
import { IDojoComponentClient } from "@/src/types/guildTypes"; import { IDojoComponentClient } from "@/src/types/guildTypes";
import { getGuildForRequest } from "@/src/services/guildService"; import { getGuildForRequest } from "@/src/services/guildService";
import { Types } from "mongoose"; import { Types } from "mongoose";
import { ExportDojoRecipes } from "warframe-public-export-plus";
interface IStartDojoRecipeRequest { interface IStartDojoRecipeRequest {
PlacedComponent: IDojoComponentClient; PlacedComponent: IDojoComponentClient;
@ -12,6 +13,13 @@ export const startDojoRecipeController: RequestHandler = async (req, res) => {
const guild = await getGuildForRequest(req); 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. // 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 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({ guild.DojoComponents!.push({
_id: new Types.ObjectId(), _id: new Types.ObjectId(),
pf: request.PlacedComponent.pf, pf: request.PlacedComponent.pf,

View File

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

View File

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