mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-10 01:27:48 +02:00
DNET: Cache reward fixes (#2731)
This commit is contained in:
committed by
GitHub
parent
530392eeee
commit
15a67d0156
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user