def _checkEndConditions(self, player, row, column): if len(self._player1Drops) + len(self._player2Drops) < 7: return elif len(self._player1Drops) + len(self._player2Drops) == self._width * self._height: raise GameHasBeenEnded elif player == 1 and Rules.check(row, column, self._player1Drops): raise Player1Wins elif player == 2 and Rules.check(row, column, self._player2Drops): raise Player2Wins
def test_win_on_misc_cross_rule(self): buttons = [Button(0,5), Button(2,5), Button(1,4), Button(3,4), Button(2,3), Button(3,2)] self.assertTrue(Rules.check(5, 0, buttons))
def test_win_on_descending_cross_rule(self): buttons = [Button(0,3), Button(1,2), Button(2,1), Button(3,0)] self.assertTrue(Rules.check(1, 2, buttons))
def test_win_on_vertical_rule(self): buttons = [Button(0,0), Button(0,1), Button(0,2), Button(0,3)] self.assertTrue(Rules.check(0, 0, buttons))
def test_win_on_horizontal_rule(self): buttons = [Button(0,0), Button(1,0), Button(2,0), Button(3,0)] self.assertTrue(Rules.check(0, 2, buttons))
def test_no_win_on_any_rule(self): buttons = [Button(0,0)] self.assertFalse(Rules.check(0, 0, buttons))