MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / main

Function main

src/gamesbyexample/barca.py:74–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72
73
74def main():
75 print("""Barca, by Al Sweigart al@inventwithpython.com
76Barca is a chess variant where each player has two mice (which move like
77chess rooks), lions (bishops), and elephants (queens). The object of the
78game is to occupy three of the four "watering hole" spaces near the
79middle of the board.
80
81Mice are afraid of lions, lions are afraid of elephants, and elephants
82are afraid of mice. Afraid animals are in "check", and must move away
83before other animals can move.
84
85Barca 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
106def getNewBoard():

Callers 1

barca.pyFile · 0.70

Calls 4

getNewBoardFunction · 0.70
displayBoardFunction · 0.70
doPlayerMoveFunction · 0.70
isWinnerFunction · 0.70

Tested by

no test coverage detected