Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python.pythonPath": "C:\\Users\\agreb\\Anaconda3\\python.exe",
"python.linting.pylintEnabled": true
}
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ django-cors-headers = "*"
gunicorn = "*"
django-heroku = "*"
django-rest-api = "*"
"psycopg2-binary" = "*"
dj-database-url = "*"
whitenoise = "*"

[dev-packages]

Expand Down
216 changes: 124 additions & 92 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ creative guide.
- [ ] Share your board with the project manager that has been assigned to you. If you have not been assigned yet, reach out to your lead PM for guidance
- [ ] Add your Trello URL to your project's README.md file. Commit the change, push it to your repository & submit a pull request

https://trello.com/b/62H8aKgt/lambdamud-anthony-greb

## MVP Features:

#### Client
Expand Down
15 changes: 10 additions & 5 deletions adv_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import django_heroku
from rest_framework.authentication import SessionAuthentication, BasicAuthentication, TokenAuthentication
"""
Django settings for adv_project project.

Expand All @@ -11,8 +13,10 @@
"""

import os
import dj_database_url
from decouple import config


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

Expand All @@ -26,8 +30,9 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', cast=bool)

ALLOWED_HOSTS = []

# ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS').split(',')
# print('ALLOWED_HOSTS', os.getenv('ALLOWED_HOSTS'))
ALLOWED_HOSTS = ["http://localhost:3000", "127.0.0.1"]

# Application definition

Expand Down Expand Up @@ -55,6 +60,7 @@

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down Expand Up @@ -115,7 +121,6 @@
},
]

from rest_framework.authentication import SessionAuthentication, BasicAuthentication, TokenAuthentication

REST_FRAMEWORK = {
# 'DEFAULT_PERMISSION_CLASSES': [
Expand All @@ -128,7 +133,7 @@
),
}

CORS_ORIGIN_ALLOW_ALL=True
CORS_ORIGIN_ALLOW_ALL = True

# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
Expand All @@ -148,6 +153,6 @@
# https://docs.djangoproject.com/en/2.1/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

import django_heroku
django_heroku.settings(locals())
13 changes: 11 additions & 2 deletions adventure/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,14 @@ def move(request):
@csrf_exempt
@api_view(["POST"])
def say(request):
# IMPLEMENT
return JsonResponse({'error':"Not yet implemented"}, safe=True, status=500)
player = request.user.player
player_id = player.id
player_uuid = player.uuid
data = json.loads(request.body)
message = data['message']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's small thing, but have you thought about how you'd handle the case in which the user sends a blank message, or a message with malicious code?

room = player.room()
currentPlayerUUIDs = room.playerUUIDs(player_id)
for p_uuid in currentPlayerUUIDs:
pusher.trigger(f'p-channel-{p_uuid}', u'broadcast', {'message':f'{player.user.username} says {message}.'})
return JsonResponse({'username':player.user.username, 'message': message}, safe=True, status=200)
# return JsonResponse({'error':"Not yet implemented"}, safe=True, status=500)
39 changes: 39 additions & 0 deletions adventure/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 2.1.1 on 2018-12-10 20:02

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Player',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('currentRoom', models.IntegerField(default=0)),
('uuid', models.UUIDField(default=uuid.uuid4, unique=True)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Room',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(default='DEFAULT TITLE', max_length=50)),
('description', models.CharField(default='DEFAULT DESCRIPTION', max_length=500)),
('n_to', models.IntegerField(default=0)),
('s_to', models.IntegerField(default=0)),
('e_to', models.IntegerField(default=0)),
('w_to', models.IntegerField(default=0)),
],
),
]
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ requests-oauthlib==1.0.0
six==1.11.0
urllib3==1.23
whitenoise==4.1

pip freeze > requirements.txt
2 changes: 2 additions & 0 deletions util/create_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@
p.currentRoom=r_outside.id
p.save()

cfe1913928b90b3516e9981d7f3cd76524ecc870

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is your secret key? Why the choice to store it here?