feat: unveil riven with cipher #992
@ -2,8 +2,7 @@ import { RequestHandler } from "express";
 | 
				
			|||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
import { addMiscItems, 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 { ExportUpgrades } from "warframe-public-export-plus";
 | 
					import { IUnveiledRivenFingerprint, randomiseRivenStats } from "@/src/helpers/rivenFingerprintHelper";
 | 
				
			||||||
import { getRandomElement } from "@/src/services/rngService";
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const rerollRandomModController: RequestHandler = async (req, res) => {
 | 
					export const rerollRandomModController: RequestHandler = async (req, res) => {
 | 
				
			||||||
    const accountId = await getAccountIdForRequest(req);
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
@ -25,7 +24,7 @@ export const rerollRandomModController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
        fingerprint.rerolls++;
 | 
					        fingerprint.rerolls++;
 | 
				
			||||||
        upgrade.UpgradeFingerprint = JSON.stringify(fingerprint);
 | 
					        upgrade.UpgradeFingerprint = JSON.stringify(fingerprint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        randomiseStats(upgrade.ItemType, fingerprint);
 | 
					        randomiseRivenStats(upgrade.ItemType, fingerprint);
 | 
				
			||||||
        upgrade.PendingRerollFingerprint = JSON.stringify(fingerprint);
 | 
					        upgrade.PendingRerollFingerprint = JSON.stringify(fingerprint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await inventory.save();
 | 
					        await inventory.save();
 | 
				
			||||||
@ -52,28 +51,6 @@ export const rerollRandomModController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const randomiseStats = (randomModType: string, fingerprint: IUnveiledRivenFingerprint): void => {
 | 
					 | 
				
			||||||
    const meta = ExportUpgrades[randomModType];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fingerprint.buffs = [];
 | 
					 | 
				
			||||||
    const numBuffs = 2 + Math.trunc(Math.random() * 2); // 2 or 3
 | 
					 | 
				
			||||||
    const buffEntries = meta.upgradeEntries!.filter(x => x.canBeBuff);
 | 
					 | 
				
			||||||
    for (let i = 0; i != numBuffs; ++i) {
 | 
					 | 
				
			||||||
        const buffIndex = Math.trunc(Math.random() * buffEntries.length);
 | 
					 | 
				
			||||||
        const entry = buffEntries[buffIndex];
 | 
					 | 
				
			||||||
        fingerprint.buffs.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
 | 
					 | 
				
			||||||
        buffEntries.splice(buffIndex, 1);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    fingerprint.curses = [];
 | 
					 | 
				
			||||||
    if (Math.random() < 0.5) {
 | 
					 | 
				
			||||||
        const entry = getRandomElement(
 | 
					 | 
				
			||||||
            meta.upgradeEntries!.filter(x => x.canBeCurse && !fingerprint.buffs.find(y => y.Tag == x.tag))
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
        fingerprint.curses.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type RerollRandomModRequest = LetsGoGamblingRequest | AwDangitRequest;
 | 
					type RerollRandomModRequest = LetsGoGamblingRequest | AwDangitRequest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface LetsGoGamblingRequest {
 | 
					interface LetsGoGamblingRequest {
 | 
				
			||||||
@ -85,20 +62,4 @@ interface AwDangitRequest {
 | 
				
			|||||||
    CommitReroll: boolean;
 | 
					    CommitReroll: boolean;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IUnveiledRivenFingerprint {
 | 
					 | 
				
			||||||
    compat: string;
 | 
					 | 
				
			||||||
    lim: number;
 | 
					 | 
				
			||||||
    lvl: number;
 | 
					 | 
				
			||||||
    lvlReq: 0;
 | 
					 | 
				
			||||||
    rerolls?: number;
 | 
					 | 
				
			||||||
    pol: string;
 | 
					 | 
				
			||||||
    buffs: IRivenStat[];
 | 
					 | 
				
			||||||
    curses: IRivenStat[];
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
interface IRivenStat {
 | 
					 | 
				
			||||||
    Tag: string;
 | 
					 | 
				
			||||||
    Value: number;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const rerollCosts = [900, 1000, 1200, 1400, 1700, 2000, 2350, 2750, 3150];
 | 
					const rerollCosts = [900, 1000, 1200, 1400, 1700, 2000, 2350, 2750, 3150];
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										40
									
								
								src/helpers/rivenFingerprintHelper.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/helpers/rivenFingerprintHelper.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					import { ExportUpgrades } from "warframe-public-export-plus";
 | 
				
			||||||
 | 
					import { getRandomElement } from "../services/rngService";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IUnveiledRivenFingerprint {
 | 
				
			||||||
 | 
					    compat: string;
 | 
				
			||||||
 | 
					    lim: number;
 | 
				
			||||||
 | 
					    lvl: number;
 | 
				
			||||||
 | 
					    lvlReq: 0;
 | 
				
			||||||
 | 
					    rerolls?: number;
 | 
				
			||||||
 | 
					    pol: string;
 | 
				
			||||||
 | 
					    buffs: IRivenStat[];
 | 
				
			||||||
 | 
					    curses: IRivenStat[];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					interface IRivenStat {
 | 
				
			||||||
 | 
					    Tag: string;
 | 
				
			||||||
 | 
					    Value: number;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const randomiseRivenStats = (randomModType: string, fingerprint: IUnveiledRivenFingerprint): void => {
 | 
				
			||||||
 | 
					    const meta = ExportUpgrades[randomModType];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fingerprint.buffs = [];
 | 
				
			||||||
 | 
					    const numBuffs = 2 + Math.trunc(Math.random() * 2); // 2 or 3
 | 
				
			||||||
 | 
					    const buffEntries = meta.upgradeEntries!.filter(x => x.canBeBuff);
 | 
				
			||||||
 | 
					    for (let i = 0; i != numBuffs; ++i) {
 | 
				
			||||||
 | 
					        const buffIndex = Math.trunc(Math.random() * buffEntries.length);
 | 
				
			||||||
 | 
					        const entry = buffEntries[buffIndex];
 | 
				
			||||||
 | 
					        fingerprint.buffs.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
 | 
				
			||||||
 | 
					        buffEntries.splice(buffIndex, 1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fingerprint.curses = [];
 | 
				
			||||||
 | 
					    if (Math.random() < 0.5) {
 | 
				
			||||||
 | 
					        const entry = getRandomElement(
 | 
				
			||||||
 | 
					            meta.upgradeEntries!.filter(x => x.canBeCurse && !fingerprint.buffs.find(y => y.Tag == x.tag))
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					        fingerprint.curses.push({ Tag: entry.tag, Value: Math.trunc(Math.random() * 0x40000000) });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user