Пример #1
0
def exitGame(lang, prompt, retries=3):
    negativa = ['n', 'no']
    positive = ['y', 'yes']
    positiva = ['s', 'si']
    while True:
        ok = input(prompt)
        respuesta = ok.lower()
        if respuesta in negativa:
            system('clear')
            print()
            efects.Writer(admin.Plus + language(lang)(17), 3)
            print('\n')
            exit()
        elif respuesta in positive or respuesta in positiva:
            #system('clear')
            print()
            efects.Writer(admin.Plus + language(lang)(18), 3)
            sleep(1)
            system('clear')
            return True
        else:
            retries -= 1
            if retries < 0:
                print()
                efects.Writer(admin.Minus + language(lang)(19), 3)
                print('\n')
                exit()
            print()
            print(admin.Warning + language(lang)(16))
Пример #2
0
def userLoss(lang, word):
    system("clear")
    print(color.red + language(lang)(14) + color.white)
    efects.Writer(tries.images.get(6), 1)
    print(color.red + language(lang)(15), color.yellow + word)
    efects.Writer(color.red + language(lang)(9), 8)
    return False
Пример #3
0
def userWin(lang, word, prompt):
    if prompt == word:
        system('clear')
        print(color.green + language(lang)(7) + color.white)
        efects.Writer(tries.images.get(7), 1)
        print(color.green + language(lang)(8), color.yellow + word)
        efects.Writer(color.red + language(lang)(9), 8)
        return True
    else:
        return False
Пример #4
0
def showImage(lang, clue, trie, mask, inputs): 
    print('\n\t {0} '.format(clue))
    print(tries.images.get(trie))
    joinMask=' '.join(mask)
    print(color.yellow+'\n    ',joinMask)
    inputs="".join(inputs)
    if ' ' in mask:
        x=len(mask)-1
    else:
        x=len(mask)
    print('\n')
    print(admin.Info+ language(lang)(0),color.yellow+str(x))
    print(admin.Info+language(lang)(1),color.red+str(6-trie))
    print(admin.Info+language(lang)(2),inputs)
Пример #5
0
def hangman(lang):
    userTries=0
    inputs=[color.pink+'']
    word,clue=randomWord()
    mask=maskWord(word)
    while True:
        unMask="".join(mask)
        win= validate.userWin(lang, word, unMask)
        if win==True:
            break
        showImage(lang, "Pista|Clue: "+clue, userTries, mask, inputs)
        print('\n')
        print(admin.Run+language(lang)(3),end=' ')
        letter=input(color.green+'')
        incognito=validate.userWin_or_Lose(lang, letter, word)
        if incognito=='userWin' or incognito==word:
            validate.userWin(lang, word, word)
            break
        elif incognito=='userLoss':
            validate.userLoss(lang, word)
            break
        prompt=validate.userInput(lang, letter, inputs, word)
        if prompt=='userLoss':
            validate.userLoss(lang, word)
            break
        win=validate.userWin(lang, word,prompt)
        if win==True:
            break
        inputs.append(prompt)
        inputs.append(',')
        if prompt in word:
            for i in range(len(word)):
                if word[i]==prompt:
                    mask[i]=prompt                     
            num=word.count(prompt)
            print()
            efects.Writer(admin.Good+language(lang)(4).format(str(num)) ,4)
            sleep(2)
        elif userTries==5:
            validate.userLoss(lang, word)
            break
        else:
            print()               
            efects.Writer(admin.Wrong+language(lang)(5),4)   
            sleep(1)
            userTries+=1        
        system("clear")
Пример #6
0
def userInput(lang, prompt, inputs, word):
    while True:
        answer = ' '
        prompt = prompt.lower()
        if prompt == 'exit' or prompt == 'guess':
            incognito = userWin_or_Lose(lang, prompt, word)
            return incognito
        if prompt in answer or prompt in inputs or len(prompt) > 1:
            if prompt in inputs:
                print()
                print(admin.Warning + language(lang)(11))
                print()
                prompt = input(admin.Run + language(lang)(12) + color.green)
            else:
                print()
                print(admin.Warning + language(lang)(13))
                print()
                prompt = input(admin.Run + language(lang)(12) + color.green)
        else:
            return prompt
Пример #7
0
def userWin_or_Lose(lang, prompt, word):
    if prompt == 'exit':
        print()
        exit()
    elif prompt == 'guess':
        print()
        print(admin.Run + language(lang)(10), end=' ')
        solution = input('' + color.green)
        if solution == word:
            return word
        else:
            return 'userLoss'
    else:
        return
Пример #8
0
                if word[i]==prompt:
                    mask[i]=prompt                     
            num=word.count(prompt)
            print()
            efects.Writer(admin.Good+language(lang)(4).format(str(num)) ,4)
            sleep(2)
        elif userTries==5:
            validate.userLoss(lang, word)
            break
        else:
            print()               
            efects.Writer(admin.Wrong+language(lang)(5),4)   
            sleep(1)
            userTries+=1        
        system("clear")
    
if __name__=='__main__':
    while True:
        print(' Hangman Game (', end=' ')
        lang=input(color.yellow+'En'+color.white+'glish | '+color.yellow+'Es'+color.white+'pañol ): '+color.green)
        print('\n')
        begining()
        language(lang)
        print()     
        print(rules.rules)
        hangman(lang)
        print('\n')             
        print(admin.Question+language(lang)(6)+color.yellow+'Y'+color.white+'es | '+color.yellow+'N'+color.white+'o')
        print()
        exitGame.exitGame(lang, admin.Run+' DecosSoft»» '+color.green)