~subsetpark/whist

ref: 6c4b421ce2c269a6a4a4048cb7cd6f0712ff3c7e whist/events.janet -rw-r--r-- 1019 bytes
6c4b421c — Zach Smith Bug fix play->play transition, and dont emit discard event 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
# 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
  [players team1 score1 team2 score2]
  (let [players1 (players/of-team players (string team1))
	players2 (players/of-team players (string team2))]
    {:event "end_game" :scores (zipcoll (array/concat players1 players2)
					[score1 score1 score2 score2])}))

(defn prompt-play [player &opt from] {:event "prompt_play" :player player :to "trick" :count 1 :from from})

(defn prompt-discard [player count] {:event "prompt_discard" :player player :count count})

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