~subsetpark/whist

ref: ce6d559ad77293610211f21b8297b0acdddd859d whist/events.janet -rw-r--r-- 1.2 KiB
ce6d559a — Zach Smith Complete whist 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
## events.janet
(import players)
# Hand side effects
## Events: Draw
(defn draw [player count] {:event "draw" :player player :count count})

# Game Side Effects
## Events: End Game
(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])}))

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

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

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

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

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

# State labels
## Events: Add Info
(defn add-info [id label] {:event "add_info" :id id :label label})