forked from OpenWF/SpaceNinjaServer
Compare commits
1 Commits
main
...
fusionpoin
Author | SHA1 | Date | |
---|---|---|---|
e3783d1b9c |
@ -1,4 +1,4 @@
|
|||||||
import { getInventory } from "@/src/services/inventoryService";
|
import { addFusionPoints, getInventory } from "@/src/services/inventoryService";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ export const claimLibraryDailyTaskRewardController: RequestHandler = async (req,
|
|||||||
}
|
}
|
||||||
syndicate.Standing += rewardStanding;
|
syndicate.Standing += rewardStanding;
|
||||||
|
|
||||||
inventory.FusionPoints += 80 * rewardQuantity;
|
addFusionPoints(inventory, 80 * rewardQuantity);
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
|
@ -2,7 +2,7 @@ import { toMongoDate } from "@/src/helpers/inventoryHelpers";
|
|||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { Guild } from "@/src/models/guildModel";
|
import { Guild } from "@/src/models/guildModel";
|
||||||
import { checkClanAscensionHasRequiredContributors } from "@/src/services/guildService";
|
import { checkClanAscensionHasRequiredContributors } from "@/src/services/guildService";
|
||||||
import { getInventory } from "@/src/services/inventoryService";
|
import { addFusionPoints, getInventory } from "@/src/services/inventoryService";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
@ -36,7 +36,7 @@ export const contributeGuildClassController: RequestHandler = async (req, res) =
|
|||||||
|
|
||||||
// Either way, endo is given to the contributor.
|
// Either way, endo is given to the contributor.
|
||||||
const inventory = await getInventory(accountId, "FusionPoints");
|
const inventory = await getInventory(accountId, "FusionPoints");
|
||||||
inventory.FusionPoints += guild.CeremonyEndo!;
|
addFusionPoints(inventory, guild.CeremonyEndo!);
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
|
@ -8,7 +8,8 @@ import {
|
|||||||
addConsumables,
|
addConsumables,
|
||||||
freeUpSlot,
|
freeUpSlot,
|
||||||
combineInventoryChanges,
|
combineInventoryChanges,
|
||||||
addCrewShipRawSalvage
|
addCrewShipRawSalvage,
|
||||||
|
addFusionPoints
|
||||||
} from "@/src/services/inventoryService";
|
} from "@/src/services/inventoryService";
|
||||||
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
import { ExportDojoRecipes } from "warframe-public-export-plus";
|
||||||
@ -69,7 +70,7 @@ export const sellController: RequestHandler = async (req, res) => {
|
|||||||
if (payload.SellCurrency == "SC_RegularCredits") {
|
if (payload.SellCurrency == "SC_RegularCredits") {
|
||||||
inventory.RegularCredits += payload.SellPrice;
|
inventory.RegularCredits += payload.SellPrice;
|
||||||
} else if (payload.SellCurrency == "SC_FusionPoints") {
|
} else if (payload.SellCurrency == "SC_FusionPoints") {
|
||||||
inventory.FusionPoints += payload.SellPrice;
|
addFusionPoints(inventory, payload.SellPrice);
|
||||||
} else if (payload.SellCurrency == "SC_PrimeBucks") {
|
} else if (payload.SellCurrency == "SC_PrimeBucks") {
|
||||||
addMiscItems(inventory, [
|
addMiscItems(inventory, [
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
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 { addFusionPoints, getInventory } from "@/src/services/inventoryService";
|
||||||
|
|
||||||
export const addCurrencyController: RequestHandler = async (req, res) => {
|
export const addCurrencyController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const inventory = await getInventory(accountId);
|
|
||||||
const request = req.body as IAddCurrencyRequest;
|
const request = req.body as IAddCurrencyRequest;
|
||||||
inventory[request.currency] += request.delta;
|
const inventory = await getInventory(accountId, request.currency);
|
||||||
|
if (request.currency == "FusionPoints") {
|
||||||
|
addFusionPoints(inventory, request.delta);
|
||||||
|
} else {
|
||||||
|
inventory[request.currency] += request.delta;
|
||||||
|
}
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
res.end();
|
res.end();
|
||||||
};
|
};
|
||||||
|
@ -580,7 +580,7 @@ export const addItem = async (
|
|||||||
}
|
}
|
||||||
if (typeName in ExportFusionBundles) {
|
if (typeName in ExportFusionBundles) {
|
||||||
const fusionPointsTotal = ExportFusionBundles[typeName].fusionPoints * quantity;
|
const fusionPointsTotal = ExportFusionBundles[typeName].fusionPoints * quantity;
|
||||||
inventory.FusionPoints += fusionPointsTotal;
|
addFusionPoints(inventory, fusionPointsTotal);
|
||||||
return {
|
return {
|
||||||
FusionPoints: fusionPointsTotal
|
FusionPoints: fusionPointsTotal
|
||||||
};
|
};
|
||||||
@ -1069,6 +1069,15 @@ export const updateCurrency = (
|
|||||||
return currencyChanges;
|
return currencyChanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const addFusionPoints = (inventory: TInventoryDatabaseDocument, add: number): number => {
|
||||||
|
if (inventory.FusionPoints + add > 2147483647) {
|
||||||
|
logger.warn(`capping FusionPoints balance at 2147483647`);
|
||||||
|
add = 2147483647 - inventory.FusionPoints;
|
||||||
|
}
|
||||||
|
inventory.FusionPoints += add;
|
||||||
|
return add;
|
||||||
|
};
|
||||||
|
|
||||||
const standingLimitBinToInventoryKey: Record<
|
const standingLimitBinToInventoryKey: Record<
|
||||||
Exclude<TStandingLimitBin, "STANDING_LIMIT_BIN_NONE">,
|
Exclude<TStandingLimitBin, "STANDING_LIMIT_BIN_NONE">,
|
||||||
keyof IDailyAffiliations
|
keyof IDailyAffiliations
|
||||||
|
@ -19,6 +19,7 @@ import {
|
|||||||
addCrewShipRawSalvage,
|
addCrewShipRawSalvage,
|
||||||
addEmailItem,
|
addEmailItem,
|
||||||
addFocusXpIncreases,
|
addFocusXpIncreases,
|
||||||
|
addFusionPoints,
|
||||||
addFusionTreasures,
|
addFusionTreasures,
|
||||||
addGearExpByCategory,
|
addGearExpByCategory,
|
||||||
addItem,
|
addItem,
|
||||||
@ -287,14 +288,14 @@ export const addMissionInventoryUpdates = async (
|
|||||||
addShipDecorations(inventory, value);
|
addShipDecorations(inventory, value);
|
||||||
break;
|
break;
|
||||||
case "FusionBundles": {
|
case "FusionBundles": {
|
||||||
let fusionPoints = 0;
|
let fusionPointsDelta = 0;
|
||||||
for (const fusionBundle of value) {
|
for (const fusionBundle of value) {
|
||||||
const fusionPointsTotal =
|
fusionPointsDelta += addFusionPoints(
|
||||||
ExportFusionBundles[fusionBundle.ItemType].fusionPoints * fusionBundle.ItemCount;
|
inventory,
|
||||||
inventory.FusionPoints += fusionPointsTotal;
|
ExportFusionBundles[fusionBundle.ItemType].fusionPoints * fusionBundle.ItemCount
|
||||||
fusionPoints += fusionPointsTotal;
|
);
|
||||||
}
|
}
|
||||||
inventoryChanges.FusionPoints = fusionPoints;
|
inventoryChanges.FusionPoints = fusionPointsDelta;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "EmailItems": {
|
case "EmailItems": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user