Fix gamestate setup.
authorSimon Cross <hodgestar@gmail.com>
Sun, 11 May 2014 17:24:53 +0000 (19:24 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sun, 11 May 2014 17:26:13 +0000 (19:26 +0200)
naja/gameboard.py
naja/gamestate.py

index 123f3be6d6bf059187f4ac97357f306e613cf625..5ec61507c7e31a5b10b7c28780b427414e97c462 100644 (file)
@@ -20,7 +20,8 @@ class GameBoard(object):
         self.board_locations = board_locations
 
     @classmethod
-    def new_game(cls, max_health, wins_required, locations_definition):
+    def new_game(cls, initial_bits, initial_pos, max_health, wins_required,
+                 locations_definition):
         state = {
             'max_health': max_health,
             'health': max_health,
@@ -28,7 +29,7 @@ class GameBoard(object):
             'wins': 0,
             'locations': locations_definition,
         }
-        player = Player(0x0f, (2, 2))
+        player = Player(initial_bits, initial_pos)
         board_locations = cls.generate_board(locations_definition)
         return cls(state, player, board_locations)
 
index a2eb77b2de2aea3dae40fee8a08d5e12272af3cd..dabf34a9c23311c6302d06242dc2688dce5d50b8 100644 (file)
@@ -4,7 +4,6 @@ The current game state.
 
 from naja.constants import BITS
 from naja.gameboard import GameBoard
-from naja.player import Player
 
 
 class GameState(object):
@@ -20,6 +19,13 @@ class GameState(object):
     WINS_REQUIRED = 4
 
     def __init__(self):
-        self.player = Player(self.INITIAL_BITS, (0, 0))
-        self.gameboard = GameBoard(
-            self.player, self.MAX_HEALTH, self.WINS_REQUIRED)
+        self.gameboard = GameBoard.new_game(
+            initial_bits=self.INITIAL_BITS,
+            initial_pos=(2, 2),
+            max_health=self.MAX_HEALTH,
+            wins_required=self.WINS_REQUIRED,
+            locations_definition=[])  # TODO: we will need some of these :)
+
+    @property
+    def player(self):
+        return self.gameboard.player