Fixing Item Cards to recycle.

logins
Thomas Hintz 5 years ago
parent b4416783ba
commit b9cb7e842a

@ -87,6 +87,7 @@ function handleMessage(evt) {
store.dispatch(startOrJoinGame({ type: 'join-game', store.dispatch(startOrJoinGame({ type: 'join-game',
playerName: 'Player ' + data.games.games[0].colors[0], playerName: 'Player ' + data.games.games[0].colors[0],
checkedColor: data.games.games[0].colors[0], checkedColor: data.games.games[0].colors[0],
gameId: data.games.games[0].id,
gameName: data.games.games[0].name })); gameName: data.games.games[0].name }));
} }
} }

@ -698,16 +698,22 @@
(print action) (print action)
(cond ((eq? value 'otb) (cond ((eq? value 'otb)
(let ((otb (do-action action player))) (let ((otb (do-action action player)))
(set! (game-actions game) (cdr (game-actions game)))
(if otb (if otb
(begin (begin
(set! (game-actions game) (cdr (game-actions game)))
(set-ui-action! `((action . "otb") (set-ui-action! `((action . "otb")
(value . ,(alist-ref 'contents otb))) (value . ,(alist-ref 'contents otb)))
game) game)
(create-ws-response player "action" (create-ws-response player "action"
`((action . "otb") `((action . "otb")
(value . ,(alist-ref 'contents otb))))) (value . ,(alist-ref 'contents otb)))))
(loop)))) (begin
(set-ui-action! `((action . "info")
(value . ,(conc "Out of " *item-card-short* "'s.")))
game)
(create-ws-response player "action"
`((action . "info")
(value . ,(conc "Out of " *item-card-short* "'s."))))))))
((eq? name 'move) ((eq? name 'move)
(set! (game-actions game) (cdr (game-actions game))) (set! (game-actions game) (cdr (game-actions game)))
(set-ui-action! `((action . "move") (value . ,value)) game) (set-ui-action! `((action . "move") (value . ,value)) game)
@ -805,20 +811,23 @@
(let* ((id (alist-ref 'id msg)) (let* ((id (alist-ref 'id msg))
(otb (find (lambda (x) (= id (alist-ref 'id x))) (otb (find (lambda (x) (= id (alist-ref 'id x)))
(player-otbs player)))) (player-otbs player))))
(if (when (buy-crop (normalize-crop
(buy-crop (normalize-crop (string->symbol (alist-ref 'crop otb)))
(string->symbol (alist-ref 'crop otb))) (string->symbol (alist-ref 'crop otb))
(string->symbol (alist-ref 'crop otb)) (alist-ref 'amount otb)
(alist-ref 'amount otb) (* (or (and (number? (alist-ref 'cash msg))
(* (or (and (number? (alist-ref 'cash msg)) (alist-ref 'cash msg))
(alist-ref 'cash msg)) 0)
0) 1000)
1000) player
player game)
game) (set! (game-otbs game)
(set! (player-otbs player) (append (game-otbs game)
(filter (lambda (x) (not (= id (alist-ref 'id x)))) (filter (lambda (x) (= id (alist-ref 'id x)))
(player-otbs player))))) (player-otbs player))))
(set! (player-otbs player)
(filter (lambda (x) (not (= id (alist-ref 'id x))))
(player-otbs player)))))
(create-ws-response player "buy" '())) (create-ws-response player "buy" '()))
((string=? type "buy-uncle-bert") ((string=? type "buy-uncle-bert")
(set! (player-cash player) (- (player-cash player) 10000)) (set! (player-cash player) (- (player-cash player) 10000))
@ -1571,15 +1580,13 @@
(harvest-action-of-type? crop (car actions)))) (harvest-action-of-type? crop (car actions))))
#f)) #f))
(define (draw-otb player) (define (draw-otb player game)
(let ((game (session-ref (sid) 'game))) (if (null? (game-otbs game))
(if (null? (game-otbs game)) #f
(begin (push-message player "No O.T.B.s left to draw!") (receive (new-otb remaining-otbs) (split-at (game-otbs game) 1)
#f) (set! (player-otbs player) (cons (car new-otb) (player-otbs player)))
(receive (new-otb remaining-otbs) (split-at (game-otbs game) 1) (set! (game-otbs game) remaining-otbs)
(set! (player-otbs player) (cons (car new-otb) (player-otbs player))) (car new-otb))))
(set! (game-otbs game) remaining-otbs)
(car new-otb)))))
(define (do-action action player) (define (do-action action player)
(let ((a (alist-ref '?action action))) (let ((a (alist-ref '?action action)))
@ -1600,9 +1607,9 @@
(let ((month (alist-ref '?value action))) (let ((month (alist-ref '?value action)))
(list-index (lambda (x) (eq? x month)) *months*)))) (list-index (lambda (x) (eq? x month)) *months*))))
((and (eq? a 'draw) (eq? (alist-ref '?value action) 'otb)) ((and (eq? a 'draw) (eq? (alist-ref '?value action) 'otb))
(when (not (null? (game-otbs (session-ref (sid) 'game)))) (if (not (null? (game-otbs (session-ref (sid) 'game))))
(push-message player "You drew an O.T.B.!") (draw-otb player (session-ref (sid) 'game))
(draw-otb player))) #f))
((and (eq? a 'draw) (eq? (alist-ref '?value action) 'farmers-fate)) ((and (eq? a 'draw) (eq? (alist-ref '?value action) 'farmers-fate))
(let ((game (session-ref (sid) 'game))) (let ((game (session-ref (sid) 'game)))
(receive (new-ff remaining-ffs) (split-at (game-farmers-fates game) 1) (receive (new-ff remaining-ffs) (split-at (game-farmers-fates game) 1)
@ -1705,5 +1712,4 @@
;; bug: harvest action multiplayer doesn't flow right for other players ;; bug: harvest action multiplayer doesn't flow right for other players
;; info actions should look better ;; info actions should look better
;; you can get $50 from harvest ;; you can get $50 from harvest
;; ran out of otbs
;; bug: new websocket messages should not reset IFS card selection ;; bug: new websocket messages should not reset IFS card selection

Loading…
Cancel
Save