()
| 72 | |
| 73 | |
| 74 | def main(): |
| 75 | print("""Barca, by Al Sweigart al@inventwithpython.com |
| 76 | Barca is a chess variant where each player has two mice (which move like |
| 77 | chess rooks), lions (bishops), and elephants (queens). The object of the |
| 78 | game is to occupy three of the four "watering hole" spaces near the |
| 79 | middle of the board. |
| 80 | |
| 81 | Mice are afraid of lions, lions are afraid of elephants, and elephants |
| 82 | are afraid of mice. Afraid animals are in "check", and must move away |
| 83 | before other animals can move. |
| 84 | |
| 85 | Barca was invented by Andrew Caldwell http://playbarca.com |
| 86 | """) |
| 87 | input('Press Enter to begin...') |
| 88 | |
| 89 | turn = ROUND_PLAYER |
| 90 | gameBoard = getNewBoard() |
| 91 | while True: # Main game loop. |
| 92 | displayBoard(gameBoard) |
| 93 | |
| 94 | doPlayerMove(turn, gameBoard) |
| 95 | if isWinner(turn, gameBoard): |
| 96 | print(turn, 'has won!') |
| 97 | sys.exit() |
| 98 | |
| 99 | # Switch turns to the next player. |
| 100 | if turn == SQUARE_PLAYER: |
| 101 | turn = ROUND_PLAYER |
| 102 | elif turn == ROUND_PLAYER: |
| 103 | turn = SQUARE_PLAYER |
| 104 | |
| 105 | |
| 106 | def getNewBoard(): |
no test coverage detected