Exemplo n.º 1
0
 def test_king_isvalid(self):
     '''King move validation'''
     testdata = {King('white'): [(4, 0), (4, 1), True],
                 King('white'): [(4, 0), (4, 2), False],
                 }
     for piece, (start, end, ans) in testdata.items():
         result = piece.isvalid(start, end)
         self.assertEqual(result, ans)
Exemplo n.º 2
0
 def test_no_jump(self):
     '''Pieces cannot jump over pieces of same colour'''
     game = Board(debug=True)
     game.add((4, 1), King('white'))
     game.add((4, 4), Rook('white'))
     game.add((4, 6), King('black'))
     game.add((4, 3), Rook('black'))
     game.turn, game.other_turn = 'white', 'black'
     self.assertFalse(game.valid_move((4, 4), (4, 0)))
     self.assertFalse(game.valid_move((4, 3), (4, 7)))
Exemplo n.º 3
0
def gameSetupWithKings():
    game = Board(debug=True)
    game.add((4, 0), King('white'))
    game.add((4, 7), King('black'))
    return game