Compare commits

..

No commits in common. "47fe29d4a432e137c4623d1941ae2b62d04a5afe" and "b69b21d518eb6054b0598fb4b8479582c5d6ec38" have entirely different histories.

6 changed files with 37 additions and 37 deletions

View File

@ -1,32 +1,2 @@
# avalon-django
`avalon-django` is a web-app implementation of the tabletop hidden-roles game
[The Resistance: Avalon](https://boardgamegeek.com/boardgame/128882/resistance-avalon)
powered by the Python web framework [Django](https://www.djangoproject.com/).
The impetus for implementing the game electronically was to speed up gameplay
by having the computer do the bookkeeping and (optionally) having the computer
display a history of public actions to reduce discussion about what had happened
so far in the game.
## How to play
Each player must have their own device (usually a smartphone, but any device
with a web browser will work) and go to the URL where the game is hosted.
(Feel free to
[play on my server](https://aweirdimagination.net/apps/avalon-django).)
When creating a game, a 6 letter game code will be generated to identify the
game for other players to join. Optionally, a shared device (e.g. a TV or
large tablet) may be setup as an "observer" to display the public data on
a common display (to make the game more social by avoiding everyone
constantly looking at their own phone). Once everyone has joined, follow
the on-screen instructions to play; the interface is made assuming everyone
already knows the basic game rules.
## Installation
TODO: Write more detail.
See the `deploy/awi` branch to see the configuration files used to
deploy this on https://avalon.aweirdimagination.net/
Resistance: Avalon web app implemented using Django

View File

@ -32,13 +32,23 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [
'avalon_game.apps.AvalonGameConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE_CLASSES = [
# Does not exist in Django before 1.8.
#'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
@ -53,6 +63,7 @@ TEMPLATES = [
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
@ -77,6 +88,25 @@ DATABASES = {
}
# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/

View File

@ -15,7 +15,9 @@ Including another URLconf
3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^', include('avalon_game.urls')),
url(r'^admin/', admin.site.urls),
]

View File

@ -29,13 +29,11 @@ class Game(models.Model):
display_history = models.NullBooleanField()
private_voting = models.NullBooleanField()
player_assassinated = models.ForeignKey('Player', null=True, default=None,
related_name='+',
on_delete=models.PROTECT)
related_name='+')
created = models.DateTimeField()
ended = models.DateTimeField(null=True, default=None)
next_game = models.OneToOneField('self', null=True, default=None,
related_name='previous_game',
on_delete=models.SET_DEFAULT)
related_name='previous_game')
# from http://stackoverflow.com/a/11821832
def save(self, *args, **kwargs):

View File

@ -1,4 +1,4 @@
{% load static %}
{% load staticfiles %}
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>

View File

@ -205,7 +205,7 @@ def game_base_context(game, player):
context['num_resistance'] = len([p for p in players if not p.is_spy()])
resistance_roles = [p.role_string() for p in players
if not p.is_spy() and p.role != Player.ROLE_GOOD]
if resistance_roles and all(r is not None for r in resistance_roles):
if resistance_roles:
resistance_roles.sort()
context['resistance_roles'] = resistance_roles