summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hintz <t@thintz.com>2020-04-29 07:47:50 -0700
committerThomas Hintz <t@thintz.com>2020-04-29 07:47:50 -0700
commitce0070ed7e9bdcd5317c6dbb6578b3eee9977d71 (patch)
tree0866bc74c573718eb0798de832665dc70ba52d40
parent9160fdc92a7581cb9de48c80f99feac9701dddd1 (diff)
downloadfarm-ce0070ed7e9bdcd5317c6dbb6578b3eee9977d71.tar.gz
Fixing turn end bug.
-rw-r--r--src/server/farm.scm32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/server/farm.scm b/src/server/farm.scm
index 62a8299..cdf67ba 100644
--- a/src/server/farm.scm
+++ b/src/server/farm.scm
@@ -1445,20 +1445,23 @@
`(,(car row) . ,(list->vector (cdr row))))
*harvest-table*)))))
((string=? type "turn-ended")
- (reconcile-display-cash player game)
- (safe-set! (player-harvesting player) #f)
- (if (>= (player-cash player) 0)
- (begin (advance-turn game player)
- (handle-exceptions
- exn
- (begin (log-error exn)
- (log-msg "error saving app"))
- (save-game game))
- (if (eq? (game-state game) 'finished)
- (do-end-of-game game)
- (message-players! game player '() type: "update"))
- (create-ws-response player "update" '()))
- (begin (create-ws-response player "update" '()))))
+ (if (not (eq? (player-state player) 'turn-ended))
+ (begin
+ (reconcile-display-cash player game)
+ (safe-set! (player-harvesting player) #f)
+ (if (>= (player-cash player) 0)
+ (begin (advance-turn game player)
+ (handle-exceptions
+ exn
+ (begin (log-error exn)
+ (log-msg "error saving app"))
+ (save-game game))
+ (if (eq? (game-state game) 'finished)
+ (do-end-of-game game)
+ (message-players! game player '() type: "update"))
+ (create-ws-response player "update" '()))
+ (begin (create-ws-response player "update" '()))))
+ (create-ws-response player "update" '())))
((string=? type "toggle-reveal-for-trading")
(let ((id (alist-ref 'id msg)))
(if (member id (player-revealed-cards player))
@@ -1763,7 +1766,6 @@
1000)
-1)))))
(print "ending turn")
- ;; (thread-sleep! 0.5)
(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