diff --git a/src/Faction/Faction.ts b/src/Faction/Faction.ts
index 6604e8465..261aa23cb 100644
--- a/src/Faction/Faction.ts
+++ b/src/Faction/Faction.ts
@@ -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;
}
/**
diff --git a/src/Faction/formulas/favor.ts b/src/Faction/formulas/favor.ts
index f5c6d639c..04e615ebf 100644
--- a/src/Faction/formulas/favor.ts
+++ b/src/Faction/formulas/favor.ts
@@ -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.
}
diff --git a/src/Faction/ui/Info.tsx b/src/Faction/ui/Info.tsx
index f7c5617f8..55f403cbe 100644
--- a/src/Faction/ui/Info.tsx
+++ b/src/Faction/ui/Info.tsx
@@ -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 (
<>
{props.factionInfo.infoText}
@@ -54,15 +54,17 @@ export function Info(props: IProps): React.ReactElement {
title={
<>
- You will have faction favor after installing an
- Augmentation.
+ You will have faction favor after
+ installing an Augmentation.
{"\\(\\huge{r = \\text{total faction reputation}}\\)"}
- {"\\(\\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}\\)"
+ }
>
@@ -96,7 +98,7 @@ export function Info(props: IProps): React.ReactElement {
}
>
- Faction Favor:
+ Faction Favor:
diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts
index 6dbf25b15..e81c8bf14 100644
--- a/src/NetscriptFunctions/Singularity.ts
+++ b/src/NetscriptFunctions/Singularity.ts
@@ -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"));