feat: unveil riven with cipher
All checks were successful
Build / build (18) (push) Successful in 1m1s
Build / build (20) (push) Successful in 1m4s
Build / build (22) (push) Successful in 40s
Build / build (18) (pull_request) Successful in 1m2s
Build / build (22) (pull_request) Successful in 37s
Build / build (20) (pull_request) Successful in 1m5s
All checks were successful
Build / build (18) (push) Successful in 1m1s
Build / build (20) (push) Successful in 1m4s
Build / build (22) (push) Successful in 40s
Build / build (18) (pull_request) Successful in 1m2s
Build / build (22) (pull_request) Successful in 37s
Build / build (20) (pull_request) Successful in 1m5s
This commit is contained in:
parent
bcb0a46f41
commit
751ff8addb
57
src/controllers/api/completeRandomModChallengeController.ts
Normal file
57
src/controllers/api/completeRandomModChallengeController.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
|
||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||
import { IUnveiledRivenFingerprint, randomiseRivenStats } from "@/src/helpers/rivenFingerprintHelper";
|
||||
import { getRandomElement, getRandomInt } from "@/src/services/rngService";
|
||||
import { ExportUpgrades } from "warframe-public-export-plus";
|
||||
|
||||
export const completeRandomModChallengeController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const inventory = await getInventory(accountId);
|
||||
const request = getJSONfromString<ICompleteRandomModChallengeRequest>(String(req.body));
|
||||
let inventoryChanges: IInventoryChanges = {};
|
||||
|
||||
// Remove 20 plat or riven cipher
|
||||
if ((req.query.p as string) == "1") {
|
||||
inventoryChanges = { ...updateCurrency(inventory, 20, true) };
|
||||
} else {
|
||||
const miscItemChanges: IMiscItem[] = [
|
||||
{
|
||||
ItemType: "/Lotus/Types/Items/MiscItems/RivenIdentifier",
|
||||
ItemCount: -1
|
||||
}
|
||||
];
|
||||
addMiscItems(inventory, miscItemChanges);
|
||||
inventoryChanges.MiscItems = miscItemChanges;
|
||||
}
|
||||
|
||||
// Update riven fingerprint to a randomised unveiled state
|
||||
const upgrade = inventory.Upgrades.id(request.ItemId)!;
|
||||
const meta = ExportUpgrades[upgrade.ItemType];
|
||||
const fingerprint: IUnveiledRivenFingerprint = {
|
||||
compat: getRandomElement(meta.compatibleItems!),
|
||||
lim: 0,
|
||||
lvl: 0,
|
||||
lvlReq: getRandomInt(8, 16),
|
||||
rerolls: 0,
|
||||
pol: getRandomElement(["AP_ATTACK", "AP_DEFENSE", "AP_TACTIC"]),
|
||||
buffs: [],
|
||||
curses: []
|
||||
};
|
||||
randomiseRivenStats(meta, fingerprint);
|
||||
upgrade.UpgradeFingerprint = JSON.stringify(fingerprint);
|
||||
|
||||
await inventory.save();
|
||||
|
||||
res.json({
|
||||
InventoryChanges: inventoryChanges,
|
||||
Fingerprint: upgrade.UpgradeFingerprint
|
||||
});
|
||||
};
|
||||
|
||||
interface ICompleteRandomModChallengeRequest {
|
||||
ItemId: string;
|
||||
}
|
@ -3,6 +3,7 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { addMiscItems, getInventory } from "@/src/services/inventoryService";
|
||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||
import { IUnveiledRivenFingerprint, randomiseRivenStats } from "@/src/helpers/rivenFingerprintHelper";
|
||||
import { ExportUpgrades } from "warframe-public-export-plus";
|
||||
|
||||
export const rerollRandomModController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
@ -24,7 +25,7 @@ export const rerollRandomModController: RequestHandler = async (req, res) => {
|
||||
fingerprint.rerolls++;
|
||||
upgrade.UpgradeFingerprint = JSON.stringify(fingerprint);
|
||||
|
||||
randomiseRivenStats(upgrade.ItemType, fingerprint);
|
||||
randomiseRivenStats(ExportUpgrades[upgrade.ItemType], fingerprint);
|
||||
upgrade.PendingRerollFingerprint = JSON.stringify(fingerprint);
|
||||
|
||||
await inventory.save();
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { ExportUpgrades } from "warframe-public-export-plus";
|
||||
import { IUpgrade } from "warframe-public-export-plus";
|
||||
import { getRandomElement } from "../services/rngService";
|
||||
|
||||
export interface IUnveiledRivenFingerprint {
|
||||
compat: string;
|
||||
lim: number;
|
||||
lim: 0;
|
||||
lvl: number;
|
||||
lvlReq: 0;
|
||||
lvlReq: number;
|
||||
rerolls?: number;
|
||||
pol: string;
|
||||
buffs: IRivenStat[];
|
||||
@ -17,9 +17,7 @@ interface IRivenStat {
|
||||
Value: number;
|
||||
}
|
||||
|
||||
export const randomiseRivenStats = (randomModType: string, fingerprint: IUnveiledRivenFingerprint): void => {
|
||||
const meta = ExportUpgrades[randomModType];
|
||||
|
||||
export const randomiseRivenStats = (meta: IUpgrade, fingerprint: IUnveiledRivenFingerprint): void => {
|
||||
fingerprint.buffs = [];
|
||||
const numBuffs = 2 + Math.trunc(Math.random() * 2); // 2 or 3
|
||||
const buffEntries = meta.upgradeEntries!.filter(x => x.canBeBuff);
|
||||
|
@ -8,6 +8,7 @@ import { changeDojoRootController } from "@/src/controllers/api/changeDojoRootCo
|
||||
import { checkDailyMissionBonusController } from "@/src/controllers/api/checkDailyMissionBonusController";
|
||||
import { claimCompletedRecipeController } from "@/src/controllers/api/claimCompletedRecipeController";
|
||||
import { clearDialogueHistoryController } from "@/src/controllers/api/clearDialogueHistoryController";
|
||||
import { completeRandomModChallengeController } from "@/src/controllers/api/completeRandomModChallengeController";
|
||||
import { createGuildController } from "@/src/controllers/api/createGuildController";
|
||||
import { creditsController } from "@/src/controllers/api/creditsController";
|
||||
import { deleteSessionController } from "@/src/controllers/api/deleteSessionController";
|
||||
@ -133,6 +134,7 @@ apiRouter.post("/artifacts.php", artifactsController);
|
||||
apiRouter.post("/changeDojoRoot.php", changeDojoRootController);
|
||||
apiRouter.post("/claimCompletedRecipe.php", claimCompletedRecipeController);
|
||||
apiRouter.post("/clearDialogueHistory.php", clearDialogueHistoryController);
|
||||
apiRouter.post("/completeRandomModChallenge.php", completeRandomModChallengeController);
|
||||
apiRouter.post("/createGuild.php", createGuildController);
|
||||
apiRouter.post("/endlessXp.php", endlessXpController);
|
||||
apiRouter.post("/evolveWeapon.php", evolveWeaponController);
|
||||
|
Loading…
x
Reference in New Issue
Block a user