This repository contains the server for the Gnarly Funky build week team. This Django server serves up a multiplayer real-time vitual world (MUD) to a client front-end.
The core dependencies are as follows:
- django
- djangorestframework
- python-decouple
- django-rest-auth
- django-allauth
- pusher
- django-cors-headers
- gunicorn
- django-heroku
- psycopg2-binary
- whitenoise
Method Url: /api/registration/
HTTP method: [POST]
| name | type | required | description |
|---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
| name | type | required | description |
|---|---|---|---|
username |
String | Yes | Must match a username in the database |
password1 |
String | Yes | Must match the second password sent with the request |
password2 |
String | Yes | Must match the first password sent with the request |
example:
{
"username": "mcfly",
"password1": "wehavetogoback",
"password2: "wehavetogoback"
}If you successfully register, the endpoint will return an HTTP response with a status code
200and a body as below.
{
"key": "4f5d1b80619c3851e382f34a1d67efdc03c68192639"
}If you either try to register with an existing username or submit two passwords that do not match, you will receive a
400status code and a body that might selectively contain any of the fields below:
{
"username": ["A user with that username already exists."],
"password1": ["This password is too common."],
"password2": ["This field is required."]
}Method Url: /api/login/
HTTP method: [POST]
| name | type | required | description |
|---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
| name | type | required | description |
|---|---|---|---|
username |
String | Yes | Must match a username in the database |
password |
String | Yes | Must match a password in the database corresponding to above username |
example:
{
"username": "mcfly",
"password": "wehavetogoback"
}If you successfully login, the endpoint will return an HTTP response with a status code
200and a body as below.
{
"key": "4f5d1b80619c3851e382f34a1d67efdc03c68192639"
}If you are missing a username or password for login, the endpoint will return an HTTP response with a status code
400and a body as below.
{
"non_field_errors": ["Unable to log in with provided credentials."]
}Method Url: /api/adv/init/
HTTP method: [GET]
| name | type | required | description |
|---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
You must send a header with the following in it:
{
"authorization": "Token 4f5d1b80619c3851e382f34a1d67efdc03c68192639"
}If you successfully hit this endpoint, it will return the initial starting data for the user.
{
"player_uuid": "6720e123-53af-4c1d-9305-8asdfc7d842998",
"room_uuid": "343sdf67-5cb1-4e0c-8c44-bb04a1a7f62a",
"player_id": 1,
"player_name": "docbrown",
"room_id": 1414,
"room_title": "Musty Cave of Death",
"room_description": "Marty, we have to go back!"
}If you are missing an authorization token, the endpoint will return an HTTP response with a status code
400and a body as below.
{
"non_field_errors": ["Unable to log in with provided credentials."]
}Method Url: /api/adv/world/
HTTP method: [GET]
| name | type | required | description |
|---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
You must send a header with the following in it:
{
"authorization": "Token 4f5d1b80619c3851e382f34a1d67efdc03c68192639"
}If you successfully hit this endpoint, it will return the initial starting world data.
[
{
id: 2365,
uuid: "bba66a41-be85-4822-b914-f35cf0bcaf0f",
title: "Lost Chamber of Chaos",
desc:
"You've entered a large chambers, filled wall to wall with seating. It must have been used for grand debates. This room looks as though it hasn't been used for anything in decades. You find it hard to think. Which way was out, again?",
touched: true,
x: 23,
y: 0,
north: false,
south: true,
east: false,
west: false
},
{
id: 2366,
uuid: "67b1dff8-7670-48b7-b4e9-ce05dcba640b",
title: "Musty Great Room of Ascendance",
desc:
"You're in a massive room. Each footsteps echo off distant walls. A musty smell permeates the air around you. Soft choir chanting drifts down from somewhere.",
touched: true,
x: 23,
y: 1,
north: true,
south: true,
east: false,
west: false
},
{
id: 2367,
uuid: "6bdd9655-c5ad-46e3-bf15-6433b42b8211",
title: "Black Shrine of Ascendance",
desc:
"In the center of the room stands a grand statue of an ancient goddess. There's almost no light here. Everything is covered in black drapery. Soft choir chanting drifts down from somewhere.",
touched: true,
x: 23,
y: 2,
north: true,
south: false,
east: true,
west: false
}
];If you are missing an authorization token, the endpoint will return an HTTP response with a status code
400and a body as below.
{
"non_field_errors": ["Unable to log in with provided credentials."]
}Method Url: /api/adv/move/
HTTP method: [GET]
| name | type | required | description |
|---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
You must send a header with the following in it:
{
"authorization": "Token 4f5d1b80619c3851e382f34a1d67efdc03c68192639"
}You must also send a body with a
room_idnumber in it:
{
"room_id": 1567
}If you successfully hit this endpoint, it will return the
room_idback along with data about placement of other users on the world map.
{
"new_room": 2674,
"other_players": [
{
"username": "xxx360_no_scopexxx",
"room_x": 21,
"room_y": 7
},
{
"username": "killer_sword",
"room_x": 20,
"room_y": 20
},
{
"username": "thomasnw",
"room_x": 23,
"room_y": 0
},
{
"username": "johnnyboy",
"room_x": 23,
"room_y": 15
},
{
"username": "GyorgLopez",
"room_x": 20,
"room_y": 24
},
{
"username": "derp70",
"room_x": 25,
"room_y": 16
},
{
"username": "littlebillybob",
"room_x": 20,
"room_y": 20
}
]
}If you are missing an authorization token, the endpoint will return an HTTP response with a status code
400and a body as below.
{
"non_field_errors": ["Unable to log in with provided credentials."]
}Our data modeling for our world uses a combination of the following two data structures:
- Matrix
- Linked List
We build our world using a 2D matrix with x and y coordinates. However, each nodes contains references to whether or not you can head in a north, south, east, or west direction. The combination of these two data structures gives us the power of a linked list with the O(1) lookup time that a matrix of x and y points affords us.
- Thanks to the entire Lambda School team for the training and education we've received here. It's been top-notch.