Fix 180 favor issue, reworked favor and reputation mathjax

This commit is contained in:
Olivier Gagnon 2021-09-03 17:12:55 -04:00
parent 5dd6145d53
commit cc9a07c09f
4 changed files with 18 additions and 6 deletions

File diff suppressed because one or more lines are too long

@ -2,8 +2,15 @@
// These formulas were derived on wolfram alpha.
// Wolfram Alpha: sum from 0 to n of 500*1.02^n
// 500 * ((pow(51, f+1)) / pow(50,f) - 50)
// Then we use https://herbie.uwplse.org/demo/ to simplify it and prevent
// Infinity issues.
export function favorToRep(f: number): number {
return 500 * ((Math.pow(51, f+1)) / Math.pow(50,f) - 50);
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);
}
// Wolfram Alpha: 500 (50^(-n) 51^(n + 1) - 50) solve for n

@ -41,7 +41,11 @@ export class Info extends React.Component<IProps, any> {
getFavorGainContent(): JSX.Element {
const favorGain = this.props.faction.getFavorGain()[0];
return <>You will earn {Favor(favorGain)} faction favor upon resetting after installing an Augmentation</>
return (<>
You will earn {Favor(favorGain)} faction favor upon resetting after installing an Augmentation
<MathComponent tex={String.raw`r = \text{total faction reputation}`} />
<MathComponent tex={String.raw`favor=\left\lfloor\log_{1.02}\left(\frac{r+25000}{25500}\right)\right\rfloor`} />
</>);
}
getReputationContent(): JSX.Element {
@ -54,10 +58,11 @@ export class Info extends React.Component<IProps, any> {
this faction by 1% per favor. Faction favor is gained whenever you
reset after installing an Augmentation. The amount of
favor you gain depends on how much reputation you have with the faction
<MathComponent tex={String.raw`r = \text{total faction reputation}`} />
<MathComponent tex={String.raw`\text{favor} = \frac{-\ln(\frac{25500}{r + 25000})}{\ln(\frac{51}{50})}`} />
<MathComponent tex={String.raw`r = reputation`} />
<MathComponent tex={String.raw`\Delta r = \Delta r \times \frac{100+favor}{100}`} />
</>;
const infoText: IInnerHTMLMarkup = {
__html: this.props.factionInfo.infoText,
}

@ -125,7 +125,6 @@ export class Gang {
this.respectGainRate = respectGains;
this.wantedGainRate = wantedLevelGains;
this.moneyGainRate = moneyGains;
const gain = respectGains * numCycles;
this.respect += gain;
// Faction reputation gains is respect gain divided by some constant
@ -135,6 +134,7 @@ export class Gang {
throw new Error('Could not find the faction associated with this gang.');
}
const favorMult = 1 + (fac.favor / 100);
fac.playerReputation += ((player.faction_rep_mult * gain * favorMult) / GangConstants.GangRespectToReputationRatio);
// Keep track of respect gained per member