~subsetpark/whist

ref: 18a5446a58efa8d6444719443d57c93ffa5bcaa9 whist/game/deal.janet -rw-r--r-- 833 bytes
18a5446a — Zach Smith Incorporate lit through discard 7 months 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# game/deal.janet
(import events)
(import bids)

# Each Player Draws
(defn- all-draw [players] (map |(events/draw ($0 :id) 12) players))

# Initialize Metadata
(defn- new-meta [players] {:high_bid {}
                           :not_passed (zipcoll (map |($0 :id) players) [true true true true])})

# Main Deal Function
(defn deal-phase
  ```
  Each player starts with 12 cards. 

  The first player is prompted to begin bidding.
  ```
  [state players]
  # Get The First Player
  (let [bidder ((in players 0) :id)]

  # Return Value
  [
   # New State
   # State: Deal -> Bid 
   (merge state {:phase "bid"
                 :meta (new-meta players)})

   # Deal Events
   (array/concat
    (all-draw players)
    (events/add-decoration bidder "bid_action" "bidding")
     (events/pick1 "bid" bidder (bids/available-bids)))

  ]))