Permalink
Browse files

Standardise layout

Djangoify existing Sabacc code as old_sabacc Django app
Move existing game_test into old_sabacc
Add some TODOs
  • Loading branch information...
1 parent 78d7196 commit 12d45d07e9a656ae6afb37fd5a19038eae450180 @ukch committed Feb 4, 2012
Showing with 66 additions and 197 deletions.
  1. +0 −40 INSTALL
  2. +0 −105 NEWS
  3. 0 online_sabacc/__init__.py
  4. 0 {tests → src/sabacc}/__init__.py
  5. +1 −0 src/sabacc/cardsets/TODO
  6. 0 { → src/sabacc}/cardsets/swag/00sabers_1.png
  7. 0 { → src/sabacc}/cardsets/swag/01flasks_1.png
  8. 0 { → src/sabacc}/cardsets/swag/02coins_1.png
  9. 0 { → src/sabacc}/cardsets/swag/03staves_1.png
  10. 0 { → src/sabacc}/cardsets/swag/04sabers_2.png
  11. 0 { → src/sabacc}/cardsets/swag/05flasks_2.png
  12. 0 { → src/sabacc}/cardsets/swag/06coins_2.png
  13. 0 { → src/sabacc}/cardsets/swag/07staves_2.png
  14. 0 { → src/sabacc}/cardsets/swag/08sabers_3.png
  15. 0 { → src/sabacc}/cardsets/swag/09flasks_3.png
  16. 0 { → src/sabacc}/cardsets/swag/10coins_3.png
  17. 0 { → src/sabacc}/cardsets/swag/11staves_3.png
  18. 0 { → src/sabacc}/cardsets/swag/12sabers_4.png
  19. 0 { → src/sabacc}/cardsets/swag/13flasks_4.png
  20. 0 { → src/sabacc}/cardsets/swag/14coins_4.png
  21. 0 { → src/sabacc}/cardsets/swag/15staves_4.png
  22. 0 { → src/sabacc}/cardsets/swag/16sabers_5.png
  23. 0 { → src/sabacc}/cardsets/swag/17flasks_5.png
  24. 0 { → src/sabacc}/cardsets/swag/18coins_5.png
  25. 0 { → src/sabacc}/cardsets/swag/19staves_5.png
  26. 0 { → src/sabacc}/cardsets/swag/20sabers_6.png
  27. 0 { → src/sabacc}/cardsets/swag/21flasks_6.png
  28. 0 { → src/sabacc}/cardsets/swag/22coins_6.png
  29. 0 { → src/sabacc}/cardsets/swag/23staves_6.png
  30. 0 { → src/sabacc}/cardsets/swag/24sabers_7.png
  31. 0 { → src/sabacc}/cardsets/swag/25flasks_7.png
  32. 0 { → src/sabacc}/cardsets/swag/26coins_7.png
  33. 0 { → src/sabacc}/cardsets/swag/27staves_7.png
  34. 0 { → src/sabacc}/cardsets/swag/28sabers_8.png
  35. 0 { → src/sabacc}/cardsets/swag/29flasks_8.png
  36. 0 { → src/sabacc}/cardsets/swag/30coins_8.png
  37. 0 { → src/sabacc}/cardsets/swag/31staves_8.png
  38. 0 { → src/sabacc}/cardsets/swag/32sabers_9.png
  39. 0 { → src/sabacc}/cardsets/swag/33flasks_9.png
  40. 0 { → src/sabacc}/cardsets/swag/34coins_9.png
  41. 0 { → src/sabacc}/cardsets/swag/35staves_9.png
  42. 0 { → src/sabacc}/cardsets/swag/36sabers_10.png
  43. 0 { → src/sabacc}/cardsets/swag/37flasks_10.png
  44. 0 { → src/sabacc}/cardsets/swag/38coins_10.png
  45. 0 { → src/sabacc}/cardsets/swag/39staves_10.png
  46. 0 { → src/sabacc}/cardsets/swag/40sabers_11.png
  47. 0 { → src/sabacc}/cardsets/swag/41flasks_11.png
  48. 0 { → src/sabacc}/cardsets/swag/42coins_11.png
  49. 0 { → src/sabacc}/cardsets/swag/43staves_11.png
  50. 0 { → src/sabacc}/cardsets/swag/44sabers_com.png
  51. 0 { → src/sabacc}/cardsets/swag/45flasks_com.png
  52. 0 { → src/sabacc}/cardsets/swag/46coins_com.png
  53. 0 { → src/sabacc}/cardsets/swag/47staves_com.png
  54. 0 { → src/sabacc}/cardsets/swag/48sabers_mis.png
  55. 0 { → src/sabacc}/cardsets/swag/49flasks_mis.png
  56. 0 { → src/sabacc}/cardsets/swag/50coins_mis.png
  57. 0 { → src/sabacc}/cardsets/swag/51staves_mis.png
  58. 0 { → src/sabacc}/cardsets/swag/52sabers_mas.png
  59. 0 { → src/sabacc}/cardsets/swag/53flasks_mas.png
  60. 0 { → src/sabacc}/cardsets/swag/54coins_mas.png
  61. 0 { → src/sabacc}/cardsets/swag/55staves_mas.png
  62. 0 { → src/sabacc}/cardsets/swag/56sabers_ace.png
  63. 0 { → src/sabacc}/cardsets/swag/57flasks_ace.png
  64. 0 { → src/sabacc}/cardsets/swag/58coins_ace.png
  65. 0 { → src/sabacc}/cardsets/swag/59staves_ace.png
  66. 0 { → src/sabacc}/cardsets/swag/60_61idiot.png
  67. 0 { → src/sabacc}/cardsets/swag/62_63queen.png
  68. 0 { → src/sabacc}/cardsets/swag/64_65endurance.png
  69. 0 { → src/sabacc}/cardsets/swag/66_67balance.png
  70. 0 { → src/sabacc}/cardsets/swag/68_69demise.png
  71. 0 { → src/sabacc}/cardsets/swag/70_71moderation.png
  72. 0 { → src/sabacc}/cardsets/swag/72_73evilone.png
  73. 0 { → src/sabacc}/cardsets/swag/74_75star.png
  74. 0 { → src/sabacc}/cardsets/swag/76cardback.png
  75. +14 −14 {online_sabacc → src/sabacc}/manage.py
  76. 0 {sabacc → src/sabacc/old_sabacc}/__init__.py
  77. +13 −13 {sabacc → src/sabacc/old_sabacc}/back/Agents.py
  78. +13 −13 {sabacc → src/sabacc/old_sabacc}/back/Game.py
  79. 0 {sabacc → src/sabacc/old_sabacc}/back/__init__.py
  80. +3 −3 {sabacc → src/sabacc/old_sabacc}/back/xml_tools.py
  81. 0 {sabacc → src/sabacc/old_sabacc}/constants.py
  82. +3 −3 {tests → src/sabacc/old_sabacc}/game_test.py
  83. +3 −3 {sabacc → src/sabacc/old_sabacc}/get_settings.py
  84. +3 −0 src/sabacc/old_sabacc/models.py
  85. +7 −0 src/sabacc/old_sabacc/tests.py
  86. +1 −0 src/sabacc/old_sabacc/views.py
  87. +3 −2 {online_sabacc → src/sabacc}/settings.py
  88. +2 −1 { → src/sabacc}/settings.xml
  89. 0 {online_sabacc → src/sabacc}/urls.py
View
40 INSTALL
@@ -1,40 +0,0 @@
-Installing Sabacc
-=================
-
-Before attempting to run or install Sabacc, first ensure that you have
-all the correct dependencies (see below). If you have decided to install
-pygtkmvc locally, you may need to run the following command before Sabacc
-will work:
- sed -i 's@from model_mt import@#from model_mt import@' \
- sabacc/front/guiInterface/gtkmvc/__init__.py
-
-Now, to install Sabacc, change to the directory where you unpacked the
-source tarball, then type (as root):
-
-python setup.py install
-
-Alternatively, you can run Sabacc from the extracted tarball archive.
-Simply type 'python ./bin/sabacc --local' from the correct directory.
-
-If you are a user of Debian/Ubuntu or Microsoft Windows, you might want
-to consider installing the relevant .deb or .exe version of Sabacc
-instead. These are both available from http://sabacc.sourceforge.net and
-make the process of installing and running Sabacc relatively
-hassle-free.
-
-
-Requirements
-============
-
-You will need the following software installed to run Sabacc:
-
- - Python (>= 2.5) - http://www.python.org/
- - The lxml.etree library (>=1.3.6) - http://codespeak.net/lxml/
-
-To use the GTK GUI, you will also need the following:
- - GTK+ (>= 2.8) - http://www.gtk.org/
- - PyGTK (>= 2.8) - http://www.pygtk.org/
- - pygtkmvc (>= 1.2.2) - http://pygtkmvc.sourceforge.net/
- If you do not have this installed system-wide, you may download
- the tarball and extract into the sabacc/front/guiInterface/gtkmvc
- directory.
View
105 NEWS
@@ -1,105 +0,0 @@
-======================
-1.0Beta1 (24 Dec 2008)
-======================
-
-New Features
-------------
- - A complete text-based interface has been added.
- - The bin/sabacc executable now accepts Unix-style arguments.
- - Added new functionality to create/modify/save agents from the main
- interface.
- - Added new settings.xml file and renamed some settings.
-
-
-Bug Fixes
----------
- - It is now impossible to bet more than another player has.
- - Sabacc is now thread-safe and will no longer crash over
- thread-based issues.
- - Closing the player window during a game now no longer breaks the
- game.
-
-
-Miscellaneous
--------------
- - All Python modules have been moved to a seperate 'sabacc' directory,
- and all code has been rewritten
- - GUI front-end has been rewritten using MVC and a separate interface
- package.
- - Changed XML library to lxml.etree as pyxml is becoming obsoleted.
-
-=================
-0.6 (01 May 2008)
-=================
-
-New Features
-------------
- - An icon has been added to the application.
- - 'Bet' button is now renamed to 'End betting' when the bet
- counter is set to 0.
-
-Bug Fixes
----------
- - The only player able to afford the initial ante will no
- longer have to buy in to the game.
- - Various problems with 'New Agent' button fixed.
- - When no winner is declared the unwon winnings will now
- be moved into the Sabacc pot.
- - Win32 'dual display' mode no longer causes problems.
- - Computer agents are now much more likely to call the hand.
-
-======================
-0.6beta1 (01 Feb 2008)
-======================
-
-New Features
-------------
- - Back End:
- - An ante/buy-in has been added to the game. This goes into
- both pots. If a player cannot afford the ante, he/she is
- kicked out of the game.
- - An initial round of betting has been added to the game.
- This round takes place after the game has begun but before
- the cards are revealed.
- - The end-game winning conditions have been modified to make
- them fit in more easily with the rules on the website. The
- new 'Sudden Demise' rule has been added, but may be switched
- on or off by modifying the sabacc.back.settings module.
- - A player drawing a card and having a new total over 23 or
- under -23 will now not bomb out until the game is called.
- - A 'Sabacc Shift' feature has been added to the game. Now,
- a random number of cards will be changed at random points
- during the game. This can happen at any stage, even mid-turn.
- - Computer agents are now capable of betting with a reasonable
- degree of intelligence.
-
- - Front End:
- - The game now supports multiple human agents in the same game.
- If there are multiple humans in the same game, there will be a
- pause between turns and a player's cards will only be shown
- during his/her turn.
-
-Bug Fixes
----------
- - Calling a game during the betting round will now not end the
- player's turn.
- - Multiple bugs involving players leaving the game and clicking
- the 'Quit Game' button have been fixed.
- - A number of bugs involving the end of the game and bomb outs
- have been fixed.
-
-Miscellaneous
--------------
- - All LearningAgent-related features have been removed to speed
- the transition from academic project to playable game. The
- project no longer depends on NumPy.
- - The project has been renamed from SabaccApp to Sabacc. Some
- files have been renamed and others moved. Some text has been
- changed.
- - A setup script has been added to ease installation.
-
-======================
-0.5 (16 November 2007)
-======================
-
- - Initial release.
View
0 online_sabacc/__init__.py
No changes.
View
0 tests/__init__.py → src/sabacc/__init__.py
File renamed without changes.
View
1 src/sabacc/cardsets/TODO
@@ -0,0 +1 @@
+TODO: Allow this to be placed outside src directory
View
0 cardsets/swag/00sabers_1.png → src/sabacc/cardsets/swag/00sabers_1.png
File renamed without changes
View
0 cardsets/swag/01flasks_1.png → src/sabacc/cardsets/swag/01flasks_1.png
File renamed without changes
View
0 cardsets/swag/02coins_1.png → src/sabacc/cardsets/swag/02coins_1.png
File renamed without changes
View
0 cardsets/swag/03staves_1.png → src/sabacc/cardsets/swag/03staves_1.png
File renamed without changes
View
0 cardsets/swag/04sabers_2.png → src/sabacc/cardsets/swag/04sabers_2.png
File renamed without changes
View
0 cardsets/swag/05flasks_2.png → src/sabacc/cardsets/swag/05flasks_2.png
File renamed without changes
View
0 cardsets/swag/06coins_2.png → src/sabacc/cardsets/swag/06coins_2.png
File renamed without changes
View
0 cardsets/swag/07staves_2.png → src/sabacc/cardsets/swag/07staves_2.png
File renamed without changes
View
0 cardsets/swag/08sabers_3.png → src/sabacc/cardsets/swag/08sabers_3.png
File renamed without changes
View
0 cardsets/swag/09flasks_3.png → src/sabacc/cardsets/swag/09flasks_3.png
File renamed without changes
View
0 cardsets/swag/10coins_3.png → src/sabacc/cardsets/swag/10coins_3.png
File renamed without changes
View
0 cardsets/swag/11staves_3.png → src/sabacc/cardsets/swag/11staves_3.png
File renamed without changes
View
0 cardsets/swag/12sabers_4.png → src/sabacc/cardsets/swag/12sabers_4.png
File renamed without changes
View
0 cardsets/swag/13flasks_4.png → src/sabacc/cardsets/swag/13flasks_4.png
File renamed without changes
View
0 cardsets/swag/14coins_4.png → src/sabacc/cardsets/swag/14coins_4.png
File renamed without changes
View
0 cardsets/swag/15staves_4.png → src/sabacc/cardsets/swag/15staves_4.png
File renamed without changes
View
0 cardsets/swag/16sabers_5.png → src/sabacc/cardsets/swag/16sabers_5.png
File renamed without changes
View
0 cardsets/swag/17flasks_5.png → src/sabacc/cardsets/swag/17flasks_5.png
File renamed without changes
View
0 cardsets/swag/18coins_5.png → src/sabacc/cardsets/swag/18coins_5.png
File renamed without changes
View
0 cardsets/swag/19staves_5.png → src/sabacc/cardsets/swag/19staves_5.png
File renamed without changes
View
0 cardsets/swag/20sabers_6.png → src/sabacc/cardsets/swag/20sabers_6.png
File renamed without changes
View
0 cardsets/swag/21flasks_6.png → src/sabacc/cardsets/swag/21flasks_6.png
File renamed without changes
View
0 cardsets/swag/22coins_6.png → src/sabacc/cardsets/swag/22coins_6.png
File renamed without changes
View
0 cardsets/swag/23staves_6.png → src/sabacc/cardsets/swag/23staves_6.png
File renamed without changes
View
0 cardsets/swag/24sabers_7.png → src/sabacc/cardsets/swag/24sabers_7.png
File renamed without changes
View
0 cardsets/swag/25flasks_7.png → src/sabacc/cardsets/swag/25flasks_7.png
Diff not rendered.
View
0 cardsets/swag/26coins_7.png → src/sabacc/cardsets/swag/26coins_7.png
Diff not rendered.
View
0 cardsets/swag/27staves_7.png → src/sabacc/cardsets/swag/27staves_7.png
Diff not rendered.
View
0 cardsets/swag/28sabers_8.png → src/sabacc/cardsets/swag/28sabers_8.png
Diff not rendered.
View
0 cardsets/swag/29flasks_8.png → src/sabacc/cardsets/swag/29flasks_8.png
Diff not rendered.
View
0 cardsets/swag/30coins_8.png → src/sabacc/cardsets/swag/30coins_8.png
Diff not rendered.
View
0 cardsets/swag/31staves_8.png → src/sabacc/cardsets/swag/31staves_8.png
Diff not rendered.
View
0 cardsets/swag/32sabers_9.png → src/sabacc/cardsets/swag/32sabers_9.png
Diff not rendered.
View
0 cardsets/swag/33flasks_9.png → src/sabacc/cardsets/swag/33flasks_9.png
Diff not rendered.
View
0 cardsets/swag/34coins_9.png → src/sabacc/cardsets/swag/34coins_9.png
Diff not rendered.
View
0 cardsets/swag/35staves_9.png → src/sabacc/cardsets/swag/35staves_9.png
Diff not rendered.
View
0 cardsets/swag/36sabers_10.png → src/sabacc/cardsets/swag/36sabers_10.png
Diff not rendered.
View
0 cardsets/swag/37flasks_10.png → src/sabacc/cardsets/swag/37flasks_10.png
Diff not rendered.
View
0 cardsets/swag/38coins_10.png → src/sabacc/cardsets/swag/38coins_10.png
Diff not rendered.
View
0 cardsets/swag/39staves_10.png → src/sabacc/cardsets/swag/39staves_10.png
Diff not rendered.
View
0 cardsets/swag/40sabers_11.png → src/sabacc/cardsets/swag/40sabers_11.png
Diff not rendered.
View
0 cardsets/swag/41flasks_11.png → src/sabacc/cardsets/swag/41flasks_11.png
Diff not rendered.
View
0 cardsets/swag/42coins_11.png → src/sabacc/cardsets/swag/42coins_11.png
Diff not rendered.
View
0 cardsets/swag/43staves_11.png → src/sabacc/cardsets/swag/43staves_11.png
Diff not rendered.
View
0 cardsets/swag/44sabers_com.png → src/sabacc/cardsets/swag/44sabers_com.png
Diff not rendered.
View
0 cardsets/swag/45flasks_com.png → src/sabacc/cardsets/swag/45flasks_com.png
Diff not rendered.
View
0 cardsets/swag/46coins_com.png → src/sabacc/cardsets/swag/46coins_com.png
Diff not rendered.
View
0 cardsets/swag/47staves_com.png → src/sabacc/cardsets/swag/47staves_com.png
Diff not rendered.
View
0 cardsets/swag/48sabers_mis.png → src/sabacc/cardsets/swag/48sabers_mis.png
Diff not rendered.
View
0 cardsets/swag/49flasks_mis.png → src/sabacc/cardsets/swag/49flasks_mis.png
Diff not rendered.
View
0 cardsets/swag/50coins_mis.png → src/sabacc/cardsets/swag/50coins_mis.png
Diff not rendered.
View
0 cardsets/swag/51staves_mis.png → src/sabacc/cardsets/swag/51staves_mis.png
Diff not rendered.
View
0 cardsets/swag/52sabers_mas.png → src/sabacc/cardsets/swag/52sabers_mas.png
Diff not rendered.
View
0 cardsets/swag/53flasks_mas.png → src/sabacc/cardsets/swag/53flasks_mas.png
Diff not rendered.
View
0 cardsets/swag/54coins_mas.png → src/sabacc/cardsets/swag/54coins_mas.png
Diff not rendered.
View
0 cardsets/swag/55staves_mas.png → src/sabacc/cardsets/swag/55staves_mas.png
Diff not rendered.
View
0 cardsets/swag/56sabers_ace.png → src/sabacc/cardsets/swag/56sabers_ace.png
Diff not rendered.
View
0 cardsets/swag/57flasks_ace.png → src/sabacc/cardsets/swag/57flasks_ace.png
Diff not rendered.
View
0 cardsets/swag/58coins_ace.png → src/sabacc/cardsets/swag/58coins_ace.png
Diff not rendered.
View
0 cardsets/swag/59staves_ace.png → src/sabacc/cardsets/swag/59staves_ace.png
Diff not rendered.
View
0 cardsets/swag/60_61idiot.png → src/sabacc/cardsets/swag/60_61idiot.png
Diff not rendered.
View
0 cardsets/swag/62_63queen.png → src/sabacc/cardsets/swag/62_63queen.png
Diff not rendered.
View
0 cardsets/swag/64_65endurance.png → src/sabacc/cardsets/swag/64_65endurance.png
Diff not rendered.
View
0 cardsets/swag/66_67balance.png → src/sabacc/cardsets/swag/66_67balance.png
Diff not rendered.
View
0 cardsets/swag/68_69demise.png → src/sabacc/cardsets/swag/68_69demise.png
Diff not rendered.
View
0 cardsets/swag/70_71moderation.png → src/sabacc/cardsets/swag/70_71moderation.png
Diff not rendered.
View
0 cardsets/swag/72_73evilone.png → src/sabacc/cardsets/swag/72_73evilone.png
Diff not rendered.
View
0 cardsets/swag/74_75star.png → src/sabacc/cardsets/swag/74_75star.png
Diff not rendered.
View
0 cardsets/swag/76cardback.png → src/sabacc/cardsets/swag/76cardback.png
Diff not rendered.
View
28 online_sabacc/manage.py → src/sabacc/manage.py 100644 → 100755
@@ -1,14 +1,14 @@
-#!/usr/bin/env python
-from django.core.management import execute_manager
-import imp
-try:
- imp.find_module('settings') # Assumed to be in the same directory.
-except ImportError:
- import sys
- sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
- sys.exit(1)
-
-import settings
-
-if __name__ == "__main__":
- execute_manager(settings)
+#!/usr/bin/env python
+from django.core.management import execute_manager
+import imp
+try:
+ imp.find_module('settings') # Assumed to be in the same directory.
+except ImportError:
+ import sys
+ sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
+ sys.exit(1)
+
+import settings
+
+if __name__ == "__main__":
+ execute_manager(settings)
View
0 sabacc/__init__.py → src/sabacc/old_sabacc/__init__.py
File renamed without changes.
View
26 sabacc/back/Agents.py → src/sabacc/old_sabacc/back/Agents.py
@@ -33,20 +33,20 @@ def __init__(self, name, interface=None):
self.name = name
if interface == None:
- from sabacc.front.nullInterface import playerInterface
+ from old_sabacc.front.nullInterface import playerInterface
interface = playerInterface(name)
self.interface = interface
self.quit_next_turn = False # player will leave game at next opportunity
- from sabacc.get_settings import initial_credits
+ from old_sabacc.get_settings import initial_credits
self.credits = initial_credits
def move(self, cards):
'''Gets a move from the player and returns it.'''
if self.quit_next_turn:
- from sabacc.constants import moves
+ from old_sabacc.constants import moves
move = moves['fold']
else:
move = self.interface.get_move(cards)
@@ -56,7 +56,7 @@ def move(self, cards):
def bet(self, cards, must_match):
'''Gets a bet from the player and returns it.'''
if self.quit_next_turn:
- from sabacc.constants import moves
+ from old_sabacc.constants import moves
bet = moves['fold']
else:
bet = self.interface.get_bet(cards, must_match)
@@ -157,20 +157,20 @@ def move(self, cards):
If there is an error, the move will always be 'fold'.'''
if self.quit_next_turn:
- from sabacc.constants import moves
+ from old_sabacc.constants import moves
return moves['fold']
self.raised = False
- from sabacc.constants import card_values
+ from old_sabacc.constants import card_values
# Get value of hand
score = 0
for card in cards:
score += card_values[card]
- from sabacc.constants import moves
- from sabacc.get_settings import rule_sets
+ from old_sabacc.constants import moves
+ from old_sabacc.get_settings import rule_sets
if rule_sets.has_key(self.ruleset):
threshold = rule_sets[self.ruleset]
@@ -211,10 +211,10 @@ def bet(self, cards, must_match):
'''Calculates the bet based on the value of the hand.'''
if self.quit_next_turn:
- from sabacc.constants import moves
+ from old_sabacc.constants import moves
return moves['fold']
- from sabacc.constants import card_values
+ from old_sabacc.constants import card_values
# Get value of hand
score = 0
@@ -242,8 +242,8 @@ def bet(self, cards, must_match):
score_type = score_types['out']
from random import randint
- from sabacc.get_settings import agent_betting
- from sabacc.constants import moves
+ from old_sabacc.get_settings import agent_betting
+ from old_sabacc.constants import moves
min_bet = agent_betting['min_bet']
max_bet = agent_betting['max_bet']
@@ -294,7 +294,7 @@ def game_over(self, won, cards):
'''Updates the player's statistics depending
on the outsome of the game,'''
- from sabacc.constants import card_values
+ from old_sabacc.constants import card_values
# Get value of hand
score = 0
View
26 sabacc/back/Game.py → src/sabacc/old_sabacc/back/Game.py
@@ -113,14 +113,14 @@ def start_game(ante=0):
if game_in_progress:
interface.write_error(_('Error: A game is already in progress!'))
return False
- from sabacc.get_settings import game_settings
+ from old_sabacc.get_settings import game_settings
min_players = game_settings['min_players']
if len(loaded) < min_players:
interface.write_error(_('Error: A minimum of %s players must be in the game!') %min_players)
return False
game_in_progress = True
- from sabacc.get_settings import sabacc_shift
+ from old_sabacc.get_settings import sabacc_shift
# initialise Sabacc Shift timer
if sabacc_shift['on']:
@@ -140,7 +140,7 @@ def start_game(ante=0):
player, hand, in_game = player_tuple
loaded[index] = (player, [], True)
- from sabacc.constants import number_of_cards
+ from old_sabacc.constants import number_of_cards
for card in range(number_of_cards):
deck.append(card)
@@ -227,7 +227,7 @@ def start_game(ante=0):
show_all_cards = False
break
- from sabacc.get_settings import game_settings
+ from old_sabacc.get_settings import game_settings
pot_building_rounds = game_settings['pot_building_rounds']
if current_round < pot_building_rounds: # if pot-building phase in progress
@@ -252,7 +252,7 @@ def betting_round(starting_player=0):
must_match = 0 # will increase as players bet
called = False # has the game been called?
already_bet = [] # how much has each player already bet?
- from sabacc.constants import moves # mapping of move names to numbers
+ from old_sabacc.constants import moves # mapping of move names to numbers
for index in range(len(loaded_copy)): # for each player
# no player has bet this round
@@ -343,7 +343,7 @@ def betting_round(starting_player=0):
def drawing_round():
'''Perform one round of drawing, starting with player 0.'''
- from sabacc.constants import moves
+ from old_sabacc.constants import moves
global callable
called = False
@@ -354,7 +354,7 @@ def drawing_round():
#perform move
while in_game and not legal_move:
- from sabacc.get_settings import game_settings
+ from old_sabacc.get_settings import game_settings
idle_time = game_settings['idle_time']
global idle_moves
@@ -464,7 +464,7 @@ def end_game(show_all_cards):
if hand_value == 5 and len(hand) == 3:
idiot_cards = (False, False, False) # used to count number of idiot's array cards
for card in hand:
- from sabacc.constants import card_values
+ from old_sabacc.constants import card_values
if card_values[card] == 0:
idiot_cards[0] = True
elif card_values[card] == 2:
@@ -523,7 +523,7 @@ def end_game(show_all_cards):
#Let's try a sudden demise/card count
if len(winners) > 1:
- from sabacc.get_settings import game_settings
+ from old_sabacc.get_settings import game_settings
sudden_demise = game_settings['sudden_demise']
if sudden_demise:
@@ -611,7 +611,7 @@ def end_game(show_all_cards):
# Don't like sudden demise? Do a card count instead.
else:
# calculate winner with least cards
- from sabacc.constants import number_of_cards
+ from old_sabacc.constants import number_of_cards
least_cards = number_of_cards # maximum number of cards
least_cards_winners = []
@@ -716,7 +716,7 @@ def end_game(show_all_cards):
def get_value(cards):
'''Returns the value of the given list of cards.'''
- from sabacc.constants import card_values
+ from old_sabacc.constants import card_values
hand_total = 0
for card in cards:
hand_total += card_values[card]
@@ -730,8 +730,8 @@ def start_shift():
from random import seed, randint, uniform
seed()
- from sabacc.constants import number_of_cards
- from sabacc.get_settings import sabacc_shift
+ from old_sabacc.constants import number_of_cards
+ from old_sabacc.get_settings import sabacc_shift
num_to_shift = randint(sabacc_shift['min_num'], sabacc_shift['max_num'])
# A player is more likely to be shifted if he has more cards
View
0 sabacc/back/__init__.py → src/sabacc/old_sabacc/back/__init__.py
File renamed without changes.
View
6 sabacc/back/xml_tools.py → src/sabacc/old_sabacc/back/xml_tools.py
@@ -31,7 +31,7 @@ def create_agent(filename, agent_name, ruleset):
'''Creates a blank agent and saves to the given filename.'''
from lxml import etree
- from sabacc import __major_version__
+ from old_sabacc import __major_version__
# Generate template file
template_file = '''<?xml version='1.0' encoding='UTF-8'?>
@@ -134,8 +134,8 @@ def load_file(filename):
sys.stderr.write(_("Error: The file '%s' is not a Sabacc file!\n") %filename)
return False
- from sabacc.constants import lowest_xml_version
- from sabacc import __major_version__
+ from old_sabacc.constants import lowest_xml_version
+ from old_sabacc import __major_version__
if xml_version < lowest_xml_version or xml_version > __major_version__:
sys.stderr.write(_("Error: The file '%s' was made using an\nincompatible version of Sabacc!\n") %filename)
View
0 sabacc/constants.py → src/sabacc/old_sabacc/constants.py
File renamed without changes.
View
6 tests/game_test.py → src/sabacc/old_sabacc/game_test.py
@@ -6,8 +6,8 @@
import mox
-import sabacc.back.Agents as agents
-import sabacc.back.Game as game
+import old_sabacc.back.Agents as agents
+import old_sabacc.back.Game as game
# TODO: Move this to a common location
class MockableTestCase(unittest.TestCase):
@@ -104,4 +104,4 @@ def test_maximum_bet_too_high(self):
if __name__ == "__main__":
- unittest.main()
+ unittest.main()
View
6 sabacc/get_settings.py → src/sabacc/old_sabacc/get_settings.py
@@ -23,7 +23,7 @@
from lxml import etree # xml parser
import gettext; _=gettext.gettext # gettext for translations
-import sabacc.constants as constants
+import old_sabacc.constants as constants
def get_rule_sets():
'''Find the list of rule sets and their data and return it as a dictionary'''
@@ -185,7 +185,7 @@ def load_settings_file():
import sys
sys.exit(_("Error: The file '%s' is not a Sabacc file!\n") %filename)
- from sabacc import __major_version__
+ from old_sabacc import __major_version__
if (xml_version < constants.lowest_xml_version
or xml_version > __major_version__):
@@ -239,4 +239,4 @@ def get_cards_dir():
initial_credits = get_setting('initial_credits')
card_set = get_setting('card_set')
rule_sets = get_rule_sets()
-cards_dir = get_cards_dir()
+cards_dir = get_cards_dir()
View
3 src/sabacc/old_sabacc/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
View
7 src/sabacc/old_sabacc/tests.py
@@ -0,0 +1,7 @@
+from django.utils import unittest
+
+from . import game_test
+
+def suite():
+ loader = unittest.TestLoader()
+ return loader.loadTestsFromTestCase(game_test.GameTests)
View
1 src/sabacc/old_sabacc/views.py
@@ -0,0 +1 @@
+# Create your views here.
View
5 online_sabacc/settings.py → src/sabacc/settings.py
@@ -11,8 +11,8 @@
DATABASES = {
'default': {
- 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
- 'NAME': '', # Or path to database file if using sqlite3.
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': 'sabacc.db',
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
@@ -119,6 +119,7 @@
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
+ "old_sabacc",
)
# A sample logging configuration. The only tangible logging
View
3 settings.xml → src/sabacc/settings.xml
@@ -1,4 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
+<!-- TODO: Replace this file with a ConfigParser-type file -->
<sabacc version='1'>
<rule_sets>
<rule_set name='bold' upper='18' lower='-18' />
@@ -26,4 +27,4 @@
<setting name='initial_credits' value='500' />
<setting type='str' name='card_set' value='swag' />
</settings>
-</sabacc>
+</sabacc>
View
0 online_sabacc/urls.py → src/sabacc/urls.py
File renamed without changes.

0 comments on commit 12d45d0

Please sign in to comment.