Exemplo n.º 1
0
 def loop(self):
     #Main loop
     while (True):
         print(str(self.current_leader) + ", pick a word!")
         self.current_word = Word(input())
         self.guesses = MAX_GUESSES
         print("\n"*20)
         
         while (True):
             #Loop through players which are non-leaders
             for player in [player for player in self.players if player != self.current_leader]:
                 if (self.guesses > 0):
                     self.current_word.print_word()
                     player.turn(self.current_word)
                 else:
                     print("No guesses left, " + str(self.current_leader) + " +3 points!")
                     self.current_leader.score += 3
                     break
                 if (self.guessed): 
                     break
             else:
                 continue; #Executed if the loop finished without breaking
             break #This never gets called until the above "continue" isn't called (which happens when break is called within the inner loop)
         
         print("Keep playing? y/n")
         
         choice = get_choice(("y","n"))
         if (choice == "n"):
             self.end_game()
             break
         elif (choice == "y"):
             self.clear_vars()
             continue
Exemplo n.º 2
0
 def ask(self):
     decision = util.get_choice(*Commands,
             in_handler=sys.stdin, out_handler=sys.stdout)
     return decision