Fixed issue with faction reputation donation bug calculating invalid rep gain

This commit is contained in:
danielyxie 2019-04-16 01:19:29 -07:00 committed by danielyxie
parent 33f1e0cb3c
commit 3dd2975c61
2 changed files with 7 additions and 7 deletions

File diff suppressed because one or more lines are too long

@ -45,9 +45,9 @@ export class DonateOption extends React.Component<IProps, IState> {
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
} }
// Returns rep gain for the current donation amount // Returns rep gain for a given donation amount
calculateRepGain(): number { calculateRepGain(amt: number): number {
return this.state.donateAmt / CONSTANTS.DonateMoneyToRepDivisor * this.props.p.faction_rep_mult; return amt / CONSTANTS.DonateMoneyToRepDivisor * this.props.p.faction_rep_mult;
} }
donate(): void { donate(): void {
@ -59,7 +59,7 @@ export class DonateOption extends React.Component<IProps, IState> {
dialogBoxCreate(`You cannot afford to donate this much money!`); dialogBoxCreate(`You cannot afford to donate this much money!`);
} else { } else {
this.props.p.loseMoney(amt); this.props.p.loseMoney(amt);
const repGain = this.calculateRepGain(); const repGain = this.calculateRepGain(amt);
this.props.faction.playerReputation += repGain; this.props.faction.playerReputation += repGain;
dialogBoxCreate(`You just donated ${numeralWrapper.formatMoney(amt)} to ${fac.name} to gain ` + dialogBoxCreate(`You just donated ${numeralWrapper.formatMoney(amt)} to ${fac.name} to gain ` +
`${numeralWrapper.format(repGain, "0,0.000")} reputation`); `${numeralWrapper.format(repGain, "0,0.000")} reputation`);
@ -76,11 +76,11 @@ export class DonateOption extends React.Component<IProps, IState> {
statusTxt: "Invalid donate amount entered!", statusTxt: "Invalid donate amount entered!",
}); });
} else { } else {
const repGain = this.calculateRepGain(); const repGain = this.calculateRepGain(amt);
this.setState({ this.setState({
donateAmt: amt, donateAmt: amt,
statusTxt: `This donation will result in ${numeralWrapper.format(repGain, "0,0.000")} reputation gain`, statusTxt: `This donation will result in ${numeralWrapper.format(repGain, "0,0.000")} reputation gain`,
}) });
} }
} }