simplify getNemesisPasscode API

This commit is contained in:
Sainan 2025-04-12 19:23:23 +02:00
parent 5c6b4b5779
commit f1d0a5591f
2 changed files with 4 additions and 4 deletions

View File

@ -49,7 +49,7 @@ export const nemesisController: RequestHandler = async (req, res) => {
} else if ((req.query.mode as string) == "p") { } else if ((req.query.mode as string) == "p") {
const inventory = await getInventory(accountId, "Nemesis"); const inventory = await getInventory(accountId, "Nemesis");
const body = getJSONfromString<INemesisPrespawnCheckRequest>(String(req.body)); const body = getJSONfromString<INemesisPrespawnCheckRequest>(String(req.body));
const passcode = getNemesisPasscode(inventory.Nemesis!.fp, inventory.Nemesis!.Faction); const passcode = getNemesisPasscode(inventory.Nemesis!);
let guessResult = 0; let guessResult = 0;
if (inventory.Nemesis!.Faction == "FC_INFESTATION") { if (inventory.Nemesis!.Faction == "FC_INFESTATION") {
for (let i = 0; i != 3; ++i) { for (let i = 0; i != 3; ++i) {

View File

@ -33,10 +33,10 @@ const systemIndexes: Record<string, number[]> = {
}; };
// Get a parazon 'passcode' based on the nemesis fingerprint so it's always the same for the same nemesis. // Get a parazon 'passcode' based on the nemesis fingerprint so it's always the same for the same nemesis.
export const getNemesisPasscode = (fp: bigint, faction: string): number[] => { export const getNemesisPasscode = (nemesis: { fp: bigint; Faction: string }): number[] => {
const rng = new SRng(fp); const rng = new SRng(nemesis.fp);
const passcode = [rng.randomInt(0, 7)]; const passcode = [rng.randomInt(0, 7)];
if (faction != "FC_INFESTATION") { if (nemesis.Faction != "FC_INFESTATION") {
passcode.push(rng.randomInt(0, 7)); passcode.push(rng.randomInt(0, 7));
passcode.push(rng.randomInt(0, 7)); passcode.push(rng.randomInt(0, 7));
} }