-
Notifications
You must be signed in to change notification settings - Fork 176
LambdaMUD-Project #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
LambdaMUD-Project #132
Changes from all commits
a691768
0ce2ccd
7b1b5d4
4d01fb0
4fb8ac4
2487adc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "python.pythonPath": "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3" | ||
| } |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,9 +59,18 @@ def move(request): | |
| players = room.playerNames(player_id) | ||
| return JsonResponse({'name':player.user.username, 'title':room.title, 'description':room.description, 'players':players, 'error_msg':"You cannot move that way."}, safe=True) | ||
|
|
||
|
|
||
| @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'] | ||
| room = player.room() | ||
| currentPlayerUUIDs = room.playerUUIDs(player_id) | ||
| for p_uuid in currentPlayerUUIDs: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This say command looks great! It might be nice to have a few more comments. Also have you thought about how you might handle the case where a user tries to send an empty message? |
||
| 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) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Generated by Django 2.1.1 on 2018-12-10 23:32 | ||
|
|
||
| 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)), | ||
| ], | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import random | ||
| key = ''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is cool, I like how you set a file to do this secret key generation. It's good reusability and accessibility. |
||
| print(key) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good that you added a link to your URL here. It's a small thing but many students forget/ignore that instruction.