|
|
@ -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?
|
|
|
|