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

Method checkInput

recipes/Python/580811_Uno_TextBased/recipe-580811.py:887–902  ·  view source on GitHub ↗
(self, playerInput)

Source from the content-addressed store, hash-verified

885 self.elements['HVisual'] = string
886
887 def checkInput(self, playerInput):
888 if playerInput == '':
889 return {'valid':False,'entry':playerInput}
890 if playerInput.isnumeric():
891 if int(playerInput)+(10*self.handPosition) < self.players[self.turn].getCardNum():
892 return {'valid':True,'entry':str(int(playerInput)+(10*self.handPosition)),'type':'card'}
893 else:
894 self.elements['Error'] = '{} is not a card.'.format(playerInput)
895 return {'valid':False,'entry':playerInput}
896 else:
897 playerInput = playerInput.lower()[0]
898 if playerInput in ['<','>','u','d','p','q','s']:
899 return {'valid':True,'entry':playerInput}
900 else:
901 self.elements['Error'] = '{} is not a valid selection.'.format(playerInput)
902 return {'valid':False,'entry':playerInput}
903
904 def checkColorInput(self, playerInput):
905 if playerInput == '':

Callers 1

nextTurnMethod · 0.95

Calls 4

strFunction · 0.85
getCardNumMethod · 0.80
formatMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected