Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def playHand(hand, wordList, n):
- lettervalue=calculateHandlen(hand)
- score=0
- while lettervalue>0:
- displayHand(hand)
- userinput=raw_input('Enter word, or a "." to indicate that you are finished:')
- if userinput==".":
- print "Goodbye! Total score: %d points."%(score)
- return
- else:
- if isValidWord(userinput, hand, wordList):
- lettervalue-=len(userinput)
- score+=getWordScore(userinput, n)
- print "%s earned %d points. Total: %d points"%(userinput,getWordScore(userinput, n),score)
- else:
- print "Invalid word, please try again."
- print "Run out of letters. Total score: %d points."%(score)
- def playGame(wordList):
- offswitch=0
- temph=[]
- while offswitch==0:
- interinput=raw_input("Enter n to deal a new hand, r to replay the last hand, or e to end game: ")
- if interinput=='e':
- offswitch=1
- break
- if interinput=='n':
- gamesplayed=1
- newh=dealHand(HAND_SIZE)
- temph=newh.copy()
- playHand(newh, wordList, HAND_SIZE)
- if interinput=='r':
- if temph==[]:
- print "You have not played a hand yet. Please play a new hand first!"
- else:
- playHand(temph, wordList, HAND_SIZE)
- if interinput !=('e','r','n'):
- print "Invalid Command"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement