# $Id$

Request:

<iq type='set' to='a@b.c' id='id1'>
    <create xmlns='games:board' id='123' type='battleship' start='true'/>
</iq>

Positive response:

<iq type='result' to='x@y.z' id='id1'/>?

After that the encrypted field must be sent by both players.
Hash is SHA1 digest of concatenated random string seed and symbol 0
(if the field is empty) or 1 (if the field is occupied by a ship).

Example1: seed qscercxifvrt gives 3ebe9d6974e3a2815271553605b3d3b74008e8d4 for
free field and 7cdb05fd65cd3d943a7ff937cc0da5f31b990f76 for occupied field.

Also, the ship hashes are to be included: each is a SHA1 hash of
concatenated seeds for the positions where the ship is located.
The cells go sequentially with one coordinate fixed and the other is growing.

Seed MUST NOT be the same for different board cells.

<iq type='set' to='a@b.c' id='id2'>
    <board xmlns='games:board' type='battleship' id='123'>
	<cell row='0' col='0' hash='3ebe9d6974e3a2815271553605b3d3b74008e8d4'/>
	<cell row='0' col='1' hash='abc4481f0927f3c4a004314dc9c43999ed14d4f6'/>
	<cell row='0' col='2' hash='7f1afdcdad4c980952580f85e35c21b6d7ba13ca'/>
	<cell row='0' col='3' hash='4e14237c1458cfb3e755e30ff99bfab9dd883752'/>
	...
	<cell row='1' col='6' hash='97e471491d08463424b97ea495218a67cfc339ca'/>
	...
	<cell row='9' col='9' hash='79a2cecfcda630a268e955ccc3f60edec952b375'/>
	<ship length='5' hash='1212312312312312312312312312313212121'/>
	<ship length='4' hash='3423423423423423423423423423423423423'/>
	<ship length='3' hash='3423423423423423423423423423423423423'/>
	<ship length='2' hash='3423423423423423423423423423423423423'/>
	<ship length='2' hash='3423423423423423423423423423423423423'/>
	<ship length='1' hash='3423423423423423423423423423423423423'/>
    </board>
</iq>

Response for the game board:

<iq type='result' to='x@y.z' id='id2'/>

Move:

<iq type='set' to='x@y.z' id='id3'>
    <turn xmlns='games:board' type='battleship' id='123'>
	<shot row='1' col='6'/>
    </turn>
</iq>

'row' and 'col' attributes contain coordinates of cell to be shot.
Coordinate is an integer between 0 and 9.

Response MUST include the result ('miss', 'hit' or 'destroy') and the seed of
the cell to check the result.

<iq type='result' to='a@b.c' id='id3'>
    <turn xmlns='games:board' type='battleship' id='123'>
	<shot result='miss' seed='qwerty'/>
    </turn>
</iq>

Consistency check: SHA1(qwerty0) = 97e471491d08463424b97ea495218a67cfc339ca

or:

<iq type='result' to='a@b.c' id='id3'>
    <turn xmlns='games:board' type='battleship' id='123'>
	<shot result='hit' seed='qwerty'/>
    </turn>
</iq>

or (some ship is destroyed):

<iq type='result' to='a@b.c' id='id3'>
    <turn xmlns='games:board' type='battleship' id='123'>
	<shot result='destroy' seed='qwerty'/>
    </turn>
</iq>

Proposing draw (if you want to terminate game before someone wins):

<iq type='set' to='a@b.c' id='id4'>
    <turn xmlns='games:board' type='battleship' id='123'>
	<shot row='1' col='7'/>
	<draw/>
    </turn>
</iq>

The move turn then unconditionally goes to the opponent.

Accepting draw proposal:

<iq type='set' to='a@b.c' id='id5'>
    <turn xmlns='games:board' type='battleship' id='123'>
	<accept/>
    </turn>
</iq>

Resigning:

<iq type='set' to='a@b.c' id='id6'>
    <turn xmlns='games:board' type='battleship' id='123'>
	<resign/>
    </turn>
</iq>

Response:

<iq type='result' to='x@y.z' id='id*'/>

if move accepted, or error 'Not Acceptable' if other side thinks that this move
illegal.

After the game is over (either someone have lost all his/her ships, or someone
resigned, or game was tied) both players MUST send uncovered boards with seeds:

<iq type='set' to='a@b.c' id='id7'>
    <board xmlns='games:board' type='battleship' id='123'>
	<cell row='0' col='0' ship='true' seed='qwert1'/>
	<cell row='0' col='1' ship='false' seed='qwert2'/>
	<cell row='0' col='2' ship='false' seed='qwert3'/>
	<cell row='0' col='3' ship='false' seed='qwert4'/>
	...
	<cell row='1' col='6' ship='false' seed='qwerty'/>
	...
	<cell row='9' col='9' ship='true' seed='qwert12'/>
    </board>
</iq>

Response:

<iq type='result' to='x@y.z' id='id7'/>

if the board is consistent with the initial hashes. Otherwise client should
return error 'Not Acceptable'



