1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-18 07:15:07 -05:00
xeps/inbox/tictactoe-mug.xml

322 lines
11 KiB
XML
Executable File

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
<!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
<!ENTITY FEATURE "&lt;feature/&gt;">
<!ENTITY NAME "&lt;name/&gt;">
<!ENTITY MOVE "&lt;move/&gt;">
<!ENTITY TURN "&lt;turn/&gt;">
<!ENTITY GAME "&lt;game/&gt;">
<!ENTITY xep-mug "<span class='ref'><link url='http://pidgin-games.sourceforge.net/xep/multi-user_gaming.html'>Multi-User Gaming</link></span> <note>XEP-xxxx: Multi-User Gaming &lt;<link url='http://pidgin-games.sourceforge.net/xep/multi-user_gaming.html'>http://pidgin-games.sourceforge.net/xep/multi-user_gaming.html</link>&gt;.</note>" >
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
<title>Server-based Tic-tac-toe</title>
<abstract>This document defines how to play a Tic-tac-toe game over XMPP</abstract>
&LEGALNOTICE;
<number>xxxx</number>
<status>ProtoXEP</status>
<type>Standards Track</type>
<approver>Council</approver>
<dependencies>
<spec>XMPP Core</spec>
<spec>XEP-xxxx</spec>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>Not yet assigned</shortname>
<author>
<firstname>Arne</firstname>
<surname>König</surname>
<email>arne.ko(&#228;t)23inch.de</email>
<jid>arne++(&#228;t)jabber.ccc.de</jid>
</author>
<author>
<firstname>G&#252;nther</firstname>
<surname>Nie&#223;</surname>
<email>guenther.niess(&#228;t)web.de</email>
<jid>niess(&#228;t)jabber.ccc.de</jid>
</author>
<revision>
<version>0.0.1</version>
<date>2009-03-14</date>
<initials>ak</initials>
<remark>
<p>First Draft.</p>
</remark>
</revision>
</header>
<section1 topic='Introduction' anchor='intro'>
<p>
It is quite common to play games over IM networks.
Since Tic-tac-toe is a well-known and simple game,
it's a good example for a server-based game protocol.
</p>
</section1>
<section1 topic='Requirements' anchor='reqs'>
<p>
This document addresses the requirements for a game protocol as defined by &xep-mug;.
In particular this consists of:
</p>
<ol start='1'>
<li>game roles</li>
<li>match state</li>
<li>turns</li>
<li>match configuration</li>
<li>conditions for interrupting and terminating a match</li>
</ol>
<p>
The extensions needed to implement these requirements are qualified by the 'http://jabber.org/protocol/mug/tictactoe' namespace.
</p>
</section1>
<section1 topic='Discovering Support' anchor='support'>
<p>
An entity implementing this protocol MUST also support &xep-mug; and answer to disco requests accordingly
including both the Multi-User Gaming and the game &FEATURE; elements in the response.
</p>
<example caption='Service Informs Juliet That It is Capable of Hosting Tic-tac-toe'><![CDATA[
<iq type='result'
from='games.shakespeare.lit'
id='disco1'
to='juliet@capulet.com/garden'>
<query xmlns='http://jabber.org/protocol/disco#info'>
...
<feature var='http://jabber.org/protocol/mug'/>
<feature var='http://jabber.org/protocol/mug/tictactoe'/>
...
</query>
</iq>
]]></example>
</section1>
<section1 topic='Game Roles' anchor='roles'>
<p>
A Tic-tac-toe game uses two game roles, "x" and "o".
Both roles have to be assigned to exactly one player to start a match.
If one role gets unassigned or a player gets unavailable the match has to be paused.
</p>
</section1>
<section1 topic='Match Configuration' anchor='config'>
<p>
A service SHOULD offer a configuration form with the following options:
</p>
<ol start='1'>
<li>starting role ("mug/tictactoe#config_first")</li>
<li>size of the board ("mug/tictactoe#config_rows" and "mug/tictactoe#config_cols")</li>
<li>the number of marks in a row needed to win ("mug/tictactoe#config_first")</li>
</ol>
<p>
An implementation MUST be able to handle the a board with three cols and rows
and three respective marks to win.
Everything beyond that is OPTIONAL.
</p>
<example caption='Service Sends Configuration Form'><![CDATA[
<iq from='tictactoe@games.shakespeare.lit'
id='config1'
to='juliet@capulet.com/garden'
type='result'>
<query xmlns='http://jabber.org/protocol/mug#owner'>
<options>
<x xmlns='jabber:x:data' type='form'>
<title>Tic-tac-toe Room</title>
...
</x>
<options xmlns='http://jabber.org/protocol/mug/tictactoe'>
<x xmlns='jabber:x:data' type='form'>
<title>Configuration for Tic-tac-toe</title>
<instructions>
Below you can see the default configuration.
To accept the default configuration, click OK.
To select a different configuration, please complete this form.
</instructions>
<field var='FORM_TYPE' type='hidden'>
<value>http://jabber.org/protocol/mug/tictactoe#tictactoeconfig</value>
</field>
<field label='Number of rows' var='mug/tictactoe#config_rows' type='list-single'>
<value>3</value>
<option label='3'><value>3</value></option>
<option label='4'><value>4</value></option>
<option label='5'><value>5</value></option>
<option label='6'><value>6</value></option>
<option label='7'><value>7</value></option>
<option label='8'><value>8</value></option>
<option label='9'><value>9</value></option>
<option label='10'><value>10</value></option>
</field>
<field label='Number of cols' var='mug/tictactoe#config_cols' type='list-single'>
<value>3</value>
<option label='3'><value>3</value></option>
<option label='4'><value>4</value></option>
<option label='5'><value>5</value></option>
<option label='6'><value>6</value></option>
<option label='7'><value>7</value></option>
<option label='8'><value>8</value></option>
<option label='9'><value>9</value></option>
<option label='10'><value>10</value></option>
</field>
<field label='Strike' var='mug/tictactoe#config_strike' type='list-single'>
<value>3</value>
<option label='3'><value>3</value></option>
<option label='4'><value>4</value></option>
<option label='5'><value>5</value></option>
<option label='6'><value>6</value></option>
<option label='7'><value>7</value></option>
<option label='8'><value>8</value></option>
<option label='9'><value>9</value></option>
<option label='10'><value>10</value></option>
</field>
<field label='Select a role who start the game' var='mug/tictactoe#config_first' type='list-single'>
<value>x</value>
<option label='x'><value>x</value></option>
<option label='o'><value>o</value></option>
</field>
</x>
</options>
</options>
</query>
</iq>
]]></example>
<p>
Submitting a strike option value bigger than the number of rows or columns SHOULD
result in &notacceptable; error.
</p>
</section1>
<section1 topic='Match State' anchor='state'>
<p>
The state in a Tic-tac-toe match represents the match configuration,
the player who makes the next turn
and the current state of the board. Every state is distributed to all occupants.
</p>
<example caption='Service Sends Start State'><![CDATA[
<presence
from='tictactoe@games.shakespeare.lit'
to='juliet@capulet.com/garden'>
<game xmlns='http://jabber.org/protocol/mug'>
<status>inactive</status>
<state xmlns='http://jabber.org/protocol/mug/tictactoe'>
<rows>3</rows>
<cols>3</cols>
<strike>3</strike>
<next>x</next>
<board/>
</state>
</game>
</presence>
]]></example>
<p>
After a valid turn, the state gets updated with the corresponding mark.
</p>
<example caption='Service Sends Mid-Game State'><![CDATA[
<presence
from='tictactoe@games.shakespeare.lit'
to='juliet@capulet.com/garden'>
<game xmlns='http://jabber.org/protocol/mug'>
<status>active</status>
<state xmlns='http://jabber.org/protocol/mug/tictactoe'>
<rows>3</rows>
<cols>3</cols>
<strike>3</strike>
<next>o</next>
<board>
<field row='1' col='1'>x</field>
<field row='2' col='1'>o</field>
<field row='2' col='2'>x</field>
<field row='1' col='3'>o</field>
<field row='2' col='3'>x</field>
</board>
</state>
</game>
]]></example>
<p>
The match is considered terminated when the board is full or
when one player reaches the number of respective marks as defined by the strike option.
After termination the service broadcasts the final state including either a &lt;draw&gt;
or &lt;won&gt; (including a game role) element to indicate the resulting score
and the initial state of the next round.
</p>
<example caption='Service Sends Draw State'><![CDATA[
<presence
from='tictactoe@games.shakespeare.lit'
to='juliet@capulet.com/garden'>
<game xmlns='http://jabber.org/protocol/mug'>
<status>inactive</status>
<state xmlns='http://jabber.org/protocol/mug/tictactoe'>
<rows>3</rows>
<cols>3</cols>
<strike>3</strike>
<next>o</next>
<board/>
<won>x</won>
</state>
</game>
</presence>
]]></example>
</section1>
<section1 topic='Turns' anchor='turn'>
<p>
During the game, players change in turn, each of them MUST send only one move at a time.
It MUST possess these attributes:
<table caption='&MOVE; attributes'>
<tr>
<td><strong>Name</strong></td>
<td><strong>Type</strong></td>
<td><strong>Description</strong></td>
</tr>
<tr>
<td>'id'</td>
<td>REQUIRED</td>
<td>The number of the move. First move is 1.</td>
</tr>
<tr>
<td>'row'</td>
<td>REQUIRED</td>
<td>The horizontal position of the mark.</td>
</tr>
<tr>
<td>'col'</td>
<td>REQUIRED</td>
<td>The vertical position of the mark.</td>
</tr>
</table>
</p>
<example caption='Juliet Sends a Move'><![CDATA[
<message
to='tictactoe@games.shakespeare.lit'
from='juliet@capulet.com/garden'
type='chat'>
<turn xmlns='http://jabber.org/protocol/mug#user'>
<move
xmlns='http://jabber.org/protocol/mug/tictactoe'
row='3'
col='2'
id='7'/>
</turn>
</message>
]]></example>
</section1>
<section1 topic='Security Considerations' anchor='security'>
<p>
The author is not aware of any security issues introduced by this protocol extension.
</p>
</section1>
<section1 topic='IANA Considerations' anchor='iana'>
<p>This document requires no interaction with &IANA;.</p>
</section1>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
<p>The &REGISTRAR; shall include 'http://jabber.org/protocol/mug/tictactoe' in its registry of protocols.</p>
</section1>
<section1 topic='XML Schema' anchor='schema'>
</section1>
</xep>