AI UX improvements.

master
Thomas Hintz 5 years ago
parent 5609720876
commit 4cbfe0b394

@ -1501,11 +1501,13 @@ class Harvest extends React.Component {
<div className={'flex ' + (currentExpense <= 0 ? 'red' : 'green')}>
<FontAwesomeIcon icon={faDollarSign} size='6x' />
<div>
<p>
{isCurrentPlayer ? 'You' : this.props.game.currentPlayer}
{currentExpense <= 0 ? ' lost ' : ' gained '}
${formatMoney(Math.abs(currentExpense))}!
</p>
{currentExpense ? (
<p>
{isCurrentPlayer ? 'You' : this.props.game.currentPlayer}
{currentExpense <= 0 ? ' lost ' : ' gained '}
${formatMoney(Math.abs(currentExpense))}!
</p>
) : (<></>)}
{Object.keys(this.props.expenseValue)
.filter(p => p !== this.props.game.currentPlayer)
.map((p, i) =>

@ -1719,6 +1719,24 @@
#f)))
)
(define (finish-ai-turn player game)
(when (< (player-cash player) 0)
(print "taking out loan")
(process-message player game "loan" `((amount . ,(/ (+ (abs (player-cash player))
(remainder (abs (player-cash player)) 1000))
1000)))))
(when (and (>= (player-cash player) 1000)
(or (<= (player-debt player) 40000)
(>= (player-cash player) 75000)))
(print "repaying loan")
(process-message player game "loan" `((amount . ,(* (/ (- (player-cash player)
(remainder (player-cash player) 1000))
1000)
-1)))))
(print "ending turn")
(set! (player-processing-turn player) #f)
(process-message player game "turn-ended" '()))
(define (process-ai-push-message player game msg)
(print (player-name player))
(print msg)
@ -1740,7 +1758,10 @@
(print "ai-next-action")
(when (player-processing-turn player)
(let ((res (process-message player game "next-action" '((type . "next-action")))))
res
(if (and (equal? (alist-ref 'event res) "action")
(equal? (alist-ref 'action res) "actions-end"))
(finish-ai-turn player game)
res)
;; (display "res: ")
;; (write res)
;; (newline)
@ -1756,23 +1777,7 @@
(if (eq? (player-state player) 'pre-turn)
(process-ai-push-message player game '((type . "update"))) ;; restarting at AI player's turn
(if (player-processing-turn player)
(begin
(when (< (player-cash player) 0)
(print "taking out loan")
(process-message player game "loan" `((amount . ,(/ (+ (abs (player-cash player))
(remainder (abs (player-cash player)) 1000))
1000)))))
(when (and (>= (player-cash player) 1000)
(or (<= (player-debt player) 40000)
(>= (player-cash player) 75000)))
(print "repaying loan")
(process-message player game "loan" `((amount . ,(* (/ (- (player-cash player)
(remainder (player-cash player) 1000))
1000)
-1)))))
(print "ending turn")
(set! (player-processing-turn player) #f)
(process-message player game "turn-ended" '()))
(finish-ai-turn player game)
;; this could happen if we restart the game in the middle of a turn
;; so lets just force the next turn
;; TODO this might get hit for every AI player?

Loading…
Cancel
Save