Invent with Python

Python 文字游戏---Dragon Realm 

long long ago ,在一个岛上,住着很多龙.其中有善良的,也有凶残的。在玩家的面前有两个洞穴供选择。一个洞中的龙会将自己的财宝送给你。另外一个则会将玩家吃掉。come on!!!!

 

 

import time
import random

def displayInfo():
    print('You are in a land full of dragons. In front of you.')
    print('you are tow caves.In one cave,the dragon is friednly')
    print('and will share his treasure with you .The other dragon')
    print('is greedy and hungry,and will eat you on sight.')
    print()

def chooseCave():
    cave = ''
    while cave!='1' and cave!='2':
        print('Which cave will you go into ?(1 or 2)')
        cave = raw_input()

    return cave

def checkCave(chosenCave):
    print('You approach the cave ...')
    time.sleep(2)
    print('It is dark and spooky..')
    time.sleep(2)
    print('A large dragon jumps out in front of you ! He open his jaw and ..')
    print()
    time.sleep(2)

    friendlyCave = random.randint(1,2)

    if chosenCave == str(friendlyCave):
        print('Gives you his treasure!')
    else:
        print('Gobbles you down in on bite!')

playAgain = 'yes'
while playAgain == 'yes' or playAgain == 'y':
    displayInfo()

    caveNumber = chooseCave()
    checkCave(caveNumber)

    print('Do you want to play again ? (yes or no) ')
    playAgain = raw_input()



    

Invent with Python <Dragon>_第1张图片

你可能感兴趣的:(python)