field updates - xale/iTetrinet GitHub Wiki
The field update message, which is identical for both the server-to-client and client-to-server versions, has the following format:
f <playernum> <fieldstring>
arguments | type | values | meaning |
---|---|---|---|
playernum |
integer | 1 – 6 |
the number of the player to whom the field update applies |
fieldstring |
string | see below | the contents of the player’s field, or a partial field update |
The second argument comes in two forms. The longer, but simpler, form is referred to as a “fieldstring”, which consists of 264 (12 * 22) characters, each representing a single cell on the field, indexed left-to-right, then top-to-bottom, starting with the top-left corner of the field.
An example fieldstring:
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000510000000055511101000a555511010005555a5101022r525521010225222c22
The second, shorter form of field update is a partial update:
#8F7G8G9G
The first character of a partial field update lies in the range of ASCII 0x21
to 0x2F
, inclusive. These values correspond to a color of cell, or type of special block:
character | ASCII value | cell type | sample image |
---|---|---|---|
! |
0x21 / 33 |
empty | |
" |
0x22 / 34 |
blue cell | |
# |
0x23 / 35 |
yellow cell | |
$ |
0x24 / 36 |
green cell | |
% |
0x25 / 37 |
purple cell | |
& |
0x26 / 38 |
red cell | |
' |
0x27 / 39 |
add line | |
( |
0x28 / 40 |
clear line | |
) |
0x29 / 41 |
nuke field | |
* |
0x2A / 42 |
random clear | |
+ |
0x2B / 43 |
switchfield | |
, |
0x2C / 44 |
clear specials | |
- |
0x2D / 45 |
gravity | |
. |
0x2E / 46 |
quakefield | |
/ |
0x2F / 47 |
block bomb | |
A partial update can contain more than one of the characters in this list, and will always contain one of them as the first character.
Characters other than these correspond to coordinates on the board, indexed in in column-row order, left-to-right and top-to-bottom, with the ASCII character '3'
(0x33
, decimal 51
) representing 0
, and characters with higher ASCII values representing higher indexes.
To apply a partial update to a field, simply fill the cell at each pair of coordinates with the last cell type encountered in the string.