Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1. def playHand(hand, wordList, n):
  2.     lettervalue=calculateHandlen(hand)
  3.     score=0
  4.     while lettervalue>0:
  5.         displayHand(hand)
  6.         userinput=raw_input('Enter word, or a "." to indicate that you are finished:')
  7.         if userinput==".":
  8.             print "Goodbye! Total score: %d points."%(score)        
  9.             return
  10.         else:
  11.             if isValidWord(userinput, hand, wordList):
  12.                 lettervalue-=len(userinput)
  13.                 score+=getWordScore(userinput, n)
  14.                 print "%s earned %d points. Total: %d points"%(userinput,getWordScore(userinput, n),score)
  15.             else:
  16.                 print "Invalid word, please try again."
  17.     print "Run out of letters. Total score: %d points."%(score)
  18.  
  19. def playGame(wordList):
  20.     offswitch=0
  21.     temph=[]
  22.     while offswitch==0:
  23.         interinput=raw_input("Enter n to deal a new hand, r to replay the last hand, or e to end game: ")
  24.  
  25.         if interinput=='e':
  26.             offswitch=1
  27.             break
  28.         if interinput=='n':
  29.             gamesplayed=1
  30.             newh=dealHand(HAND_SIZE)
  31.             temph=newh.copy()
  32.             playHand(newh, wordList, HAND_SIZE)
  33.         if interinput=='r':
  34.             if temph==[]:
  35.                 print "You have not played a hand yet. Please play a new hand first!"
  36.             else:
  37.                 playHand(temph, wordList, HAND_SIZE)
  38.         if interinput !=('e','r','n'):
  39.             print "Invalid Command"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement