Emergency loan support.

logins
Thomas Hintz 5 years ago
parent 29171875f4
commit a13e26b24c

@ -550,6 +550,11 @@ class Loans extends React.Component {
this.setState({ repay: 0, takeOut: 0 });
}
handleEmergencyLoan = e => {
e.preventDefault();
loan(1);
}
componentDidUpdate(prevProps) {
if (this.props.player.debt !== prevProps.player.debt ||
this.props.game.settings.loanInterest !== prevProps.game.settings.loanInterest ||
@ -566,7 +571,11 @@ class Loans extends React.Component {
/${formatMoney(this.props.game.settings.maxDebt)}
<br />
{this.props.game.settings.loanInterest > 0 ? '(' + (this.props.game.settings.loanInterest * 100) + '% interest added to each loan)' : ''}
<br /><br />
<br />
{this.props.player.debt >= this.props.game.settings.maxDebt ? (
<><Button onClick={this.handleEmergencyLoan}>Emergency Loan</Button> $1,000 at 100% interest</>
) : (<></>)}
<br />
<form onSubmit={this.handleSubmit}>
<Row collapse='true'>
<Col width='8'>

@ -901,12 +901,12 @@
(if (> (+ (player-debt player)
(farming-round (+ amount (* amount (game-setting 'loan-interest game)))))
(game-setting 'max-debt game))
(push-message player "Exceeds max loan.")
(begin (safe-set! (player-cash player) (+ (player-cash player) amount))
(safe-set! (player-debt player) (+ (player-debt player) (* amount 2))))
(begin (safe-set! (player-cash player) (+ (player-cash player) amount))
(safe-set! (player-debt player) (+ (player-debt player)
(farming-round
(+ amount (* amount (game-setting 'loan-interest game))))))
(push-message player (conc "Loan of $" amount " taken out."))))
(+ amount (* amount (game-setting 'loan-interest game))))))))
;; repaying loan
(cond ((> (abs amount) (player-cash player))
(push-message player "Not enough cash to repay loan."))

Loading…
Cancel
Save