mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
Merge pull request #2537 from nickofolas/parallelize-favor-gain
(Breaking change) Parallelize favor gain
This commit is contained in:
commit
59100e33e0
@ -1,7 +1,7 @@
|
|||||||
import { CompanyPosition } from "./CompanyPosition";
|
import { CompanyPosition } from "./CompanyPosition";
|
||||||
import * as posNames from "./data/companypositionnames";
|
import * as posNames from "./data/companypositionnames";
|
||||||
|
import { favorToRep, repToFavor } from "./formulas/favor";
|
||||||
|
|
||||||
import { CONSTANTS } from "../Constants";
|
|
||||||
import { IMap } from "../types";
|
import { IMap } from "../types";
|
||||||
|
|
||||||
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
|
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver";
|
||||||
@ -71,7 +71,6 @@ export class Company {
|
|||||||
isPlayerEmployed: boolean;
|
isPlayerEmployed: boolean;
|
||||||
playerReputation: number;
|
playerReputation: number;
|
||||||
favor: number;
|
favor: number;
|
||||||
rolloverRep: number;
|
|
||||||
|
|
||||||
constructor(p: IConstructorParams = DefaultConstructorParams) {
|
constructor(p: IConstructorParams = DefaultConstructorParams) {
|
||||||
this.name = p.name;
|
this.name = p.name;
|
||||||
@ -84,7 +83,6 @@ export class Company {
|
|||||||
this.isPlayerEmployed = false;
|
this.isPlayerEmployed = false;
|
||||||
this.playerReputation = 1;
|
this.playerReputation = 1;
|
||||||
this.favor = 0;
|
this.favor = 0;
|
||||||
this.rolloverRep = 0;
|
|
||||||
this.isMegacorp = false;
|
this.isMegacorp = false;
|
||||||
if (p.isMegacorp) this.isMegacorp = true;
|
if (p.isMegacorp) this.isMegacorp = true;
|
||||||
}
|
}
|
||||||
@ -137,39 +135,17 @@ export class Company {
|
|||||||
if (this.favor == null) {
|
if (this.favor == null) {
|
||||||
this.favor = 0;
|
this.favor = 0;
|
||||||
}
|
}
|
||||||
if (this.rolloverRep == null) {
|
this.favor += this.getFavorGain();
|
||||||
this.rolloverRep = 0;
|
|
||||||
}
|
|
||||||
const res = this.getFavorGain();
|
|
||||||
if (res.length != 2) {
|
|
||||||
console.error("Invalid result from getFavorGain() function");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.favor += res[0];
|
getFavorGain(): number {
|
||||||
this.rolloverRep = res[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
getFavorGain(): number[] {
|
|
||||||
if (this.favor == null) {
|
if (this.favor == null) {
|
||||||
this.favor = 0;
|
this.favor = 0;
|
||||||
}
|
}
|
||||||
if (this.rolloverRep == null) {
|
const storedRep = Math.max(0, favorToRep(this.favor));
|
||||||
this.rolloverRep = 0;
|
const totalRep = storedRep + this.playerReputation;
|
||||||
}
|
const newFavor = repToFavor(totalRep);
|
||||||
let favorGain = 0,
|
return newFavor - this.favor;
|
||||||
rep = this.playerReputation + this.rolloverRep;
|
|
||||||
let reqdRep = CONSTANTS.CompanyReputationToFavorBase * Math.pow(CONSTANTS.CompanyReputationToFavorMult, this.favor);
|
|
||||||
while (rep > 0) {
|
|
||||||
if (rep >= reqdRep) {
|
|
||||||
++favorGain;
|
|
||||||
rep -= reqdRep;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
reqdRep *= CONSTANTS.FactionReputationToFavorMult;
|
|
||||||
}
|
|
||||||
return [favorGain, rep];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
13
src/Company/formulas/favor.ts
Normal file
13
src/Company/formulas/favor.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// The initial formulas was sum 0 to f of 500*1.02^f.
|
||||||
|
// see https://en.wikipedia.org/wiki/Geometric_series#Closed-form_formula
|
||||||
|
// for information on how to calculate this
|
||||||
|
|
||||||
|
export function favorToRep(f: number): number {
|
||||||
|
const raw = 25000 * (Math.pow(1.02, f) - 1);
|
||||||
|
return Math.round(raw * 10000) / 10000; // round to make things easier.
|
||||||
|
}
|
||||||
|
|
||||||
|
export function repToFavor(r: number): number {
|
||||||
|
const raw = Math.log(r / 25000 + 1) / Math.log(1.02);
|
||||||
|
return Math.round(raw * 10000) / 10000; // round to make things easier.
|
||||||
|
}
|
@ -198,7 +198,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
|||||||
<Tooltip
|
<Tooltip
|
||||||
title={
|
title={
|
||||||
<>
|
<>
|
||||||
You will have <Favor favor={company.favor + favorGain[0]} /> company favor upon resetting after
|
You will have <Favor favor={company.favor + favorGain} /> company favor upon resetting after
|
||||||
installing Augmentations
|
installing Augmentations
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user