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

Method eventWildCard

recipes/Python/580811_Uno_TextBased/recipe-580811.py:968–1015  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

966 self.event = ''
967
968 def eventWildCard(self):
969 hide = False
970 if not self.forcedWild:
971 if self.players[self.turn].getType() == 'Human':
972 self.elements['Console'] = 'Wild Card! Specifiy a Color: (B)lue, (R)ed, (G)reen, (Y)ellow'
973 self.elements['Error'] = 'Specifiy A Color'
974 print(self.drawScreen())
975 playerInput = str(input("Color Change: "))
976 checked = self.checkColorInput(playerInput)
977 while not checked['valid']:
978 if checked['entry'] == '<':
979 self.handPosition -= 1
980 if self.handPosition == -1:
981 self.handPosition = self.players[self.turn].maxScroll
982 self.buildHandVisual(self.turn)
983 elif checked['entry'] == '>':
984 self.handPosition += 1
985 if self.handPosition > self.players[self.turn].maxScroll:
986 self.handPosition = 0
987 self.buildHandVisual(self.turn)
988 print(self.drawScreen())
989 playerInput = str(input("Color Change: "))
990 checked = self.checkColorInput(playerInput)
991 else:
992 hide = self.hideComputerHands
993 checked = self.checkColorInput(self.players[self.turn].getWildColor())
994 self.wildColorChange = checked['entry']
995 else:
996 self.wildColorChange = self.checkColorInput(random.choice(('r','b','g','y')))['entry']
997 self.forcedWild = False
998 self.currentColor = self.wildColorChange
999 self.elements['Error'] = ""
1000 if self.displayEffects and not self.simulation:
1001 self.elements['Console'] = 'Wild Card! Changing Color.'
1002 seed = 1
1003 for i in range(10):
1004 i #unused
1005 if seed > 4:
1006 seed = 1
1007 print(self.drawScreen(hide,wildSeed=seed))
1008 time.sleep(.1)
1009 seed += 1
1010 self.pile[0].changeColor(self.wildColorChange)
1011 self.wildColorChange = ''
1012 cardBigNums = self.pile[0].getBigNum(self.reverse)
1013 self.elements['oHeader'] = '{}\u2666\u2666\u2666=========\u2666\u2666\u2666\033[0m\t'.format(self.pile[0].getColorCode())
1014 self.elements['oMiddle'] = cardBigNums
1015 self.event = ''
1016
1017 def eventDraw(self):
1018 self.players[self.turn].addForceDraw(self.drawAmount)

Callers 2

beginMethod · 0.95
nextTurnMethod · 0.95

Calls 13

drawScreenMethod · 0.95
checkColorInputMethod · 0.95
buildHandVisualMethod · 0.95
printFunction · 0.85
strFunction · 0.85
rangeFunction · 0.85
getTypeMethod · 0.80
getWildColorMethod · 0.80
changeColorMethod · 0.80
getBigNumMethod · 0.80
getColorCodeMethod · 0.80
sleepMethod · 0.45

Tested by

no test coverage detected