Merge branch 'main' of https://github.com/spaceninjaserver/SpaceNinjaServer
This commit is contained in:
commit
82f26f3e06
@ -14,7 +14,7 @@
|
|||||||
"unlockAllScans": true,
|
"unlockAllScans": true,
|
||||||
"unlockAllMissions": true,
|
"unlockAllMissions": true,
|
||||||
"unlockAllQuests": true,
|
"unlockAllQuests": true,
|
||||||
"completeAllQuests": false,
|
"completeAllQuests": true,
|
||||||
"infiniteCredits": true,
|
"infiniteCredits": true,
|
||||||
"infinitePlatinum": true,
|
"infinitePlatinum": true,
|
||||||
"unlockAllShipFeatures": true,
|
"unlockAllShipFeatures": true,
|
||||||
|
@ -3,9 +3,8 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
|
|||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
import { Guild } from "@/src/models/guildModel";
|
import { Guild } from "@/src/models/guildModel";
|
||||||
import { ICreateGuildRequest } from "@/src/types/guildTypes";
|
|
||||||
|
|
||||||
const createGuildController: RequestHandler = async (req, res) => {
|
export const createGuildController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const payload = getJSONfromString(String(req.body)) as ICreateGuildRequest;
|
const payload = getJSONfromString(String(req.body)) as ICreateGuildRequest;
|
||||||
|
|
||||||
@ -34,4 +33,6 @@ const createGuildController: RequestHandler = async (req, res) => {
|
|||||||
res.json(guild);
|
res.json(guild);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { createGuildController };
|
interface ICreateGuildRequest {
|
||||||
|
guildName: string;
|
||||||
|
}
|
||||||
|
@ -1,31 +1,48 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { getInventory } from "@/src/services/inventoryService";
|
import { addMiscItems, getInventory } from "@/src/services/inventoryService";
|
||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { WeaponTypeInternal } from "@/src/services/itemDataService";
|
import { getRecipe, WeaponTypeInternal } from "@/src/services/itemDataService";
|
||||||
import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||||
|
|
||||||
export const evolveWeaponController: RequestHandler = async (req, res) => {
|
export const evolveWeaponController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
const payload = getJSONfromString(String(req.body)) as IEvolveWeaponRequest;
|
const payload = getJSONfromString(String(req.body)) as IEvolveWeaponRequest;
|
||||||
console.assert(payload.Action == "EWA_INSTALL");
|
|
||||||
|
|
||||||
// TODO: We should remove the Genesis item & its resources, but currently we don't know these "recipes".
|
const recipe = getRecipe(payload.Recipe)!;
|
||||||
|
if (payload.Action == "EWA_INSTALL") {
|
||||||
|
addMiscItems(
|
||||||
|
inventory,
|
||||||
|
recipe.ingredients.map(x => ({ ItemType: x.ItemType, ItemCount: x.ItemCount * -1 }))
|
||||||
|
);
|
||||||
|
|
||||||
const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
|
const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
|
||||||
item.Features ??= 0;
|
item.Features ??= 0;
|
||||||
item.Features |= EquipmentFeatures.INCARNON_GENESIS;
|
item.Features |= EquipmentFeatures.INCARNON_GENESIS;
|
||||||
|
|
||||||
item.SkillTree = "0";
|
item.SkillTree = "0";
|
||||||
|
|
||||||
inventory.EvolutionProgress ??= [];
|
inventory.EvolutionProgress ??= [];
|
||||||
if (!inventory.EvolutionProgress.find(entry => entry.ItemType == payload.EvoType)) {
|
if (!inventory.EvolutionProgress.find(entry => entry.ItemType == payload.EvoType)) {
|
||||||
inventory.EvolutionProgress.push({
|
inventory.EvolutionProgress.push({
|
||||||
Progress: 0,
|
Progress: 0,
|
||||||
Rank: 1,
|
Rank: 1,
|
||||||
ItemType: payload.EvoType
|
ItemType: payload.EvoType
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
} else if (payload.Action == "EWA_UNINSTALL") {
|
||||||
|
addMiscItems(inventory, [
|
||||||
|
{
|
||||||
|
ItemType: recipe.resultType,
|
||||||
|
ItemCount: 1
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
const item = inventory[payload.Category].find(item => item._id.toString() == (req.query.ItemId as string))!;
|
||||||
|
item.Features! &= ~EquipmentFeatures.INCARNON_GENESIS;
|
||||||
|
} else {
|
||||||
|
throw new Error(`unexpected evolve weapon action: ${payload.Action}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
@ -33,7 +50,7 @@ export const evolveWeaponController: RequestHandler = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface IEvolveWeaponRequest {
|
interface IEvolveWeaponRequest {
|
||||||
Action: "EWA_INSTALL";
|
Action: string;
|
||||||
Category: WeaponTypeInternal;
|
Category: WeaponTypeInternal;
|
||||||
Recipe: string; // e.g. "/Lotus/Types/Items/MiscItems/IncarnonAdapters/UnlockerBlueprints/DespairIncarnonBlueprint"
|
Recipe: string; // e.g. "/Lotus/Types/Items/MiscItems/IncarnonAdapters/UnlockerBlueprints/DespairIncarnonBlueprint"
|
||||||
UninstallRecipe: "";
|
UninstallRecipe: "";
|
||||||
|
@ -1,5 +1,100 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
|
import { getGuildForRequestEx } from "@/src/services/guildService";
|
||||||
|
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
||||||
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
|
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
|
||||||
|
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
|
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||||
|
|
||||||
export const guildTechController: RequestHandler = (_req, res) => {
|
export const guildTechController: RequestHandler = async (req, res) => {
|
||||||
res.status(500).end(); // This is what I got for a fresh clan.
|
const accountId = await getAccountIdForRequest(req);
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
const guild = await getGuildForRequestEx(req, inventory);
|
||||||
|
const data = JSON.parse(String(req.body)) as TGuildTechRequest;
|
||||||
|
if (data.Action == "Sync") {
|
||||||
|
res.json({
|
||||||
|
TechProjects: guild.toJSON().TechProjects
|
||||||
|
});
|
||||||
|
} else if (data.Action == "Start") {
|
||||||
|
const recipe = ExportDojoRecipes.research[data.RecipeType!];
|
||||||
|
guild.TechProjects ??= [];
|
||||||
|
if (!guild.TechProjects.find(x => x.ItemType == data.RecipeType)) {
|
||||||
|
guild.TechProjects.push({
|
||||||
|
ItemType: data.RecipeType!,
|
||||||
|
ReqCredits: scaleRequiredCount(recipe.price),
|
||||||
|
ReqItems: recipe.ingredients.map(x => ({
|
||||||
|
ItemType: x.ItemType,
|
||||||
|
ItemCount: scaleRequiredCount(x.ItemCount)
|
||||||
|
})),
|
||||||
|
State: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await guild.save();
|
||||||
|
res.end();
|
||||||
|
} else if (data.Action == "Contribute") {
|
||||||
|
const contributions = data as IGuildTechContributeFields;
|
||||||
|
const techProject = guild.TechProjects!.find(x => x.ItemType == contributions.RecipeType)!;
|
||||||
|
if (contributions.RegularCredits > techProject.ReqCredits) {
|
||||||
|
contributions.RegularCredits = techProject.ReqCredits;
|
||||||
|
}
|
||||||
|
techProject.ReqCredits -= contributions.RegularCredits;
|
||||||
|
const miscItemChanges = [];
|
||||||
|
for (const miscItem of contributions.MiscItems) {
|
||||||
|
const reqItem = techProject.ReqItems.find(x => x.ItemType == miscItem.ItemType);
|
||||||
|
if (reqItem) {
|
||||||
|
if (miscItem.ItemCount > reqItem.ItemCount) {
|
||||||
|
miscItem.ItemCount = reqItem.ItemCount;
|
||||||
|
}
|
||||||
|
reqItem.ItemCount -= miscItem.ItemCount;
|
||||||
|
miscItemChanges.push({
|
||||||
|
ItemType: miscItem.ItemType,
|
||||||
|
ItemCount: miscItem.ItemCount * -1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addMiscItems(inventory, miscItemChanges);
|
||||||
|
const inventoryChanges: IInventoryChanges = {
|
||||||
|
...updateCurrency(inventory, contributions.RegularCredits, false),
|
||||||
|
MiscItems: miscItemChanges
|
||||||
|
};
|
||||||
|
|
||||||
|
if (techProject.ReqCredits == 0 && !techProject.ReqItems.find(x => x.ItemCount > 0)) {
|
||||||
|
// This research is now fully funded.
|
||||||
|
techProject.State = 1;
|
||||||
|
const recipe = ExportDojoRecipes.research[data.RecipeType!];
|
||||||
|
techProject.CompletionDate = new Date(new Date().getTime() + recipe.time * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
await guild.save();
|
||||||
|
await inventory.save();
|
||||||
|
res.json({
|
||||||
|
InventoryChanges: inventoryChanges
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw new Error(`unknown guildTech action: ${data.Action}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
type TGuildTechRequest = {
|
||||||
|
Action: string;
|
||||||
|
} & Partial<IGuildTechStartFields> &
|
||||||
|
Partial<IGuildTechContributeFields>;
|
||||||
|
|
||||||
|
interface IGuildTechStartFields {
|
||||||
|
Mode: "Guild";
|
||||||
|
RecipeType: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGuildTechContributeFields {
|
||||||
|
ResearchId: "";
|
||||||
|
RecipeType: string;
|
||||||
|
RegularCredits: number;
|
||||||
|
MiscItems: IMiscItem[];
|
||||||
|
VaultCredits: number;
|
||||||
|
VaultMiscItems: IMiscItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { getInventory, addMiscItems } from "@/src/services/inventoryService";
|
import { getInventory, addMiscItems, updateCurrency, addRecipes } from "@/src/services/inventoryService";
|
||||||
import { IOid } from "@/src/types/commonTypes";
|
import { IOid } from "@/src/types/commonTypes";
|
||||||
import { IInfestedFoundry, IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
import {
|
||||||
import { ExportMisc } from "warframe-public-export-plus";
|
IConsumedSuit,
|
||||||
|
IInfestedFoundry,
|
||||||
|
IInventoryDatabaseDocument,
|
||||||
|
IMiscItem,
|
||||||
|
ITypeCount
|
||||||
|
} from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
|
import { ExportMisc, ExportRecipes } from "warframe-public-export-plus";
|
||||||
|
import { getRecipe } from "@/src/services/itemDataService";
|
||||||
|
|
||||||
export const infestedFoundryController: RequestHandler = async (req, res) => {
|
export const infestedFoundryController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
@ -110,6 +117,67 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
|
|||||||
res.status(404).end();
|
res.status(404).end();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "a": {
|
||||||
|
// subsume warframe
|
||||||
|
const request = getJSONfromString(String(req.body)) as IHelminthSubsumeRequest;
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
const recipe = getRecipe(request.Recipe)!;
|
||||||
|
for (const ingredient of recipe.secretIngredients!) {
|
||||||
|
const resource = inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType);
|
||||||
|
if (resource) {
|
||||||
|
resource.Count -= ingredient.ItemCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const suit = inventory.Suits.find(x => x._id.toString() == request.SuitId.$oid)!;
|
||||||
|
inventory.Suits.pull(suit);
|
||||||
|
const consumedSuit: IConsumedSuit = { s: suit.ItemType };
|
||||||
|
if (suit.Configs && suit.Configs[0] && suit.Configs[0].pricol) {
|
||||||
|
consumedSuit.c = suit.Configs[0].pricol;
|
||||||
|
}
|
||||||
|
inventory.InfestedFoundry!.Slots!--;
|
||||||
|
inventory.InfestedFoundry!.ConsumedSuits ??= [];
|
||||||
|
inventory.InfestedFoundry!.ConsumedSuits?.push(consumedSuit);
|
||||||
|
inventory.InfestedFoundry!.LastConsumedSuit = suit;
|
||||||
|
inventory.InfestedFoundry!.AbilityOverrideUnlockCooldown = new Date(
|
||||||
|
new Date().getTime() + 24 * 60 * 60 * 1000
|
||||||
|
);
|
||||||
|
addInfestedFoundryXP(inventory.InfestedFoundry!, 1600_00);
|
||||||
|
await inventory.save();
|
||||||
|
console.log(inventory.toJSON().InfestedFoundry);
|
||||||
|
res.json({
|
||||||
|
InventoryChanges: {
|
||||||
|
RemovedIdItems: [
|
||||||
|
{
|
||||||
|
ItemId: request.SuitId
|
||||||
|
}
|
||||||
|
],
|
||||||
|
SuitBin: {
|
||||||
|
count: -1,
|
||||||
|
platinum: 0,
|
||||||
|
Slots: 1
|
||||||
|
},
|
||||||
|
InfestedFoundry: inventory.toJSON().InfestedFoundry
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case "r": {
|
||||||
|
// rush subsume
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
const currencyChanges = updateCurrency(inventory, 50, true);
|
||||||
|
const recipeChanges = handleSubsumeCompletion(inventory);
|
||||||
|
await inventory.save();
|
||||||
|
res.json({
|
||||||
|
InventoryChanges: {
|
||||||
|
...currencyChanges,
|
||||||
|
Recipes: recipeChanges,
|
||||||
|
InfestedFoundry: inventory.toJSON().InfestedFoundry
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`unhandled infestedFoundry mode: ${String(req.query.mode)}`);
|
throw new Error(`unhandled infestedFoundry mode: ${String(req.query.mode)}`);
|
||||||
}
|
}
|
||||||
@ -165,3 +233,26 @@ const addInfestedFoundryXP = (infestedFoundry: IInfestedFoundry, delta: number):
|
|||||||
infestedFoundry.Slots += 20;
|
infestedFoundry.Slots += 20;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface IHelminthSubsumeRequest {
|
||||||
|
SuitId: IOid;
|
||||||
|
Recipe: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const handleSubsumeCompletion = (inventory: IInventoryDatabaseDocument): ITypeCount[] => {
|
||||||
|
const [recipeType] = Object.entries(ExportRecipes).find(
|
||||||
|
([_recipeType, recipe]) =>
|
||||||
|
recipe.secretIngredientAction == "SIA_WARFRAME_ABILITY" &&
|
||||||
|
recipe.secretIngredients![0].ItemType == inventory.InfestedFoundry!.LastConsumedSuit!.ItemType
|
||||||
|
)!;
|
||||||
|
inventory.InfestedFoundry!.LastConsumedSuit = undefined;
|
||||||
|
inventory.InfestedFoundry!.AbilityOverrideUnlockCooldown = undefined;
|
||||||
|
const recipeChanges: ITypeCount[] = [
|
||||||
|
{
|
||||||
|
ItemType: recipeType,
|
||||||
|
ItemCount: 1
|
||||||
|
}
|
||||||
|
];
|
||||||
|
addRecipes(inventory, recipeChanges);
|
||||||
|
return recipeChanges;
|
||||||
|
};
|
||||||
|
@ -5,7 +5,7 @@ import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
|||||||
import { config } from "@/src/services/configService";
|
import { config } from "@/src/services/configService";
|
||||||
import allDialogue from "@/static/fixed_responses/allDialogue.json";
|
import allDialogue from "@/static/fixed_responses/allDialogue.json";
|
||||||
import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
|
import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
|
||||||
import { IShipInventory, equipmentKeys } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { IInventoryDatabaseDocument, IShipInventory, equipmentKeys } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { IPolarity, ArtifactPolarity } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
import { IPolarity, ArtifactPolarity } from "@/src/types/inventoryTypes/commonInventoryTypes";
|
||||||
import {
|
import {
|
||||||
ExportCustoms,
|
ExportCustoms,
|
||||||
@ -15,6 +15,7 @@ import {
|
|||||||
ExportResources,
|
ExportResources,
|
||||||
ExportVirtuals
|
ExportVirtuals
|
||||||
} from "warframe-public-export-plus";
|
} from "warframe-public-export-plus";
|
||||||
|
import { handleSubsumeCompletion } from "./infestedFoundryController";
|
||||||
|
|
||||||
export const inventoryController: RequestHandler = async (request, response) => {
|
export const inventoryController: RequestHandler = async (request, response) => {
|
||||||
let account;
|
let account;
|
||||||
@ -57,6 +58,15 @@ export const inventoryController: RequestHandler = async (request, response) =>
|
|||||||
await inventory.save();
|
await inventory.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
inventory.InfestedFoundry &&
|
||||||
|
inventory.InfestedFoundry.AbilityOverrideUnlockCooldown &&
|
||||||
|
new Date() >= inventory.InfestedFoundry.AbilityOverrideUnlockCooldown
|
||||||
|
) {
|
||||||
|
handleSubsumeCompletion(inventory as unknown as IInventoryDatabaseDocument);
|
||||||
|
await inventory.save();
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: make a function that converts from database representation to client
|
//TODO: make a function that converts from database representation to client
|
||||||
const inventoryJSON = inventory.toJSON();
|
const inventoryJSON = inventory.toJSON();
|
||||||
|
|
||||||
|
@ -5,7 +5,11 @@ import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
|
|||||||
import { getInventory, updateCurrency, addEquipment, addMiscItems } from "@/src/services/inventoryService";
|
import { getInventory, updateCurrency, addEquipment, addMiscItems } from "@/src/services/inventoryService";
|
||||||
|
|
||||||
const modularWeaponTypes: Record<string, TEquipmentKey> = {
|
const modularWeaponTypes: Record<string, TEquipmentKey> = {
|
||||||
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary": "LongGuns",
|
||||||
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam": "LongGuns",
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam": "LongGuns",
|
||||||
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryLauncher": "LongGuns",
|
||||||
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryShotgun": "LongGuns",
|
||||||
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimarySniper": "LongGuns",
|
||||||
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary": "Pistols",
|
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary": "Pistols",
|
||||||
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": "Pistols",
|
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": "Pistols",
|
||||||
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": "Pistols",
|
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": "Pistols",
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
import { IGuildDatabase, IDojoComponentDatabase } from "@/src/types/guildTypes";
|
import {
|
||||||
|
IGuildDatabase,
|
||||||
|
IDojoComponentDatabase,
|
||||||
|
ITechProjectDatabase,
|
||||||
|
ITechProjectClient
|
||||||
|
} from "@/src/types/guildTypes";
|
||||||
import { model, Schema } from "mongoose";
|
import { model, Schema } from "mongoose";
|
||||||
|
import { typeCountSchema } from "./inventoryModels/inventoryModel";
|
||||||
|
import { toMongoDate } from "../helpers/inventoryHelpers";
|
||||||
|
|
||||||
const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
||||||
pf: { type: String, required: true },
|
pf: { type: String, required: true },
|
||||||
@ -10,12 +17,35 @@ const dojoComponentSchema = new Schema<IDojoComponentDatabase>({
|
|||||||
CompletionTime: Date
|
CompletionTime: Date
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const techProjectSchema = new Schema<ITechProjectDatabase>(
|
||||||
|
{
|
||||||
|
ItemType: String,
|
||||||
|
ReqCredits: Number,
|
||||||
|
ReqItems: [typeCountSchema],
|
||||||
|
State: Number,
|
||||||
|
CompletionDate: Date
|
||||||
|
},
|
||||||
|
{ _id: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
techProjectSchema.set("toJSON", {
|
||||||
|
virtuals: true,
|
||||||
|
transform(_doc, obj) {
|
||||||
|
const db = obj as ITechProjectDatabase;
|
||||||
|
const client = obj as ITechProjectClient;
|
||||||
|
if (db.CompletionDate) {
|
||||||
|
client.CompletionDate = toMongoDate(db.CompletionDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
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 },
|
DojoCapacity: { type: Number, default: 100 },
|
||||||
DojoEnergy: { type: Number, default: 5 }
|
DojoEnergy: { type: Number, default: 5 },
|
||||||
|
TechProjects: { type: [techProjectSchema], default: undefined }
|
||||||
},
|
},
|
||||||
{ id: false }
|
{ id: false }
|
||||||
);
|
);
|
||||||
|
@ -61,7 +61,7 @@ import {
|
|||||||
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
|
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
|
||||||
import { EquipmentSelectionSchema } from "./loadoutModel";
|
import { EquipmentSelectionSchema } from "./loadoutModel";
|
||||||
|
|
||||||
const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
|
export const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
|
||||||
|
|
||||||
const focusXPSchema = new Schema<IFocusXP>(
|
const focusXPSchema = new Schema<IFocusXP>(
|
||||||
{
|
{
|
||||||
@ -459,10 +459,13 @@ const settingsSchema = new Schema<ISettings>({
|
|||||||
TradingRulesConfirmed: Boolean
|
TradingRulesConfirmed: Boolean
|
||||||
});
|
});
|
||||||
|
|
||||||
const consumedSchuitsSchema = new Schema<IConsumedSuit>({
|
const consumedSchuitsSchema = new Schema<IConsumedSuit>(
|
||||||
s: String,
|
{
|
||||||
c: colorSchema
|
s: String,
|
||||||
});
|
c: colorSchema
|
||||||
|
},
|
||||||
|
{ _id: false }
|
||||||
|
);
|
||||||
|
|
||||||
const helminthResourceSchema = new Schema<IHelminthResource>({ ItemType: String, Count: Number }, { _id: false });
|
const helminthResourceSchema = new Schema<IHelminthResource>({ ItemType: String, Count: Number }, { _id: false });
|
||||||
|
|
||||||
@ -475,11 +478,22 @@ const infestedFoundrySchema = new Schema<IInfestedFoundry>(
|
|||||||
ConsumedSuits: { type: [consumedSchuitsSchema], default: undefined },
|
ConsumedSuits: { type: [consumedSchuitsSchema], default: undefined },
|
||||||
InvigorationIndex: Number,
|
InvigorationIndex: Number,
|
||||||
InvigorationSuitOfferings: { type: [String], default: undefined },
|
InvigorationSuitOfferings: { type: [String], default: undefined },
|
||||||
InvigorationsApplied: Number
|
InvigorationsApplied: Number,
|
||||||
|
LastConsumedSuit: { type: EquipmentSchema, default: undefined },
|
||||||
|
AbilityOverrideUnlockCooldown: Date
|
||||||
},
|
},
|
||||||
{ _id: false }
|
{ _id: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
infestedFoundrySchema.set("toJSON", {
|
||||||
|
transform(_doc, ret, _options) {
|
||||||
|
if (ret.AbilityOverrideUnlockCooldown) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
|
ret.AbilityOverrideUnlockCooldown = toMongoDate(ret.AbilityOverrideUnlockCooldown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const questProgressSchema = new Schema<IQuestProgress>({
|
const questProgressSchema = new Schema<IQuestProgress>({
|
||||||
c: Number,
|
c: Number,
|
||||||
i: Boolean,
|
i: Boolean,
|
||||||
|
@ -2,17 +2,22 @@ import { Request } from "express";
|
|||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { getInventory } from "@/src/services/inventoryService";
|
import { getInventory } from "@/src/services/inventoryService";
|
||||||
import { Guild } from "@/src/models/guildModel";
|
import { Guild } from "@/src/models/guildModel";
|
||||||
|
import { IInventoryDatabaseDocument } from "../types/inventoryTypes/inventoryTypes";
|
||||||
|
|
||||||
export const getGuildForRequest = async (req: Request) => {
|
export const getGuildForRequest = async (req: Request) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
|
return await getGuildForRequestEx(req, inventory);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getGuildForRequestEx = async (req: Request, inventory: IInventoryDatabaseDocument) => {
|
||||||
const guildId = req.query.guildId as string;
|
const guildId = req.query.guildId as string;
|
||||||
if (!inventory.GuildId || inventory.GuildId.toString() != guildId) {
|
if (!inventory.GuildId || inventory.GuildId.toString() != guildId) {
|
||||||
throw new Error("Account is not in the guild that it has sent a request for");
|
throw new Error("Account is not in the guild that it has sent a request for");
|
||||||
}
|
}
|
||||||
const guild = await Guild.findOne({ _id: guildId });
|
const guild = await Guild.findOne({ _id: guildId });
|
||||||
if (!guild) {
|
if (!guild) {
|
||||||
throw new Error("Account thinks it is a in guild that doesn't exist");
|
throw new Error("Account thinks it is in a guild that doesn't exist");
|
||||||
}
|
}
|
||||||
return guild;
|
return guild;
|
||||||
};
|
};
|
||||||
|
@ -178,7 +178,9 @@ export const handleInventoryItemConfigChange = async (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
logger.error(`category not implemented: ${equipmentName}`, { config: equipment });
|
logger.warn(`loadout category not implemented, changes may be lost: ${equipmentName}`, {
|
||||||
|
config: equipment
|
||||||
|
});
|
||||||
}
|
}
|
||||||
//case "KahlLoadOuts": not sure yet how to handle kahl: it is not sent in inventory
|
//case "KahlLoadOuts": not sure yet how to handle kahl: it is not sent in inventory
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,7 @@ export interface IGuildDatabase extends IGuild {
|
|||||||
DojoComponents?: IDojoComponentDatabase[];
|
DojoComponents?: IDojoComponentDatabase[];
|
||||||
DojoCapacity: number;
|
DojoCapacity: number;
|
||||||
DojoEnergy: number;
|
DojoEnergy: number;
|
||||||
}
|
TechProjects?: ITechProjectDatabase[];
|
||||||
|
|
||||||
export interface ICreateGuildRequest {
|
|
||||||
guildName: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDojoClient {
|
export interface IDojoClient {
|
||||||
@ -49,3 +46,15 @@ export interface IDojoComponentDatabase
|
|||||||
pi?: Types.ObjectId;
|
pi?: Types.ObjectId;
|
||||||
CompletionTime?: Date;
|
CompletionTime?: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ITechProjectClient {
|
||||||
|
ItemType: string;
|
||||||
|
ReqCredits: number;
|
||||||
|
ReqItems: IMiscItem[];
|
||||||
|
State: number; // 0 = pending, 1 = complete
|
||||||
|
CompletionDate?: IMongoDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ITechProjectDatabase extends Omit<ITechProjectClient, "CompletionDate"> {
|
||||||
|
CompletionDate?: Date;
|
||||||
|
}
|
||||||
|
@ -460,10 +460,7 @@ export interface IFlavourItem {
|
|||||||
ItemType: string;
|
ItemType: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMiscItem {
|
export type IMiscItem = ITypeCount;
|
||||||
ItemCount: number;
|
|
||||||
ItemType: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ICrewShipWeapon {
|
export interface ICrewShipWeapon {
|
||||||
PILOT: ICrewShipPilotWeapon;
|
PILOT: ICrewShipPilotWeapon;
|
||||||
@ -518,10 +515,13 @@ export interface IFusionTreasure {
|
|||||||
Sockets: number;
|
Sockets: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like ITypeCount except 'Count' instead of 'ItemCount'
|
|
||||||
export interface IHelminthResource {
|
export interface IHelminthResource {
|
||||||
ItemType: string;
|
ItemType: string;
|
||||||
Count: number;
|
Count: number;
|
||||||
|
RecentlyConvertedResources?: {
|
||||||
|
ItemType: string;
|
||||||
|
Date: number;
|
||||||
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IInfestedFoundry {
|
export interface IInfestedFoundry {
|
||||||
@ -533,6 +533,8 @@ export interface IInfestedFoundry {
|
|||||||
InvigorationIndex?: number;
|
InvigorationIndex?: number;
|
||||||
InvigorationSuitOfferings?: string[];
|
InvigorationSuitOfferings?: string[];
|
||||||
InvigorationsApplied?: number;
|
InvigorationsApplied?: number;
|
||||||
|
LastConsumedSuit?: IEquipmentDatabase;
|
||||||
|
AbilityOverrideUnlockCooldown?: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IConsumedSuit {
|
export interface IConsumedSuit {
|
||||||
|
@ -140,7 +140,11 @@ function fetchItemList() {
|
|||||||
"/Lotus/Weapons/Tenno/Rifle/LotusRifle": { name: "Rifle" },
|
"/Lotus/Weapons/Tenno/Rifle/LotusRifle": { name: "Rifle" },
|
||||||
"/Lotus/Weapons/Tenno/Shotgun/LotusShotgun": { name: "Shotgun" },
|
"/Lotus/Weapons/Tenno/Shotgun/LotusShotgun": { name: "Shotgun" },
|
||||||
// Modular weapons
|
// Modular weapons
|
||||||
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary": { name: "Kitgun" },
|
||||||
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam": { name: "Kitgun" },
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryBeam": { name: "Kitgun" },
|
||||||
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryLauncher": { name: "Kitgun" },
|
||||||
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimaryShotgun": { name: "Kitgun" },
|
||||||
|
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimarySniper": { name: "Kitgun" },
|
||||||
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary": { name: "Kitgun" },
|
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondary": { name: "Kitgun" },
|
||||||
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": { name: "Kitgun" },
|
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryBeam": { name: "Kitgun" },
|
||||||
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": { name: "Kitgun" },
|
"/Lotus/Weapons/SolarisUnited/Secondary/LotusModularSecondaryShotgun": { name: "Kitgun" },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user