Python小黑屋

小黑屋

import random
import time

EVENT = ["Bobby","沼泽","xxx"]#事件列表
SOURCE = [" 火柴","牛肉","衣服"]#资源列表
SKILL = ["降龙十八掌","打狗棒法","九阴白骨爪","九阴真经","如来神掌"]#技能列表
def Init():#初始人物
    person = {"HP":100, "Hungry":100, "IQ":100,
              "skill":"",
              "火柴":1, "fire":0}#人的初始状态
    time.sleep(2)#停止运行2秒
    print("人物生成中>>>>>>>>>>50%")
    time.sleep(2)
    print("人物生成中>>>>>>>>>>>>>>>>>>>>>>>>>>>>>90%")
    time.sleep(2)
    print("人物生成完毕>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>100%")
    showPerson(person)
    return person
def showPerson(person):
    print("你现在的状态是:",person)

def fire(person):
    person["火柴"] = person["火柴"] - 1
    person["fire"] = 1
    print("火堆燃起来了!")

    return person
def PlayGame(person):
    #point = random.randint(0,1)
    point = 0
    if point == 0:
        time.sleep(1)
        print("你碰到了 Bobby")
        choose = input("是否要给他火柴:")
        print("你的火堆熊熊燃烧中")
        time.sleep(1)
        if choose == "是":
            time.sleep(1)
            person["火柴"] = person["火柴"] - 1
            if 80 < random.randint(0,100):#如果点数大于80,就能随机选择技能
                skill = random.choice(SKILL)#随机选择技能
                SKILL.remove(skill)#将技能从技能列表删除
                person["skill"] = person["skill"]+ skill
                person["HP"] = person["HP"] + 100
            else:
                print("你获得了Bobby的感激")
    return person

person = Init()
person = fire(person)
person = PlayGame(person)
showPerson(person)

你可能感兴趣的:(python)