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

Function main

src/gamesbyexample/flooder.py:50–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48
49
50def main():
51 bext.bg('black')
52 bext.fg('white')
53 bext.clear()
54 print('''Flooder, by Al Sweigart al@inventwithpython.com
55
56Set the upper left color/shape, which fills in all the
57adjacent squares of that color/shape. Try to make the
58entire 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
88def getNewBoard():

Callers 1

flooder.pyFile · 0.70

Calls 6

changeTileFunction · 0.85
clearMethod · 0.80
getNewBoardFunction · 0.70
displayBoardFunction · 0.70
askForPlayerMoveFunction · 0.70
hasWonFunction · 0.70

Tested by

no test coverage detected