diff options
author | rsiddharth <s@ricketyspace.net> | 2020-06-30 20:26:53 -0400 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-06-30 20:26:53 -0400 |
commit | 29da8db3e118df9c71ec1f3fd2cb78dd87291bdc (patch) | |
tree | f7a89f32e2dec135662602f0f657d2d3da42ebd6 /net/ricketyspace | |
parent | 112681d88bf5021a4a56b794e7c97d1f57533ff3 (diff) |
fourteen: server.rkt: Update progress.
End game when one of the player's score is greater than 30.
Diffstat (limited to 'net/ricketyspace')
-rw-r--r-- | net/ricketyspace/ror/fourteen/server.rkt | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/net/ricketyspace/ror/fourteen/server.rkt b/net/ricketyspace/ror/fourteen/server.rkt index 8088b40..55d5f7b 100644 --- a/net/ricketyspace/ror/fourteen/server.rkt +++ b/net/ricketyspace/ror/fourteen/server.rkt @@ -301,7 +301,14 @@ The server is responsible for: ;; moves all objects. may end game (define (progress pls foods spectators) (define p (play pls foods spectators)) - (cond [(empty? foods) (end-game-broadcast p)] + (define (max-score) + (foldl (λ (pl max) + (let ([pl-score (cadr pl)]) + (if (> pl-score max) pl-score max))) + 0 (score pls))) + (define (end-game?) + (or (empty? foods) (> (max-score) 30))) + (cond [(end-game?) (end-game-broadcast p)] [else (broadcast-universe p)])) ;; PlayUniverse -> [Bundle JoinUniverse] |