Giter Site home page Giter Site logo

rest-quest's Introduction

REST Quest

Write a client that consumes server.js's REST API, grabs a treasure and returns to your castle faster than your opponent.

API

  1. /register/ your player by sending a POST request with your name
  2. wait for your POST request to be answered by the server with a view
  3. POST your next move to /move/ with playercontaining your name and direction the direction you want to move to. The server will also answer with a view

What is a 'view'?

A view is an array of an array of objects that describes the surrounding tiles you can see. As different terrains provide different visibility, the array size can change.

[
	[ {"type": "grass"}, {"type": "mountain"}, {"type": "mountain"} ],
	[ {"type": "grass"}, {"type": "forest"}, {"type": "water"} ],
	[ {"type": "grass"}, {"type": "water"}, {"type": "water"} ]
]

Different terrains allow for different visiblity

  • forest: 3x3 view
  • grass: 5x5 view
  • mountain: 7x7 view

Your avatar is always positioned at the center of the view, so in the previous example he is positioned on the only forest tile.

Tiles

The tiles contained in a view can contain the following data:

{
	"type":     "grass", // the tile type
	"castle":   "[playername]", // castle of a player named [playername]
	"treasure": true // treasure
}

Movement

You can /move/ either

  • up
  • down
  • left
  • right

Moving up a mountains takes two consecutive turns of moving in the same direction. So if you want to climb a mountain tile in direction up you will have to send the up direction twice - in two separate requests. Moving onto water or the enemy castle will instantly kill you.

Game Over

When the game is over because you or your opponent died, or took a treasure to the castle you will receive a game over response.

{
	"game"   : "over",
	"result" : "won" // won, lost or draw
}

rest-quest's People

Contributors

michaelbromley avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.