Ejemplo n.º 1
0
 def test_ifRemoveWorks(self):
     bc = BallContainer()
     bc.add(BallColors.BLACK, 5)
     bc.add(BallColors.WHITE, 2)
     bc.removeOne(BallColors.WHITE)
     self.assertEquals(bc.get(BallColors.BLACK), 5)
     self.assertEquals(bc.get(BallColors.WHITE), 1)
     bc.removeOne(BallColors.BLACK)
     self.assertEquals(bc.get(BallColors.BLACK), 4)
Ejemplo n.º 2
0
 def __init__(self):
     self.board = Board.createEmptyBoard37() # TODO maybe factory method instead of @classmethod ?
     self.balls = BallContainer()
     self.balls.add(BallColors.WHITE, 6)
     self.balls.add(BallColors.GRAY, 8)
     self.balls.add(BallColors.BLACK, 10)
     self.players = {Players.PLY1: BallContainer(), Players.PLY2: BallContainer()}
     self.currPlayer = Players.PLY1
Ejemplo n.º 3
0
class Game:
    """
    Game state, including board, balls and who is going to make the move now.
    """

    def __init__(self):
        self.board = Board.createEmptyBoard37() # TODO maybe factory method instead of @classmethod ?
        self.balls = BallContainer()
        self.balls.add(BallColors.WHITE, 6)
        self.balls.add(BallColors.GRAY, 8)
        self.balls.add(BallColors.BLACK, 10)
        self.players = {Players.PLY1: BallContainer(), Players.PLY2: BallContainer()}
        self.currPlayer = Players.PLY1

    def getPlayer(self, ply):
        return self.players[ply]

    def getBoard(self):
        return self.board

    def getCurrentPlayerName(self):
        return self.currPlayer

    def getRemainingBalls(self):
        return self.balls

    def nextPlayer(self):
        if self.currPlayer == Players.PLY1:
            self.currPlayer = Players.PLY2
        else:
            self.currPlayer = Players.PLY1
        return self.currPlayer

    def getCurrentPlayerBalls(self):
        return self.players[ self.currPlayer ]
Ejemplo n.º 4
0
 def test_ifAddWorks(self):
     bc = BallContainer()
     bc.add(BallColors.WHITE, 1)
     self.assertEqual(bc.get(BallColors.WHITE), 1)
     bc.add(BallColors.WHITE, 2)
     self.assertEqual(bc.get(BallColors.WHITE), 3)