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

Function askForPlayerMove

src/gamesbyexample/parkingvalet.py:207–219  ·  view source on GitHub ↗

Let the player enter the car and direction they want to move.

(board)

Source from the content-addressed store, hash-verified

205
206
207def askForPlayerMove(board):
208 """Let the player enter the car and direction they want to move."""
209 validMoves = getValidMoves(board)
210 while True:
211 allValidMoves = '", "'.join(validMoves)
212 print('Moves: "{}", "RESET", or "QUIT".'.format(allValidMoves))
213 move = input('> ').upper()
214 if move == 'QUIT':
215 sys.exit()
216 if move == 'RESET':
217 return 'RESET'
218 if move in validMoves:
219 return move
220
221
222# If this program was run (instead of imported), run the game:

Callers 1

mainFunction · 0.70

Calls 1

getValidMovesFunction · 0.70

Tested by

no test coverage detected