4 A game spec defines the starting layout for a game: **which pieces start
5 on the table, and where**.
7 It also defines some ancillary information about the game and its
8 layout. It does not contain information about the players.
9 Players join a game as permitted by the game access control list,
10 which is specified in a *table specification* (sadly not currently
11 properly documented, but look at the Rustdoc for ``TableSpec``).
16 A game spec is a TOML file. It has the following entries at the top
19 * ``table_size`` [array of 2 numbers]. Size of the table playing
20 area, in Otter internal units. The default is ``[300,200]``.
22 * ``table_colour`` [string: colour]. Table backdrop colour.
23 Only certain colour syntaxes are supported. Default: ``green``.
25 * ``pcaliases``: [table, values are Piece spec table]. Piece alias
26 table. When a piece is being loaded, an alias xxxx grep for where
29 * ``pieces``: Array of `Piece Specs`_. Defines the initial pieces
30 and their layout. Each entry is a piece spec sub-table.
35 A piece spec is a table defining one or more pieces. When part of a
36 game spec, it appears as an entry in the top-level ``pieces`` array,
37 and defines the location(s) on the table to place the pieces, too.
39 There is a mandatory key ``type``, a string. This determines how the
40 rest of the table is interpreted. It is one of the `Piece Spec
46 These apply regardless of the value of ``type``.
48 * ``type``: Piece type or piece spec type. One of the types listed
49 in `Piece Spec Types`_. [string, enum, mandatory]
51 * ``pos``:Position, in game coordinates, of
52 the centre of the piece. The origin is at the top left.
53 [2-element array, default ``[20,20]``]
55 * ``count``: Place multiple identical copies of this piece. [number]
57 * ``posd``: Position delta. When a spec specifies multiple pieces,
58 each successive piece will be shifted by this amount. [2-element
59 array, default ``[5,5]``]
61 * ``face``: Initial face to show (ie, "which way up" the piece
62 starts). The default face is ``0``. For most pieces that is the
63 front, and is usually a good choice. [number]
65 * ``pinned``: Whether the piece is pinned to the table. Players can
66 pin and unpin pieces during the game; this is the initial state.
69 * ``angle``: Initial orientation of the piece. The
70 specified value is multiplied by 45 degrees, increasing values
71 rotating anticlockwise. So for example ``6`` would mean to rotate
72 90 degrees clockwise. [integer 0..7]
78 Depending on the ``type``, some of these parameters will be honoured.
79 This is discussed in the descriptions for each piece spec type.
81 * `colour` [string, colour]. The fill colour For a piece which
82 supports only one face.
84 * `faces` [array of string(s), colours, mandatory]. The main fill
87 * `edge` [string, colour]. The edge colour to draw for a piece with
88 supports only one face. Default is not to draw edges.
90 * `edges` [array of string(s), colours]. The colours of edges to
91 draw. Default is not to draw edges. Must either be a 1-element
92 array, or as long as `faces` (specifying a different edge colour
95 * `edge_width` [number]. Default is 0.2 if `edge` or `edges` is
98 * `label` [table]. Displays a label with informationa about the
99 in-game state. There are two sub-keys:
100 * `colour` [string, defaults to the edge colour].
101 * `place` [string]: One of `BottomLeft` (default), `TopLeft`,
102 `BottomLeftOutside`, `TopLeftOutside`.
104 * `shape` [table]. The shape of a piece. There are two sub-keys:
105 * `type`, [string, `Circle` or `Rect` ].
106 * Either `size` [array of 1 or 2 numbers] (for a square
107 or rectangle) or `diam` [number] (for a circle).
109 * `itemname` [string]. Used when other parts of the game want to
119 A single shape from a piece library.
121 * ``lib``: The library name. [string, mandatory]
123 * ``item``: The item name within that library. [string, mandatory]
138 Multiple shapes from a piece library. Cannot be used with the `count`
141 * ``lib``: The library name. [string, mandatory]
143 * ``items``: The item names. [array of strings, mandatory]
145 * ``prefix``, ``suffix``: Prepended and appended to each
146 entry in ``items``. Useful for abbreviating. [strings]
153 lib = "cards-oxymoron"
154 prefix = "card-oxymoron-"
157 "2","3","4","5","6","7","8","9","T","J","Q","K","A",
158 "2","3","4","5","6","7","8","9","T","J","Q","K","A",
159 "2","3","4","5","6","7","8","9","T","J","Q","K","A",
167 A chess clock. Additional parameters:
169 * ``time``: Initial time for each player. [number, in seconds;
172 * ``per_move``: Time to add per moove. [number, in seconds]
174 (These clock settings cannot be reconfigured via the game UI.)
188 A pickup or play deck. This can occult the pieces (eg, cards) you put
189 on it, shuffling them and hiding their identity.
191 Requires ``face`` and ``shape``. Only ``shape.type="Rect"`` is supported.
193 Honours ``edges``, ``edge_width``.
195 Honours ``label``, displaying the number of of pieces in (on) this deck.
202 faces = ["lightblue", "grey"]
203 edges = ["black", "white"]
204 label.colour = "black"
205 label.place = "BottomLeftOutside"
213 A player hand. When active, arranges for only that player to be able
214 tos see the contents. The other players see the occulted view (eg,
217 Requires ``colour`` and ``shape``. Only ``shape.type="Rect"`` is
220 Honours ``edge``, ``edge_width``.
222 Honours ``label``, displaying the player whose hand this is, when
229 A simple label which can display a player name.
231 Requires ``colour`` and ``shape``. Only ``shape.type="Rect"`` is supported.
233 Honours ``edge``, ``edge_width``.
241 A plain rectangular piece.
243 * ``size``: Size and shape [array of 1 or 2 numbers, mandatory]
247 Honours ``itemname``, ``edges`` and ``edge_width``.
254 faces = ["yellow","#f4f"]
263 A plain circular piece.
265 * ``diam`` [number, mandatory].
269 Honours ``itemname``, ``edges`` and ``edge_width``.