DNET: Cache reward fixes (#2731)

This commit is contained in:
Michael Ficocelli
2026-05-05 15:56:02 -07:00
committed by GitHub
parent 530392eeee
commit 15a67d0156
2 changed files with 62 additions and 6 deletions
+14 -5
View File
@@ -12,6 +12,7 @@ import type { DarknetServer } from "../../Server/DarknetServer";
import { resolveCacheFilePath } from "../../Paths/CacheFilePath";
import type { CacheResult } from "@nsdefs";
import { addClue, cctCooldownReached } from "./effects";
import { getBitNodeMultipliers } from "../../BitNode/BitNode";
export const generateCacheFilename = (isPhishingCache: boolean, prefix?: string) => {
const filenamePrefix = prefix ?? cachePrefixes[Math.floor(Math.random() * cachePrefixes.length)];
@@ -41,11 +42,15 @@ export const getRewardFromCache = (server: DarknetServer, cacheName: string, sup
};
}
const rewards = [getMoneyReward, getProgramAndStockMarketRelatedRewards, getStockReward, getDataFileReward];
const rewards = [getProgramAndStockMarketRelatedRewards, getStockReward, getDataFileReward];
if (cacheName.endsWith(".d.cache")) {
// only include ccts from caches generated from phishing attacks
rewards.push(getCCTReward);
}
if (getBitNodeMultipliers(Player.bitNodeN, 1).DarknetMoneyMultiplier) {
// only include money reward if it is not disabled by the bn mults
rewards.push(getMoneyReward);
}
const reward = rewards[Math.floor(Math.random() * rewards.length)];
const result = reward(difficulty, server);
@@ -98,10 +103,14 @@ export const getStockReward = (difficulty: number): string => {
initStockMarket();
}
const stockSymbols = Object.keys(StockSymbol);
const randomStock = stockSymbols[Math.floor(Math.random() * stockSymbols.length)];
const shares = Math.floor(1 + difficulty * 5 + Math.random() * 10);
StockMarket[randomStock].playerShares += shares;
return `You have discovered a stock option cache containing ${shares} shares of ${randomStock}!`;
const stock = StockMarket[stockSymbols[Math.floor(Math.random() * stockSymbols.length)]];
const maxNewShares = stock.maxShares - stock.playerShares - stock.playerShortShares;
if (maxNewShares <= 0) {
return getMoneyReward(difficulty);
}
const shares = Math.min(Math.floor(1 + difficulty * 5 + Math.random() * 10), maxNewShares);
stock.playerShares += shares;
return `You have discovered a stock option cache containing ${shares} shares of ${stock.symbol}!`;
};
export const getDataFileReward = (difficulty: number, server: DarknetServer): string => {