Python猜谜游戏:5个测验中的任何一个失败都会跳过所有剩余的测验,直接进入结果

时间:2019-06-05 16:17:53

标签: python

所以我正在研究一个简单的python猜谜游戏。共有5个测验。但是,如果我没有通过任何一项,其余的测验将被跳过,直接进入结果。请注意,代码的某些部分仅用于装饰目的。

movie_name = "WRECK IT RALPH"
movie_name2 = "AVENGERS ENDGAME"
movie_name3 = "AVENGERS AGE OF ULTRON"
movie_name4 = "CARS 3"
movie_name5 = "SPIDER-MAN: INTO THE SPIDER-VERSE"
guess_count = 0
guess_limit = 5
print('Guess The Movie!')
print('By Ahmed Shahir Samin')

print('''
Rules and Info:
''')
print('''1. This game is NOT case sensitive. That means you can enter the answers in either upper or lower case or a
   mixture of both of them.
2. Use the hints provided to guess the answer.
3. At the end results will be shown with a format like so:
   LEVEL NO.:CORRECT ANSWER :IF YOUR ANSWER WAS CORRECT OR NOT.''')

print('''LOADING ASSETS........
ASSETS LOADED SUCCESSFULLY.
STARTING GAME FROM LEVEL 1'

GOOD LUCK''')

print('''LEVEL 1: Fill the unfilled movie name: 
W___K __ _AL__
TYPE: Animated, Adventure
STUDIO: DISNEY''')
while guess_count < guess_limit:
    guess = input('LEVEL 1: Fill the Movie Name: ')
    guess_count += 1
    if guess.upper() == movie_name:
        print('YOU WON!')
        lvl1win = True
        break
else:
    print('SORRY. YOU FAILED LEVEL 1!')
    lvl1win = False

print('''LEVEL 2: Fill the unfilled movie name: 
A___G__S ____A__
TYPE: Action
STUDIO: MARVEL''')
while guess_count < guess_limit:
    guess = input('LEVEL 2: Fill the Movie Name: ')
    guess_count += 1
    if guess.upper() == movie_name2:
        print('YOU WON!')
        lvl2win = True
        break
else:
    print('SORRY. YOU FAILED LEVEL 2!')
    lvl2win = False

print('''LEVEL 3: Fill the unfilled movie name: 
A___G__S _G_ __ _L_R__
TYPE: Action
STUDIO: MARVEL''')
while guess_count < guess_limit:
    guess = input('LEVEL 3: Fill the Movie Name: ')
    guess_count += 1
    if guess.upper() == movie_name3:
        print('YOU WON!')
        lvl3win = True
        break
else:
    print('SORRY. YOU FAILED LEVEL 3!')
    lvl3win = False

print('''LEVEL 4: Fill the unfilled movie name: 
___S 3
TYPE: Animated, Racing, Adventure
STUDIO: DISNEY''')
while guess_count < guess_limit:
    guess = input('LEVEL 4: Fill the Movie Name: ')
    guess_count += 1
    if guess.upper() == movie_name4:
        print('YOU WON!')
        lvl4win = True
        break
else:
    print('SORRY. YOU FAILED LEVEL 4!')
    lvl4win = False

print('''LEVEL 5: Fill the unfilled movie name: 
S____R-M__: I__O T_E ____ER-V___E
TYPE: Action, Animated
STUDIO: MARVEL''')
while guess_count < guess_limit:
    guess = input('LEVEL 5: Fill the Movie Name: ')
    guess_count += 1
    if guess.upper() == movie_name5:
        print('YOU WON!')
        lvl5win = True
        break
else:
    print('SORRY. YOU FAILED LEVEL 5!')
    lvl5win = False

print('''
Results:
''')

if lvl1win == True:
    print(f'LEVEL 1: {movie_name}: CORRECT!')
if lvl1win == False:
    print(f'LEVEL 1: {movie_name}: WRONG!')
if lvl2win == True:
    print(f'LEVEL 2: {movie_name2}: CORRECT!')
if lvl2win == False:
    print(f'LEVEL 2: {movie_name2}: WRONG!')
if lvl3win == True:
    print(f'LEVEL 3: {movie_name3}: CORRECT!')
if lvl3win == False:
    print(f'LEVEL 3: {movie_name3}: WRONG!')
if lvl4win == True:
    print(f'LEVEL 1: {movie_name4}: CORRECT!')
if lvl4win == False:
    print(f'LEVEL 1: {movie_name4}: WRONG!')
if lvl5win == True:
    print(f'LEVEL 1: {movie_name5}: CORRECT!')
if lvl5win == False:
    print(f'LEVEL 1: {movie_name5}: WRONG!')
print('----------------------END----------------------')


print('''

Credits:
''')

print('''A GAME BY Ahmed Shahir Samin
Hope you guys enjoyed the game. This game was about 102 lines of raw code.
Eid Mubarak and Goodbye.''')

预期结果应该是如果任何测验失败,则它将显示失败的消息并继续进行下一个测验。

0 个答案:

没有答案