mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-29 09:27:33 +01:00
fix miscalculation in growth formulas
This commit is contained in:
parent
3f5b412547
commit
83c159e901
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -45,7 +45,7 @@ export function safetlyCreateUniqueServer(params: IConstructorParams): Server {
|
||||
* @param p - Reference to Player object
|
||||
* @returns Number of "growth cycles" needed
|
||||
*/
|
||||
export function numCycleForGrowth(server: Server, growth: number, p: IPlayer): number {
|
||||
export function numCycleForGrowth(server: Server, growth: number, p: IPlayer, cores = 1): number {
|
||||
let ajdGrowthRate = 1 + (CONSTANTS.ServerBaseGrowthRate - 1) / server.hackDifficulty;
|
||||
if (ajdGrowthRate > CONSTANTS.ServerMaxGrowthRate) {
|
||||
ajdGrowthRate = CONSTANTS.ServerMaxGrowthRate;
|
||||
@ -53,9 +53,14 @@ export function numCycleForGrowth(server: Server, growth: number, p: IPlayer): n
|
||||
|
||||
const serverGrowthPercentage = server.serverGrowth / 100;
|
||||
|
||||
const coreBonus = 1 + (cores - 1) / 16;
|
||||
const cycles =
|
||||
Math.log(growth) /
|
||||
(Math.log(ajdGrowthRate) * p.hacking_grow_mult * serverGrowthPercentage * BitNodeMultipliers.ServerGrowthRate);
|
||||
(Math.log(ajdGrowthRate) *
|
||||
p.hacking_grow_mult *
|
||||
serverGrowthPercentage *
|
||||
BitNodeMultipliers.ServerGrowthRate *
|
||||
coreBonus);
|
||||
|
||||
return cycles;
|
||||
}
|
||||
@ -84,7 +89,7 @@ export function processSingleServerGrowth(server: Server, threads: number, p: IP
|
||||
// if there was any growth at all, increase security
|
||||
if (oldMoneyAvailable !== server.moneyAvailable) {
|
||||
//Growing increases server security twice as much as hacking
|
||||
let usedCycles = numCycleForGrowth(server, server.moneyAvailable / oldMoneyAvailable, p);
|
||||
let usedCycles = numCycleForGrowth(server, server.moneyAvailable / oldMoneyAvailable, p, cores);
|
||||
usedCycles = Math.max(0, usedCycles);
|
||||
server.fortify(2 * CONSTANTS.ServerFortifyAmount * Math.ceil(usedCycles));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user