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')}> <div className={'flex ' + (currentExpense <= 0 ? 'red' : 'green')}>
<FontAwesomeIcon icon={faDollarSign} size='6x' /> <FontAwesomeIcon icon={faDollarSign} size='6x' />
<div> <div>
{currentExpense ? (
<p> <p>
{isCurrentPlayer ? 'You' : this.props.game.currentPlayer} {isCurrentPlayer ? 'You' : this.props.game.currentPlayer}
{currentExpense <= 0 ? ' lost ' : ' gained '} {currentExpense <= 0 ? ' lost ' : ' gained '}
${formatMoney(Math.abs(currentExpense))}! ${formatMoney(Math.abs(currentExpense))}!
</p> </p>
) : (<></>)}
{Object.keys(this.props.expenseValue) {Object.keys(this.props.expenseValue)
.filter(p => p !== this.props.game.currentPlayer) .filter(p => p !== this.props.game.currentPlayer)
.map((p, i) => .map((p, i) =>

@ -1719,6 +1719,24 @@
#f))) #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) (define (process-ai-push-message player game msg)
(print (player-name player)) (print (player-name player))
(print msg) (print msg)
@ -1740,7 +1758,10 @@
(print "ai-next-action") (print "ai-next-action")
(when (player-processing-turn player) (when (player-processing-turn player)
(let ((res (process-message player game "next-action" '((type . "next-action"))))) (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: ") ;; (display "res: ")
;; (write res) ;; (write res)
;; (newline) ;; (newline)
@ -1756,23 +1777,7 @@
(if (eq? (player-state player) 'pre-turn) (if (eq? (player-state player) 'pre-turn)
(process-ai-push-message player game '((type . "update"))) ;; restarting at AI player's turn (process-ai-push-message player game '((type . "update"))) ;; restarting at AI player's turn
(if (player-processing-turn player) (if (player-processing-turn player)
(begin (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" '()))
;; this could happen if we restart the game in the middle of a turn ;; this could happen if we restart the game in the middle of a turn
;; so lets just force the next turn ;; so lets just force the next turn
;; TODO this might get hit for every AI player? ;; TODO this might get hit for every AI player?

Loading…
Cancel
Save