~subsetpark/whist

ref: b677ce25024b86d1b5ab62f4a77a8b359a07e8fc whist/game/beginplay.janet -rw-r--r-- 794 bytes
b677ce25 — Zach Smith Handle last card to trick 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(defn- discard [from to-discard]
  (let [new @[]]
    (each in-from from
      (if (not (find |(= in-from $0) to-discard))
	(array/push new in-from)))
    new))

(defn begin-play-phase
  ```
  The bidder has discarded six cards. 

  They may lead any card from their hand.

  Provides:
  - `suit`: The led suit of the current trick.
  ```
  [{:meta meta} players {:player bidder :value to-discard}]
  # It's the first trick; bidder gets one trick for the discard.
    (let [bidder-record (find |(= ($0 :id) bidder) players)
	    current-hand (in bidder-record :hand)]
      [{:phase "play" :meta (merge meta {:suit :null})}
       [{:event "add_score" :player bidder :value 1}
	{:event "discard" :player bidder :value to-discard}
	{:event "prompt_play" :player bidder :to "trick" :count 1}]]))