Coder Social home page Coder Social logo

zork-cortana's Introduction

Zork Game Server

This is a small web service that allows you to play Zork through an HTTP API using a JSON request format. This esencially works by running the gamebin/zork executable with the appropriate save file inside saves/. When a game request is sent with a given conversation ID, the web server first checks if the file exists already. If so, it runs the executable with that save file, runs restore, followed by the command, followed by "save\nquit\ny" to ensure the game exits. If it does not already exist, it runs zork with a new savefile, named saves/${CONV_ID}.dat, where ${CONV_ID} is the conversation ID mentioned above. It then saves the game an exits. In both cases, the game grabs the console output, filters out the unnecessary text, and returns the output as the HTTP response.

Request Format

The request should be sent as a JSON with the following format:

POST /

Headers:

X-Password: <PASSWORD>

Body:

{
    "conversation_id": "<CONVERSATION_ID>",
    "command": "<COMMAND>"
}
  • : The plaintext password used to authenticate the request. This is a required field.
  • <CONVERSATION_ID>: A unique string identifier for the conversation. Will be used to pick up the correct game after consecutive requests. This field is required.
  • : The command/input to be sent to the Zork game. This field is optional (specially for the first request) and will default to the empty string.

Response

There are two possible responses. In case of a successful request, it will return a JSON of the format:

{
    "message": "<MESSAGE>"
}

Where is the string returned by the game to display and read.

Alternatively, if there's an error, it will return the appropriate HTTP error code and the following JSON format:

{
    "error": "<HTTP ERROR>: <ERROR DESCRIPTION>"
}

Here, is an HTTP error number and name, and is a long form description of the cause of the error.

zork-cortana's People

Contributors

rdelfin avatar dependabot[bot] avatar khmakoto avatar

Watchers

James Cloos avatar  avatar  avatar Jonathan Fisher 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.