6c4b421ce2c269a6a4a4048cb7cd6f0712ff3c7e — Zach Smith 6 months ago a85d88a
Bug fix play->play transition, and dont emit discard event
5 files changed, 6 insertions(+), 8 deletions(-)

M game/beginplay.janet
M game/bid.janet
M game/play.janet
M test/last-card.janet
M test/whist.janet
M game/beginplay.janet => game/beginplay.janet +0 -1
@@ 25,5 25,4 @@
      :stacks (init-stacks)}
      (map |(events/add-info (tricks-counter ($0 :id)) ($0 :id)) players)
      {:event "discard" :player bidder :value to-discard}
      (events/prompt-play bidder))]))

M game/bid.janet => game/bid.janet +0 -1
@@ 17,7 17,6 @@
  (case last-bid
    "pass" @[(events/add-decoration last-bidder "bid_action" "passed")]
    # Handle a bid. 
     (case previous-high-bidder
       nil @[]

M game/play.janet => game/play.janet +1 -2
@@ 91,7 91,7 @@
    # State: Play->Play
    [@{:phase "play"
       :info info
       :meta @{:bid current-bid}
       :meta @{:bid current-bid :suit "undefined"}
       :stacks @{:trick []}}

@@ 136,7 136,6 @@
        highest-player (highest-card :player)
        events (map |(events/clear-decoration ($0 :id) "play_action") players)
        updated-info (update (state :info) (keyword highest-player "_tricks") inc)]
    (var next-state @{})
    (case (length ((players 0) :hand)) 
      # There are no more cards in the players' hands; resolve the
      # current hand. (NB: we expect that the game server will be

M test/last-card.janet => test/last-card.janet +2 -1
@@ 27,7 27,8 @@
  (def [state events] (whist/next player-lead))
  (def [deco1 deco2 deco3 deco4 north-prompt] events)
  (let [played-card (merge-into @{:player "North"} CA)]
    (is (deep= @{:bid @{:count 3 :suit "notrumps" :direction "up" :player "North"}} (state :meta)))
    (is (deep= @{:suit "undefined" :bid @{:count 3 :suit "notrumps" :direction "up" :player "North"}}
	       (state :meta)))
    (is (deep= @{:trick []} (state :stacks)))
    (is (deep= @{:North_tricks 1 :north_south 0} (state :info))))
  (is (= {:event "clear_decoration" :player "North" :name "play_action"} deco1))

M test/whist.janet => test/whist.janet +3 -3
@@ 41,7 41,8 @@
  (is (= {:value "3 Uptown: Clubs" :event "add_decoration" :name "high_bid" :player "North"} north-decoration))
  (is (= {:event "draw" :count 6 :player "North"} north-draw))
  (is (= {:event "prompt_discard" :count 6 :player "North"} north-prompt))
  (is (deep= {:phase "begin_play" :meta {:bid @{:count 3 :direction "up" :suit "clubs" :player "North"}}} state)))
  (is (deep= {:meta {:bid @{ :suit "clubs" :player "North" :count 3 :direction "up"}} :phase "begin_play"}

(deftest begin-play
  (let [two-cards [CA C2]

@@ 54,8 55,7 @@
				  :meta {:suit "undefined"}}
			  :action {:player "North" :name "discard" :value [C2]}}]
    (def [state events] (whist/next player-discarded))
    (def [info1 info2 info3 info4 north-discard north-prompt] events)
    (is (deep= {:event "discard" :value [@{:rank 2 :suit "clubs"}] :player "North"} north-discard))
    (def [info1 info2 info3 info4 north-prompt] events)
    (is (= {:count 1 :to "trick" :event "prompt_play" :player "North"} north-prompt))
    (is (deep= {:info @{:West_tricks 0
			:East_tricks 0