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

Function addPlayer

recipes/Python/580811_Uno_TextBased/recipe-580811.py:1394–1421  ·  view source on GitHub ↗
(gs)

Source from the content-addressed store, hash-verified

1392 return gs
1393
1394 def addPlayer(gs):
1395 colors = ['\033[91m','\033[94m', '\033[92m', '\033[93m']
1396 nameOkay = False
1397 playerNum = gs.getPlayerNum() + 1
1398 colorIndex = playerNum - 1
1399 message = "\033[97mPlease Enter Player {}'s Name: {}".format(playerNum, colors[colorIndex])
1400
1401 while not nameOkay:
1402 print(drawMainMenu(gs))
1403 name = str(input(message)).title()
1404 if len(name) > 11:
1405 gs.mainMenuError = "Name Must Be 11 Characters or Less!"
1406 elif len(name) == 0:
1407 gs.mainMenuError = ""
1408 return gs
1409 else:
1410 nameOkay = True
1411 for player in gs.playerStaging:
1412 if player.getName() == name:
1413 nameOkay = False
1414 if nameOkay == False or name in GameSettings.computerNames:
1415 gs.mainMenuError = "Name Cannot Match Another Player's Name!"
1416
1417 p = Player(name)
1418 gs.addPlayer(p)
1419 gs.mainMenuError = ""
1420
1421 return gs
1422
1423 def addComputer(gs):
1424 name = gs.getComputerName()

Callers 1

mainMenuFunction · 0.85

Calls 9

printFunction · 0.85
drawMainMenuFunction · 0.85
strFunction · 0.85
getPlayerNumMethod · 0.80
addPlayerMethod · 0.80
PlayerClass · 0.70
formatMethod · 0.45
titleMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected