I just whipped up a chess server, running on wss://chorus.mikedilger.com:444/ using all ephemeral events, no access control required.
I was having a horrible week, doing huge coding but getting no wins and probably have to throw out my efforts. I really needed a win. So I did this chess thing which was (for me) easy with super rapid progress.
Here is the protocol, anybody can write a client for this. People connect and get paired up and play each other. There is no fancy Elo score matching yet. Nor did I write a client yet. Just the server... which is currently running and listening for chess events tagging this pubkey(hex): dbb45efeb8cc10e6f75fdff7e561e7db39cc7ba6592f4c22e26f3ee36b2e7bc2
(NIP-64 is not related to this work... yet)
Please somebody write a nice client.
// Event kinds (not yet allocated in nostr)
const REQ_TO_PLAY: EventKind = EventKind::Ephemeral(20300);
/*
* {
* "pubkey": ,
* "kind": 20300,
* "tags": [
* ["p", ],
* ],
* "content": "",
* ...
* }
*/
const RESP_TO_PLAY: EventKind = EventKind::Ephemeral(20301);
/*
* {
* "pubkey": ,
* "kind": 20301,
* "tags": [
* ["p": ],
* ],
* "content": "queued", // 'queued' or 'error:' or 'started:'
* ...
* }
*
*/
const GAME_STATE: EventKind = EventKind::Ephemeral(20302);
/*
* {
* "pubkey":
* "kind": 20302,
* "tags": [
* ["d": ],
* ["p": ],
* ["p": ],
* ],
* "content": ,
* ...
* }
*/
const GAME_MOVE: EventKind = EventKind::Ephemeral(20303);
/*
* {
* "pubkey": ,
* "kind": 20303,
* "tags": [
* ["d": ],
* ["e": ],
* ["p", ],
* ["p": ],
* ["p": ],
* ],
* "content": , // or various other signals like 'quit' TBD.
* ...
* }
*/
const GAME_ERROR: EventKind = EventKind::Ephemeral(20304);
/*
* If the game is known, and the error event came from a player of the game:
* {
* "pubkey": ,
* "kind": 20304
* "tags": [
* "e": ,
* "d": , // if relevant (not present if game not found)
* "p": , // if game not found, this is the author of event reacted to
* "p": , // only if game was found, this is the other player
* ],
* "content":
* ...
* }
*
* If the game is not known:
* {
* "pubkey": ,
* "kind": 20304
* "tags": [
* ["e": ],
* ["p": ],
* ],
* "content":
* ...
* }
*/