~subsetpark/whist

c7bddc86485d86936548072589b1c9f7eeeeb4af — Zach Smith 6 months ago de17310
Replace janet with outputted janet
4 files changed, 32 insertions(+), 7 deletions(-)

M .gitignore
M events.janet
M game/deal.janet
M whist.janet
M .gitignore => .gitignore +1 -0
@@ 1,2 1,3 @@
*~
/janet_modules
whist.html

M events.janet => events.janet +6 -0
@@ 1,11 1,16 @@
# events.janet
(import players)

# Events: Pick 1
(defn pick1 [name player choices] {:event "prompt_select" :name name :player player :count 1 :from choices})

# Events: Draw
(defn draw [player count] {:event "draw" :player player :count count})

# Events: Add Decoration
(defn add-decoration [player name value] {:event "add_decoration" :name name :player player :value value})


(defn clear-decoration [player name] {:event "clear_decoration" :name name :player player})

(defn end-game


@@ 20,3 25,4 @@
(defn prompt-discard [player count] {:event "prompt_discard" :player player :count count})

(defn add-info [id label] {:event "add_info" :id id :label label})


M game/deal.janet => game/deal.janet +23 -7
@@ 1,11 1,15 @@
# 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. 


@@ 13,11 17,23 @@
  The first player is prompted to begin bidding.
  ```
  [state players]
  # Get The First Player
  (let [bidder ((in players 0) :id)]
    # State: Deal -> Bid 
    [(merge state {:phase "bid"
		   :meta (new-meta players)})
     (array/concat
      (all-draw players)
      (events/add-decoration bidder "bid_action" "bidding")
       (events/pick1 "bid" bidder (bids/available-bids)))]))

  # 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)))

  ]))




M whist.janet => whist.janet +2 -0
@@ 1,3 1,4 @@
# whist.janet
(import game/deal)
(import game/bid)
(import game/discard)


@@ 17,3 18,4 @@
    "discard" (discard/discard-phase state players action)
    "begin_play" (beginplay/begin-play-phase state players action)
    "play" (play/play-phase state players action)))