예제 #1
0
        def clicked():
            numGuesses = ui.guessLeft.value()
            global guessedLetters
            guess = ""
            if numGuesses > 0:
                availableLetters = getAvailableLetters(guessedLetters)
                if isWordGuessed(secretWord, guessedLetters):
                    ui.msg.setText("Congratulations, you won!")
                    usersMongo.updateAttempts(username, secretWord, 1)
                    
                    #break
                guess = str(ui.input.text())

                guess = guess.lower()
                if guess not in availableLetters:
                    ui.msg.setText("Oops! You've already guessed that letter")
                    updateWord()
                    ui.input.setText("")
                elif guess in secretWord:
                    guessedLetters = guessedLetters + guess
                    ui.msg.setText("Good Guess: ")
                    updateWord()
                    ui.input.setText("")
                else:
                    guessedLetters = guessedLetters + guess
                    ui.msg.setText("Oops! That letter is not in my word: ")
                    updateWord()
                    ui.guessLeft.setProperty("value", float(ui.guessLeft.value()-1))
                    ui.input.setText("")
            if numGuesses == 0:
                ui.msg.setText("Sorry! You loose "+secretWord+" was the word")
                usersMongo.updateAttempts(username, secretWord, -1)
                
            print "Prathamesh"+guess
예제 #2
0
 def process():
     final = sel.getChoice()
     print "The fianl choice is ",final
     ui.option1.setEnabled(False)
     ui.option2.setEnabled(False)
     ui.option3.setEnabled(False)
     ui.option4.setEnabled(False)
     if start.fourWords[final -1][1] == start.correctMeaning:
         print 'That is correct sending data to ML'
         usersMongo.updateAttempts(username, start.wordToGuess, 1)
         print final
         if final == 1:
             ui.option1.setStyleSheet(_fromUtf8("background-color: #33cc33;\n"))
         elif final == 2:
             ui.option2.setStyleSheet(_fromUtf8("background-color: #33cc33;\n"))
         elif final == 3:
             ui.option3.setStyleSheet(_fromUtf8("background-color: #33cc33;\n"))
         else:
             ui.option4.setStyleSheet(_fromUtf8("background-color: #33cc33;\n"))
     else:
         print 'That is wrong sending data to ML'
         usersMongo.updateAttempts(username, start.wordToGuess, -1)
         print final
         if final == 1:
             ui.option1.setStyleSheet(_fromUtf8("background-color: #cc3300;\n"))
         elif final == 2:
             ui.option2.setStyleSheet(_fromUtf8("background-color: #cc3300;\n"))
         elif final == 3:
             ui.option3.setStyleSheet(_fromUtf8("background-color: #cc3300;\n"))
         else:
             ui.option4.setStyleSheet(_fromUtf8("background-color: #cc3300;\n"))
         for i in range(4):
             if start.fourWords[i][1] == start.correctMeaning:
                 if i == 0:
                     ui.option1.setStyleSheet(_fromUtf8("background-color: #33cc33;\n"))
                 elif i == 1:
                     ui.option2.setStyleSheet(_fromUtf8("background-color: #33cc33;\n"))
                 elif i == 2:
                     ui.option3.setStyleSheet(_fromUtf8("background-color: #33cc33;\n"))
                 else:
                     ui.option4.setStyleSheet(_fromUtf8("background-color: #33cc33;\n"))
     app.processEvents()
     time.sleep(2)
     playModule2()