Permalink
Browse files

Created game app, started db design

  • Loading branch information...
1 parent f4f2154 commit 18f13dc6e253a80e668c520d53bf122f0604e66d Chris Hellmuth committed Jul 1, 2008
Showing with 66 additions and 14 deletions.
  1. 0 game/__init__.py
  2. +50 −0 game/models.py
  3. +1 −0 game/views.py
  4. +15 −14 settings.py
View
No changes.
View
@@ -0,0 +1,50 @@
+from django.db import models
+import re
+
+class Game(models.Model):
+ pass
+
+class Board(models.Model):
+ game = models.ForeignKey(Game)
+ move_no = models.IntegerField()
+ rows = models.IntegerField()
+ columns = models.IntegerField()
+ board = models.TextField()
+
+
+class StandardBoard:
+ rows = 11
+ columns = 16
+
+ G, T, R = 'G','T', 'R'
+ default_board = (G, G, G, G, R, R, R, R, R, G, T, G, R, G, G, G,
+ G, T, G, G, R, G, G, G, G, G, G, G, R, G, G, T,
+ G, G, G, R, R, T, G, G, G, G, G, G, R, R, G, G,
+ R, R, R, R, G, G, G, G, G, G, G, G, G, R, R, R,
+ G, G, G, G, G, G, G, G, G, G, G, G, G, T, R, R,
+ G, G, G, G, G, G, G, G, G, G, G, G, G, G, R, G,
+ R, R, R, R, G, G, G, G, T, G, G, G, R, R, R, G,
+ G, T, G, R, R, R, R, G, G, G, G, G, R, G, G, G,
+ G, G, G, G, G, G, R, R, R, R, R, R, R, G, T, G,
+ G, G, G, G, G, T, G, G, G, G, G, G, G, G, G, G,
+ G, G, G, G, G, G, G, G, G, G, T, G, G, G, G, G,)
+ default_board_string = '|'.join(default_board)
+
+ def __init__(self, game, move_no=0):
+ self.board = None
+ if move_no:
+ self.board = Board.objects.filter(game=game, move_no=move_no)
+ if not self.board:
+ # raise
+ pass
+ else:
+ self.board = Board(game=game,
+ move_no=1,
+ rows=self.rows,
+ columns=self.columns,
+ board=self.default_board_string)
+ self._parse_state(self.board.board)
+
+
+ def _parse_state(self, board_str):
+ self.cells = board_str.split('|')
View
@@ -0,0 +1 @@
+# Create your views here.
View
@@ -11,12 +11,12 @@
MANAGERS = ADMINS
-DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
-DATABASE_NAME = '' # Or path to database file if using sqlite3.
-DATABASE_USER = '' # Not used with sqlite3.
-DATABASE_PASSWORD = '' # Not used with sqlite3.
-DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
-DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
+DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
+DATABASE_NAME = 'tigris' # Or path to database file if using sqlite3.
+DATABASE_USER = 'postgres' # Not used with sqlite3.
+DATABASE_PASSWORD = 'postgres' # Not used with sqlite3.
+DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
+DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. Choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
@@ -60,10 +60,10 @@
)
MIDDLEWARE_CLASSES = (
- 'django.middleware.common.CommonMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.middleware.doc.XViewMiddleware',
+# 'django.middleware.common.CommonMiddleware',
+# 'django.contrib.sessions.middleware.SessionMiddleware',
+# 'django.contrib.auth.middleware.AuthenticationMiddleware',
+# 'django.middleware.doc.XViewMiddleware',
)
ROOT_URLCONF = 'tigris.urls'
@@ -76,8 +76,9 @@
)
INSTALLED_APPS = (
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.sites',
+# 'django.contrib.auth',
+# 'django.contrib.contenttypes',
+# 'django.contrib.sessions',
+# 'django.contrib.sites',
+ 'tigris.game',
)

0 comments on commit 18f13dc

Please sign in to comment.