feat: classic lich guess history
All checks were successful
Build / build (push) Successful in 48s
Build / build (pull_request) Successful in 2m17s

This commit is contained in:
Sainan 2025-06-07 12:14:17 +02:00
parent 93f345b89a
commit b97b9ef32c
3 changed files with 59 additions and 23 deletions

View File

@ -1,15 +1,19 @@
import { version_compare } from "@/src/helpers/inventoryHelpers";
import {
consumeModCharge,
decodeNemesisGuess,
encodeNemesisGuess,
getInfNodes,
getKnifeUpgrade,
getNemesisManifest,
getNemesisPasscode,
getNemesisPasscodeModTypes,
GUESS_CORRECT,
GUESS_INCORRECT,
GUESS_NEUTRAL,
GUESS_NONE,
GUESS_WILDCARD,
IKnifeResponse,
NemesisGuess
IKnifeResponse
} from "@/src/helpers/nemesisHelpers";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
@ -99,9 +103,9 @@ export const nemesisController: RequestHandler = async (req, res) => {
if (inventory.Nemesis!.Faction == "FC_INFESTATION") {
const guess: number[] = [body.guess & 0xf, (body.guess >> 4) & 0xf, (body.guess >> 8) & 0xf];
const passcode = getNemesisPasscode(inventory.Nemesis!)[0];
const result1 = passcode == guess[0] ? 0 : 1;
const result2 = passcode == guess[1] ? 0 : 1;
const result3 = passcode == guess[2] ? 0 : 1;
const result1 = passcode == guess[0] ? GUESS_CORRECT : GUESS_INCORRECT;
const result2 = passcode == guess[1] ? GUESS_CORRECT : GUESS_INCORRECT;
const result3 = passcode == guess[2] ? GUESS_CORRECT : GUESS_INCORRECT;
inventory.Nemesis!.GuessHistory.push(
encodeNemesisGuess([
{
@ -121,7 +125,7 @@ export const nemesisController: RequestHandler = async (req, res) => {
// Increase antivirus if correct antivirus mod is installed
const response: IKnifeResponse = {};
if (result1 == 0 || result2 == 0 || result3 == 0) {
if (result1 == GUESS_CORRECT || result2 == GUESS_CORRECT || result3 == GUESS_CORRECT) {
let antivirusGain = 5;
const loadout = (await Loadout.findById(inventory.LoadOutPresets, "DATAKNIFE"))!;
const dataknifeLoadout = loadout.DATAKNIFE.id(inventory.CurrentLoadOutIds[LoadoutIndex.DATAKNIFE].$oid);
@ -162,19 +166,47 @@ export const nemesisController: RequestHandler = async (req, res) => {
await inventory.save();
res.json(response);
} else {
let RankIncrease: number | undefined;
if (body.guess != GUESS_WILDCARD) {
const passcode = getNemesisPasscode(inventory.Nemesis!);
if (passcode[body.position] != body.guess) {
const manifest = getNemesisManifest(inventory.Nemesis!.manifest);
if (inventory.Nemesis!.Rank + 1 < manifest.systemIndexes.length) {
inventory.Nemesis!.Rank += 1;
RankIncrease = 1;
}
inventory.Nemesis!.InfNodes = getInfNodes(manifest, inventory.Nemesis!.Rank);
await inventory.save();
}
// For first guess, create a new entry.
if (body.position == 0) {
inventory.Nemesis!.GuessHistory.push(
encodeNemesisGuess([
{
symbol: GUESS_NONE,
result: GUESS_NEUTRAL
},
{
symbol: GUESS_NONE,
result: GUESS_NEUTRAL
},
{
symbol: GUESS_NONE,
result: GUESS_NEUTRAL
}
])
);
}
// Evaluate guess
const correct =
body.guess == GUESS_WILDCARD || getNemesisPasscode(inventory.Nemesis!)[body.position] == body.guess;
// Update entry
const guess = decodeNemesisGuess(
inventory.Nemesis!.GuessHistory[inventory.Nemesis!.GuessHistory.length - 1]
);
guess[body.position].symbol = body.guess;
guess[body.position].result = correct ? GUESS_CORRECT : GUESS_INCORRECT;
inventory.Nemesis!.GuessHistory[inventory.Nemesis!.GuessHistory.length - 1] = encodeNemesisGuess(guess);
// Increase rank if incorrect
let RankIncrease: number | undefined;
if (!correct) {
RankIncrease = 1;
const manifest = getNemesisManifest(inventory.Nemesis!.manifest);
inventory.Nemesis!.Rank = Math.min(inventory.Nemesis!.Rank + 1, manifest.systemIndexes.length - 1);
inventory.Nemesis!.InfNodes = getInfNodes(manifest, inventory.Nemesis!.Rank);
}
await inventory.save();
res.json({ RankIncrease });
}
} else if ((req.query.mode as string) == "rs") {

View File

@ -266,9 +266,15 @@ export const getNemesisPasscodeModTypes = (nemesis: { fp: bigint; Faction: TNeme
: passcode.map(i => requiemMods[i]);
};
// Symbols; 0-7 are the normal requiem mods.
export const GUESS_NONE = 8;
export const GUESS_WILDCARD = 9;
// Results; there are 3, 4, 5 as well which are more muted versions but unused afaik.
export const GUESS_NEUTRAL = 0;
export const GUESS_INCORRECT = 1;
export const GUESS_CORRECT = 2;
interface NemesisPositionGuess {
symbol: number;
result: number;

View File

@ -1182,14 +1182,12 @@ export const addMissionRewards = async (
if (nodeIndex !== -1) inventory.Nemesis.InfNodes.splice(nodeIndex, 1);
if (inventory.Nemesis.InfNodes.length <= 0) {
const manifest = getNemesisManifest(inventory.Nemesis.manifest);
if (inventory.Nemesis.Faction != "FC_INFESTATION") {
inventory.Nemesis.Rank = Math.min(inventory.Nemesis.Rank + 1, 4);
inventory.Nemesis.Rank = Math.min(inventory.Nemesis.Rank + 1, manifest.systemIndexes.length - 1);
inventoryChanges.Nemesis.Rank = inventory.Nemesis.Rank;
}
inventory.Nemesis.InfNodes = getInfNodes(
getNemesisManifest(inventory.Nemesis.manifest),
inventory.Nemesis.Rank
);
inventory.Nemesis.InfNodes = getInfNodes(manifest, inventory.Nemesis.Rank);
}
if (inventory.Nemesis.Faction == "FC_INFESTATION") {