MCPcopy Create free account
hub / github.com/ActiveState/code / mainMenu

Function mainMenu

recipes/Python/580811_Uno_TextBased/recipe-580811.py:1333–1382  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1331 os.system('cls' if os.name == 'nt' else 'clear')
1332
1333 def mainMenu():
1334 sys.stdout.write("\x1b[8;32;63t")
1335 sys.stdout.flush()
1336 gs = GameSettings()
1337
1338 while True:
1339
1340 print(drawMainMenu(gs))
1341
1342 selection = str(input('\033[97mSelection: \033[92m'))
1343 while selection not in ['1', '2', '3', '4', '5']:
1344 gs.mainMenuError = "Invalid Selection"
1345 print(drawMainMenu(gs))
1346 selection = str(input('\033[97mSelection: \033[92m'))
1347
1348 if selection == '1':
1349 if gs.canBegin():
1350 gs.mainMenuError = ""
1351 gs.finalizePlayers()
1352 gs = playMatch(gs)
1353 else:
1354 gs.mainMenuError = "Two Players Required to Begin"
1355
1356 elif selection == '2':
1357 if gs.canAddPlayer():
1358 gs.mainMenuError = ""
1359 gs = addPlayer(gs)
1360 else:
1361 gs.mainMenuError = "Max Number of Players Reached"
1362
1363 elif selection == '3':
1364 if gs.canAddPlayer():
1365 gs.mainMenuError = ""
1366 gs = addComputer(gs)
1367 else:
1368 gs.mainMenuError = "Max Number of Players Reached"
1369
1370 elif selection == '4':
1371 if gs.canRemovePlayer():
1372 gs.mainMenuError = ""
1373 gs = removePlayer(gs)
1374 else:
1375 gs.mainMenuError = "No Players to Remove"
1376
1377 elif selection == '5':
1378 gs.mainMenuError = ""
1379 gs = settingsMenu(gs)
1380
1381 else:
1382 raise BadInputError('Data Provided Has No Function')
1383
1384 def playMatch(gs):
1385 for i in range(1):

Callers 1

UnoFunction · 0.70

Calls 15

canBeginMethod · 0.95
finalizePlayersMethod · 0.95
canAddPlayerMethod · 0.95
canRemovePlayerMethod · 0.95
GameSettingsClass · 0.85
printFunction · 0.85
drawMainMenuFunction · 0.85
strFunction · 0.85
playMatchFunction · 0.85
addPlayerFunction · 0.85
addComputerFunction · 0.85
removePlayerFunction · 0.85

Tested by

no test coverage detected