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',
playerName: 'Player ' + 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 }));
}
}

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

Loading…
Cancel
Save