# -*- coding: <utf-8> -*-
import time
import random
Jian = random.randint(1, 2)
dd = 1
cc = 1
ShuaGuaiLu = random.randint(1, 12)
JiE = 100
SuoZaiDi = "基地"
KeShi = ["医疗包", "面包", "苹果"]
WuPinLan = []
FuJia = 5
HuJia = 5
SuDu = 5
ZhuangBeiLan = []
XueLiang = 100
HuJiaFuJia = 0
FuJiaSuDu = 0
KeZhuangBei = ["木剑", "遮阳帽", "魔杖", "斧头", "破烂的战地靴"]
DiQu = ["刷怪镇", "大集市", "勇士峡谷", "树藤森林", "基地", "圣湖岛"]
DiTu = '''
--------------------------------------------
/ /
| |基地| ----------|刷怪镇| \\
| | / |
| \ / |
\ |----------------|勇士峡谷| /
/ | | |
| |大集市| | \\
| \ \ |
| ------ \ |
| | |圣湖岛| /
| |树藤森林| \\
| |
---------------------------------------------
'''
class GuaiWu:
def XiaoGuai(self):
global XiaoGuaiXie, XiaoGuaiGongJi, GuaiSu
XiaoGuaiXie = random.randint(15,30)
XiaoGuaiGongJi = random.randint(5, 15)
GuaiSu = 8
print('【小怪兽】')
time.sleep(0.5)
print('血量:%d\n攻击:%d\n速度: %d\n' % (XiaoGuaiXie, XiaoGuaiGongJi, GuaiSu))
def BOSS(self):
global DaBOSS, BOSSXue, BOSScu
DaBOSS = random.randint(50, 60)
BOSSXue = random.randint(80, 100)
BOSScu = 10
print('【BOSS】')
time.sleep(0.5)
print('血量:%d\n攻击:%d\n速度: %d\n' % (BOSSXue, DaBOSS, BOSScu))
def ShuTengGuai(self):
global ShuTeng, ShuTengXue, TengCu
ShuTengXue = random.randint(30, 40)
ShuTeng = random.randint(25, 40)
TengCu = 5
print('【树藤怪】')
time.sleep(0.5)
print('血量:%d\n攻击:%d\n速度: %d\n' % (ShuTengXue, ShuTeng, TengCu))
guaiwu = GuaiWu()
def Kong():
print("\n\n")
def ChaKanZhuangBei():
time.sleep(0.5)
print("\n装备栏: ", ZhuangBeiLan)
ShiQing()
def TouShi():
global XueLiang, GongJi
XueLiang = 100
GongJi = random.randint(15,30)
print('经过灵魂的透视, 你的属性是:')
ShuXing()
def ShuXing():
global g
time.sleep(1)
Jia()
print('\n\n我的信息: ---------------------')
print('血量:'+str(XueLiang))
print('攻击:'+str(GongJi + FuJia))
print("护甲:"+str(HuJia + HuJiaFuJia))
print('速度:'+str(SuDu + FuJiaSuDu))
print("饥饿:"+str(JiE))
g = SuDu + FuJiaSuDu
def ChaKanWuPin():
time.sleep(0.5)
print("\n物品栏: ", WuPinLan)
ShiQing()
def ChuFa():
global di, SuoZaiDi, ShuaGuaiLu
print(DiTu)
print("你要去:")
di = input(">> ")
if di not in DiQu:
print("请好好看地图!")
ChuFa()
if di == SuoZaiDi:
print("你正在这里呢!")
ChuFa()
else:
print("出发!")
print("-> 5%")
time.sleep(0.5)
print("-----> 25%")
time.sleep(1)
if ShuaGuaiLu == 1:
ShuaGuaiLu = random.randint(1, 12)
print("看!前面有一只大BOSS!")
BOSScu = 10
print("你要: 1.锤! 2.溜了溜了~")
b = int(input(">> "))
if b == 1:
Jia()
print("看来免不了一场恶战!")
guaiwu.BOSS()
ShuXing()
dadou.YuBOSS()
else:
Jia()
if g >= BOSScu:
print("你成功逃走了")
else:
print("你被追上, 大战开始")
guaiwu.BOSS()
ShuXing()
dadou.YuBOSS()
elif ShuaGuaiLu > 3 and ShuaGuaiLu < 6:
ShuaGuaiLu = random.randint(1, 12)
print("看!前面有一只树藤怪!")
TengCu = 5
print("你要: 1.锤! 2.溜了溜了~")
b = int(input(">> "))
if b == 1:
Jia()
print("看来免不了一场恶战!")
guaiwu.ShuTengGuai()
ShuXing()
dadou.YuShuTengGuai()
else:
Jia()
if g >= TengCu:
print("你成功逃走了")
else:
print("你被追上, 大战开始")
guaiwu.ShuTengGuai()
ShuXing()
dadou.YuShuTengGuai()
elif ShuaGuaiLu == 2 or 3:
ShuaGuaiLu = random.randint(1, 12)
print("看!前面有一只小怪兽!")
GuaiSu = 8
print("你要: 1.锤! 2.溜了溜了~")
b = int(input(">> "))
if b == 1:
Jia()
print("看来免不了一场恶战!")
guaiwu.XiaoGuai()
ShuXing()
dadou.YuXiaoGuaiShou()
else:
Jia()
if g >= GuaiSu:
print("你成功逃走了")
else:
print("你被追上, 大战开始")
guaiwu.XiaoGuai()
ShuXing()
dadou.YuXiaoGuaiShou()
if Jian == 0:
print("你捡到了破烂的战地靴")
wupin.ZhanDiXue()
if XueLiang > 0:
print("---------------> 75%")
time.sleep(0.5)
print("--------------------> 100%")
print("到达!\n你现在在:", di)
SuoZaiDi = di
else:
Kong()
def Name():
global x
print("请告诉我你的名字吧!")
time.sleep(1)
print("-" * 10, "【请输入】", "-" * 10)
x = input(">> ")
time.sleep(1)
print("哈, 所以", x, "是你的名字呀")
time.sleep(1)
print("还挺有品味嘛!")
time.sleep(1)
def ShiQing():
print("\n现在你要:")
print("1.出发 2.装备 3.查看装备\n4.查看物品 5.查看状态 6.吃东西")
v = int(input(">> "))
if v == 1:
ChuFa()
elif v == 2:
ZhuangBei()
elif v == 3:
ChaKanZhuangBei()
elif v == 4:
ChaKanWuPin()
elif v == 5:
ShuXing()
elif v == 6:
ShiYong()
else:
print("请重新输入!")
def KaiChang():
print("你好!")
print("欢迎来玩这个游戏")
time.sleep(1)
print("让我送你一些东西吧!")
print("( 请按Enter键 )")
input(">> ")
time.sleep(1)
print("你获得了:\n1.木剑\n2.遮阳帽\n3.破烂的战地靴")
wupin.MuJian()
wupin.ZheYangMao()
wupin.ZhanDiXue()
def ZhiYie():
global HuJiaFuJia, FuJia, FuJiaSuDu, x
time.sleep(1)
print("现在, 我们来选职业啦!")
time.sleep(1)
print("1.巫师")
print("2.战士")
print("3.盗贼")
print("-" * 10, "【请输入】", "-" * 10)
c = int(input(">> "))
if c == 1:
print("恭喜" + x + "成为巫师!")
HuJiaFuJia += 20
elif c == 2:
print("恭喜" + x + "成为战士!")
FuJia += 10
elif c == 3:
print("恭喜" + x + "成为盗贼!")
FuJiaSuDu += 10
else:
print("我只给你3个职业, 你在想什么?")
ZhiYie()
Jia()
def ZhuangBei():
print("你要装备什么?")
print(WuPinLan)
o = input(">> ")
if o in WuPinLan and o in KeZhuangBei:
print("已装备")
Jia()
ZhuangBeiLan.append(o)
WuPinLan.remove(o)
print(ZhuangBeiLan)
ShiQing()
else:
print("没有这样东西!")
ZhuangBei()
def ShiYong():
global JiE, XueLiang, Shi
print("你要食用:")
print(WuPinLan)
Shi = input(">> ")
if Shi not in WuPinLan and Shi not in KeShi:
print("请重新输入!")
else:
if Shi == "医疗包":
print("你食用了医疗包, 血量加30")
XueLiang += 30
if XueLiang > 100:
XueLiang = 100
ShiQing()
elif Shi == "苹果":
print("你食用了苹果, 饥饿加10, 血量加10")
XueLiang += 10
JiE += 10
if XueLiang > 100:
XueLiang = 100
elif JiE > 100:
JiE = 100
ShiQing()
else:
print("你食用了" + Shi + "饥饿加10, 血量加5")
XueLiang += 10
JiE += 5
if XueLiang > 100:
XueLiang = 100
elif JiE > 100:
JiE = 100
ShiQing()
class DaDou:
def YuBOSS(self):
global BOSSXue, XueLiang, FuJia, HuJia, HuJiaFuJia, dd, JiE
while True:
input(">> ")
print("你开始攻击, 造成了了", GongJi + FuJia, "点伤害")
input(">> ")
print("BOSS失去了", GongJi + FuJia, "点血")
BOSSXue -= GongJi + FuJia
if XueLiang <= 0:
input(">> ")
print("你被BOSS打死了")
Si()
break
elif BOSSXue <= 0:
input(">> ")
print("BOSS被你打死了")
input(">> ")
print("恭喜你, 获得\n1.面包\n2.医疗包\n3.魔杖")
print("饥饿减", dd * 2)
wupin.MianBao()
wupin.MoZhuang()
wupin.YiLiaoBiao()
break
input(">> ")
print("BOSS开始攻击, 造成了", DaBOSS, "点伤害")
if HuJia + HuJiaFuJia > 0:
input(">> ")
print("你的护甲减去", DaBOSS * 2)
HuJia -= DaBOSS
HuJiaFuJia -= DaBOSS
if XueLiang <= 0:
input(">> ")
print("你被BOSS打死了")
Si()
break
elif BOSSXue <= 0:
input(">> ")
print("BOSS被你打死了")
input(">> ")
print("恭喜你, 获得\n1.面包\n2.医疗包\n3.魔杖")
print("饥饿减", dd * 2)
wupin.MianBao()
wupin.MoZhuang()
wupin.YiLiaoBiao()
break
else:
input(">> ")
print("你失去了", DaBOSS, "点血")
XueLiang -= DaBOSS
if XueLiang <= 0:
input(">> ")
print("你被BOSS打死了")
Si()
break
elif BOSSXue <= 0:
input(">> ")
print("BOSS被你打死了")
input(">> ")
print("恭喜你, 获得\n1.面包\n2.医疗包\n3.魔杖")
print("饥饿减", dd * 2)
wupin.MianBao()
wupin.MoZhuang()
wupin.YiLiaoBiao()
break
dd += 1
JiE -= dd * 2
def YuXiaoGuaiShou(self):
global XiaoGuaiXie, XueLiang, FuJia, HuJia, HuJiaFuJia, dd, JiE
while True:
input(">> ")
print("你开始攻击, 造成了了", GongJi + FuJia, "点伤害")
input(">> ")
print("小怪兽失去了", GongJi + FuJia, "点血")
XiaoGuaiXie -= GongJi + FuJia
if XueLiang <= 0:
input(">> ")
print("你被小怪兽打死了")
Si()
break
elif XiaoGuaiXie <= 0:
input(">> ")
print("小怪兽被你打死了")
input(">> ")
print("恭喜你, 获得\n1.面包\n2.医疗包\n3.斧头")
print("饥饿减", dd * 2)
wupin.MianBao()
wupin.FuTou()
wupin.YiLiaoBiao()
break
input(">> ")
print("小怪兽开始攻击, 造成了", XiaoGuaiGongJi, "点伤害")
if HuJia + HuJiaFuJia > 0:
input(">> ")
print("你的护甲减去", XiaoGuaiGongJi * 2)
HuJia -= XiaoGuaiGongJi
HuJiaFuJia -= XiaoGuaiGongJi
if XueLiang <= 0:
input(">> ")
print("你被小怪兽打死了")
Si()
break
elif XiaoGuaiXie <= 0:
input(">> ")
print("小怪兽被你打死了")
input(">> ")
print("恭喜你, 获得\n1.面包\n2.医疗包\n3.斧头")
print("饥饿减", dd * 2)
wupin.MianBao()
wupin.FuTou()
wupin.YiLiaoBiao()
break
else:
input(">> ")
print("你失去了", XiaoGuaiGongJi, "点血")
XueLiang -= XiaoGuaiGongJi
if XueLiang <= 0:
input(">> ")
print("你被小怪兽打死了")
Si()
break
elif XiaoGuaiXie <= 0:
input(">> ")
print("小怪兽被你打死了")
input(">> ")
print("恭喜你, 获得\n1.面包\n2.医疗包\n3.斧头")
print("饥饿减", dd * 2)
wupin.MianBao()
wupin.FuTou()
wupin.YiLiaoBiao()
break
dd += 1
JiE -= dd * 2
def YuShuTengGuai(self):
global ShuTengXue, XueLiang, FuJia, HuJia, HuJiaFuJia, dd, JiE
while True:
input(">> ")
print("你开始攻击, 造成了了", GongJi + FuJia, "点伤害")
input(">> ")
print("树藤怪失去了", GongJi + FuJia, "点血")
ShuTengXue -= GongJi + FuJia
if XueLiang <= 0:
input(">> ")
print("你被树藤怪打死了")
Si()
break
elif ShuTengXue <= 0:
input(">> ")
print("树藤怪被你打死了")
input(">> ")
print("恭喜你, 获得\n1.医疗包\n2.苹果\n3.遮阳帽")
print("饥饿减", dd * 2)
wupin.PingGuo()
wupin.ZheYangMao()
wupin.YiLiaoBiao()
break
input(">> ")
print("树藤怪开始攻击, 造成了", ShuTeng, "点伤害")
if HuJia + HuJiaFuJia > 0:
input(">> ")
print("你的护甲减去", ShuTeng * 2)
HuJia -= ShuTeng
HuJiaFuJia -= ShuTeng
if XueLiang <= 0:
input(">> ")
print("你被树藤怪打死了")
Si()
break
elif ShuTengXue <= 0:
input(">> ")
print("树藤怪被你打死了")
input(">> ")
print("恭喜你, 获得\n1.医疗包\n2.苹果\n3.遮阳帽")
print("饥饿减", dd * 2)
wupin.PingGuo()
wupin.ZheYangMao()
wupin.YiLiaoBiao()
break
else:
input(">> ")
print("你失去了", ShuTeng, "点血")
XueLiang -= ShuTeng
if XueLiang <= 0:
input(">> ")
print("你被树藤怪打死了")
Si()
break
elif ShuTengXue <= 0:
input(">> ")
print("树藤怪被你打死了")
input(">> ")
print("恭喜你, 获得\n1.医疗包\n2.苹果\n3.遮阳帽")
print("饥饿减", dd * 2)
wupin.PingGuo()
wupin.ZheYangMao()
wupin.YiLiaoBiao()
break
dd += 1
JiE -= dd * 2
dadou = DaDou()
class WuPin:
def ZhanDiXue(self):
global FuJiaSuDu, WuPinLan
WuPinLan.append("破烂的战地靴")
def MuJian(self):
WuPinLan.append("木剑")
def ZheYangMao(self):
WuPinLan.append("遮阳帽")
def YiLiaoBiao(self):
WuPinLan.append("医疗包")
def FuTou(self):
WuPinLan.append("斧头")
def MoZhuang(self):
WuPinLan.append("魔杖")
def MianBao(self):
WuPinLan.append("面包")
def PingGuo(self):
WuPinLan.append("苹果")
wupin = WuPin()
def Jia():
global FuJia, HuJiaFuJia, FuJiaSuDu
if "木剑" in ZhuangBeiLan:
FuJia = FuJia + 5
if "破烂的战地靴" in ZhuangBeiLan:
FuJiaSuDu = FuJiaSuDu + 5
if "遮阳帽" in ZhuangBeiLan:
HuJiaFuJia = HuJiaFuJia + 5
if "斧头" in ZhuangBeiLan:
FuJia = FuJia + 15
if "魔杖" in ZhuangBeiLan:
FuJia = FuJia + 30
def Game():
global cc
KaiChang()
time.sleep(0.5)
print("现在--")
time.sleep(1)
Name()
ZhiYie()
TouShi()
while cc:
ShiQing()
def Si():
global cc
print("你已经死了")
cc = 0
if __name__ == "__main__":
Game()