1""" The Racing Kings Variation"""
2
3from pychess.Utils.const import RACINGKINGSCHESS, VARIANTS_OTHER_NONSTANDARD, \
4    A8, B8, C8, D8, E8, F8, G8, H8
5from pychess.Utils.Board import Board
6
7RACINGKINGSSTART = "8/8/8/8/8/8/krbnNBRK/qrbnNBRQ w - - 0 1"
8
9RANK8 = (A8, B8, C8, D8, E8, F8, G8, H8)
10
11
12class RacingKingsBoard(Board):
13    """ :Description: The Racing Kings variation is where the object of the game
14        is to bring your king to the eight row.
15    """
16    variant = RACINGKINGSCHESS
17    __desc__ = _(
18        "In this game, check is entirely forbidden: not only is it forbidden\n" +
19        "to move ones king into check, but it is also forbidden to check the opponents king.\n" +
20        "The purpose of the game is to be the first player that moves his king to the eight row.\n" +
21        "When white moves their king to the eight row, and black moves directly after that also\n" +
22        "their king to the last row, the game is a draw\n" +
23        "(this rule is to compensate for the advantage of white that they may move first.)\n" +
24        "Apart from the above, pieces move and capture precisely as in normal chess."
25    )
26    name = _("Racing Kings")
27    cecp_name = "racingkings"
28    need_initial_board = True
29    standard_rules = False
30    variant_group = VARIANTS_OTHER_NONSTANDARD
31
32    def __init__(self, setup=False, lboard=None):
33        if setup is True:
34            Board.__init__(self, setup=RACINGKINGSSTART, lboard=lboard)
35        else:
36            Board.__init__(self, setup=setup, lboard=lboard)
37
38
39def testKingInEightRow(board):
40    """ Test for a winning position """
41    return board.kings[board.color - 1] in RANK8
42
43
44def test2KingInEightRow(board):
45    """ Test for a winning position """
46    return board.kings[board.color] in RANK8 and board.kings[board.color - 1] in RANK8
47