-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.cge
80 lines (69 loc) · 1.9 KB
/
events.cge
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name connect_four
version 0.4
config {
// The width of the game grid. min = 3, default = 7
width: int,
// The height of the game grid. min = 3, default = 6
height: int,
// The number of discs, which form a winning line. min = 2, default = 4
win_length: int,
// The rule variation to use. default: original
variation: variation
}
// The `drop_disc` command can be sent to drop a disc into the game grid. Only allowed when it is the current player's turn.
command drop_disc {
// 0 <= column < config.width
column: int
}
// The `pop_out` command can be sent to remove a disc of your color from the bottom of the grid. Only available if config.variation = pop_out.
command pop_out {
// 0 <= column < config.width
column: int
}
// The `start` event is sent to all players when the game begins.
event start {
// A map of player IDs mapped to their respective disc colors.
colors: map<color>
}
// The game grid.
event grid {
// The cells of the grid as columns (left to right) inside of rows (top to bottom).
cells: list<list<cell>>
}
// The 'invalid_action' event notifies the player that their action was not allowed.
event invalid_action {
// The message containing details on what the player did wrong.
message: string
}
// The `turn` event is sent to all players when it is the next player's turn.
event turn {
// The sign of the player whose turn it is now.
color: color
}
event game_over {
// The color of the winner.
winner_color: color,
// The four cells which form a line.
winning_line: list<cell>
}
// A cell on the game grid.
type cell {
row: int,
column: int,
color: color
}
// A disc color.
enum color {
// No color. Used for empty cells.
none,
// A drops the first disc.
a,
// B drops the second disc.
b
}
enum variation {
// The original Connect 4 game.
original,
// Instead of dropping a disc into a grid a player may choose to remove a disc of their own color from the bottom.
pop_out
}