A JSON-RPC API implementing a traditional style of adventure game.
Mostly, it's an experiment.
Since RPC has fallen so far out of favor (thanks to REST), I wanted to imagine what a user-friendly, clean developed RPC-over-HTTP API might realistically look like, free from the assumptions of an existing framework like Express.
For that purpose, I've introduced an entity -- a player character -- to which the user can issue commands. Much like the classic game, Adventure.
The API meets the JSON-RPC 2.0 Specification. It is not backwards compatible to any prior version in any way.
There are a few ways. This one's pretty good and only requires docker.
- Clone the repo.
- Inside the folder,
docker build -t adventure .
docker run -d -p 3000:3000 adventure
If you're going to be mucking about in the source anyway, there are also launch configurations present for Visual Studio Code and, of course, you can always just npm start
.
- Create a character using the
start
method.
Content-type: application/json
POST /json-rpc
{
"jsonrpc": "2.0",
"method": "start",
"id": "anything-you-want"
}
- Look at the response.
- Be amazed. This step is important. Take your time.
- Wait for more to be implemented.
- Look at this page later.
For now, the API stores its data in cookies. If you're playing, make sure your client sends back any cookies you receive.
Move to the next room, in the provided direction.
Responds with "pong"
. Unless, of course, you don't provide an id.
Returns your player data.
Create a character. Create a world. Place the character in the world. Not necessarily in that order. This is for first time users. Not a general character creation API.