Returns an (x, y) tuple of the player's move.
(previousMoves)
| 101 | return 'Sonar did not detect anything. All treasure chests out of range.' |
| 102 | |
| 103 | def askForPlayerMove(previousMoves): |
| 104 | """Returns an (x, y) tuple of the player's move.""" |
| 105 | print('Where do you want to drop the next sonar device?') |
| 106 | print('(0-59 0-14 or enter QUIT)') |
| 107 | while True: |
| 108 | move = input('> ') |
| 109 | if move.upper() == 'QUIT': |
| 110 | print('Thanks for playing!') |
| 111 | sys.exit() |
| 112 | |
| 113 | move = move.split() |
| 114 | if len(move) == 2 and move[0].isdecimal() and move[1].isdecimal() and isOnBoard(int(move[0]), int(move[1])): |
| 115 | if [int(move[0]), int(move[1])] in previousMoves: |
| 116 | print('You already moved there.') |
| 117 | continue |
| 118 | return (int(move[0]), int(move[1])) |
| 119 | |
| 120 | print('Enter a number from 0 to 59, a space, then a number') |
| 121 | print('from 0 to 14.') |
| 122 | |
| 123 | def showInstructions(): |
| 124 | """Display the game instructions.""" |