Adding 'roller' stats.

master
Thomas Hintz 5 years ago
parent d6692bc64d
commit 250fdb9ca7

@ -2105,6 +2105,8 @@ class BoardApp extends React.Component {
<p>{alert.contents.stats.back}</p>
<p>{alert.contents.stats.taxPerson}</p>
<p>{alert.contents.stats.emergency}</p>
<p>{alert.contents.stats.highRoller}</p>
<p>{alert.contents.stats.lowRoller}</p>
</Fragment>
</AlertOverlay>
);

@ -134,7 +134,9 @@
'((pro . 0)
(back . 0)
(tax-person . 0)
(emergency . 0))
(emergency . 0)
(num-harvests . 0)
(harvest-rolls . 0))
accessor: player-stats)))
(define-class <ai> (<player>)
@ -914,6 +916,12 @@
(* (player-debt player) -1)))
(define (do-end-of-game game)
(let ((rollers (sort (game-players game)
(lambda (p1 p2)
(> (/ (alist-ref 'harvest-rolls (player-stats p1))
(max (alist-ref 'num-harvests (player-stats p1)) 1))
(/ (alist-ref 'harvest-rolls (player-stats p2))
(max (alist-ref 'num-harvests (player-stats p2)) 1)))))))
(message-players!
game
#f
@ -945,8 +953,22 @@
(lambda (p1 p2)
(> (alist-ref 'emergency (player-stats p1))
(alist-ref 'emergency (player-stats p2))))))))
(conc "Living on the edge: " (player-name p) " ($" (alist-ref 'emergency (player-stats p)) ")"))))))
type: "end-of-game"))
(conc "Living on the edge: " (player-name p) " ($" (alist-ref 'emergency (player-stats p)) ")")))
(highRoller . ,(let ((p (car rollers)))
(conc "High Roller: " (player-name p) " (" (exact->inexact
(/ (round
(* (/ (alist-ref 'harvest-rolls (player-stats p))
(max (alist-ref 'num-harvests (player-stats p)) 1))
10))
10)) ")")))
(lowRoller . ,(let ((p (last rollers)))
(conc "Low Roller: " (player-name p) " (" (exact->inexact
(/ (round
(* (/ (alist-ref 'harvest-rolls (player-stats p))
(max (alist-ref 'num-harvests (player-stats p)) 1))
10))
10)) ")"))))))
type: "end-of-game")))
(define (create-ws-response player event misc)
(append `((event . ,event) ,@misc)
@ -2333,6 +2355,8 @@
(player-harvest-mult player)))))
(if (not (already-harvested? (alist-ref '?value action) player))
(begin
((make-player-stat 'num-harvests 1) player)
((make-player-stat 'harvest-rolls rolled) player)
(safe-set! (player-cash player)
(+ (player-cash player) income))
(safe-set! (player-harvest-mult player) 1)

Loading…
Cancel
Save