()
| 48 | |
| 49 | |
| 50 | def main(): |
| 51 | bext.bg('black') |
| 52 | bext.fg('white') |
| 53 | bext.clear() |
| 54 | print('''Flooder, by Al Sweigart al@inventwithpython.com |
| 55 | |
| 56 | Set the upper left color/shape, which fills in all the |
| 57 | adjacent squares of that color/shape. Try to make the |
| 58 | entire board the same color/shape.''') |
| 59 | |
| 60 | print('Do you want to play in colorblind mode? Y/N') |
| 61 | response = input('> ') |
| 62 | if response.upper().startswith('Y'): |
| 63 | displayMode = SHAPE_MODE |
| 64 | else: |
| 65 | displayMode = COLOR_MODE |
| 66 | |
| 67 | gameBoard = getNewBoard() |
| 68 | movesLeft = MOVES_PER_GAME |
| 69 | |
| 70 | while True: # Main game loop. |
| 71 | displayBoard(gameBoard, displayMode) |
| 72 | |
| 73 | print('Moves left:', movesLeft) |
| 74 | playerMove = askForPlayerMove(displayMode) |
| 75 | changeTile(playerMove, gameBoard, 0, 0) |
| 76 | movesLeft -= 1 |
| 77 | |
| 78 | if hasWon(gameBoard): |
| 79 | displayBoard(gameBoard, displayMode) |
| 80 | print('You have won!') |
| 81 | break |
| 82 | elif movesLeft == 0: |
| 83 | displayBoard(gameBoard, displayMode) |
| 84 | print('You have run out of moves!') |
| 85 | break |
| 86 | |
| 87 | |
| 88 | def getNewBoard(): |
no test coverage detected