mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-08 22:37:37 +01:00
get rid of rollover rep
This commit is contained in:
parent
ec76c2ecca
commit
f8917473f8
@ -39,12 +39,6 @@ export class Faction {
|
||||
*/
|
||||
playerReputation = 0;
|
||||
|
||||
/**
|
||||
* Reputation from the last "prestige" that was not converted to favor.
|
||||
* This reputation rolls over and is used for the next favor calculation
|
||||
*/
|
||||
rolloverRep = 0;
|
||||
|
||||
constructor(name = "") {
|
||||
this.name = name;
|
||||
}
|
||||
@ -64,31 +58,18 @@ export class Faction {
|
||||
if (this.favor == null) {
|
||||
this.favor = 0;
|
||||
}
|
||||
if (this.rolloverRep == null) {
|
||||
this.rolloverRep = 0;
|
||||
}
|
||||
const res = this.getFavorGain();
|
||||
if (res.length !== 2) {
|
||||
console.error("Invalid result from getFavorGain() function");
|
||||
return;
|
||||
}
|
||||
this.favor += res[0];
|
||||
this.rolloverRep = res[1];
|
||||
this.favor += this.getFavorGain();
|
||||
}
|
||||
|
||||
//Returns an array with [How much favor would be gained, how much rep would be left over]
|
||||
getFavorGain(): number[] {
|
||||
getFavorGain(): number {
|
||||
if (this.favor == null) {
|
||||
this.favor = 0;
|
||||
}
|
||||
if (this.rolloverRep == null) {
|
||||
this.rolloverRep = 0;
|
||||
}
|
||||
const storedRep = Math.max(0, favorToRep(this.favor - 1));
|
||||
const totalRep = storedRep + this.rolloverRep + this.playerReputation;
|
||||
const newFavor = Math.floor(repToFavor(totalRep));
|
||||
const newRep = favorToRep(newFavor);
|
||||
return [newFavor - this.favor + 1, totalRep - newRep];
|
||||
const storedRep = Math.max(0, favorToRep(this.favor));
|
||||
const totalRep = storedRep + this.playerReputation;
|
||||
const newFavor = repToFavor(totalRep);
|
||||
return newFavor - this.favor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,11 +9,13 @@ export function favorToRep(f: number): number {
|
||||
function fma(a: number, b: number, c: number): number {
|
||||
return a * b + c;
|
||||
}
|
||||
const ex = fma(f, Math.log(51.0) - Math.log(50.0), Math.log(51.0));
|
||||
return fma(500.0, Math.exp(ex), -25000.0);
|
||||
const ex = fma(f - 1, Math.log(51.0) - Math.log(50.0), Math.log(51.0));
|
||||
const raw = fma(500.0, Math.exp(ex), -25000.0);
|
||||
return Math.round(raw * 10000) / 10000; // round to make things easier.
|
||||
}
|
||||
|
||||
// Wolfram Alpha: 500 (50^(-n) 51^(n + 1) - 50) solve for n
|
||||
export function repToFavor(r: number): number {
|
||||
return -Math.log(25500 / (r + 25000)) / Math.log(51 / 50);
|
||||
const raw = Math.log((r + 25000) / 25500) / Math.log(1.02) + 1;
|
||||
return Math.round(raw * 10000) / 10000; // round to make things easier.
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ export function Info(props: IProps): React.ReactElement {
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
const favorGain = props.faction.getFavorGain()[0];
|
||||
const favorGain = props.faction.getFavorGain();
|
||||
return (
|
||||
<>
|
||||
<Typography classes={{ root: classes.noformat }}>{props.factionInfo.infoText}</Typography>
|
||||
@ -54,15 +54,17 @@ export function Info(props: IProps): React.ReactElement {
|
||||
title={
|
||||
<>
|
||||
<Typography>
|
||||
You will have <Favor favor={props.faction.favor + favorGain} /> faction favor after installing an
|
||||
Augmentation.
|
||||
You will have <Favor favor={Math.floor(props.faction.favor + favorGain)} /> faction favor after
|
||||
installing an Augmentation.
|
||||
</Typography>
|
||||
<MathJaxContext>
|
||||
<MathJax>{"\\(\\huge{r = \\text{total faction reputation}}\\)"}</MathJax>
|
||||
</MathJaxContext>
|
||||
<MathJaxContext>
|
||||
<MathJax>
|
||||
{"\\(\\huge{favor=\\left\\lfloor\\log_{1.02}\\left(\\frac{r+25000}{25500}\\right)\\right\\rfloor}\\)"}
|
||||
{
|
||||
"\\(\\huge{favor=1+\\left\\lfloor\\log_{1.02}\\left(\\frac{r+25000}{25500}\\right)\\right\\rfloor}\\)"
|
||||
}
|
||||
</MathJax>
|
||||
</MathJaxContext>
|
||||
</>
|
||||
@ -96,7 +98,7 @@ export function Info(props: IProps): React.ReactElement {
|
||||
}
|
||||
>
|
||||
<Typography>
|
||||
Faction Favor: <Favor favor={props.faction.favor} />
|
||||
Faction Favor: <Favor favor={Math.floor(props.faction.favor)} />
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
|
@ -908,7 +908,7 @@ export function NetscriptSingularity(
|
||||
helper.updateDynamicRam("getCompanyFavorGain", getRamCost("getCompanyFavorGain"));
|
||||
helper.checkSingularityAccess("getCompanyFavorGain", 2);
|
||||
const company = getCompany("getCompanyFavorGain", companyName);
|
||||
return company.getFavorGain()[0];
|
||||
return company.getFavorGain();
|
||||
},
|
||||
checkFactionInvitations: function (): any {
|
||||
helper.updateDynamicRam("checkFactionInvitations", getRamCost("checkFactionInvitations"));
|
||||
@ -1096,7 +1096,7 @@ export function NetscriptSingularity(
|
||||
helper.updateDynamicRam("getFactionFavorGain", getRamCost("getFactionFavorGain"));
|
||||
helper.checkSingularityAccess("getFactionFavorGain", 2);
|
||||
const faction = getFaction("getFactionFavorGain", name);
|
||||
return faction.getFavorGain()[0];
|
||||
return faction.getFavorGain();
|
||||
},
|
||||
donateToFaction: function (name: any, amt: any): any {
|
||||
helper.updateDynamicRam("donateToFaction", getRamCost("donateToFaction"));
|
||||
|
Loading…
Reference in New Issue
Block a user