首页 > 代码库 > Python07旧版作业源码:虚拟人生(仅供参考)
Python07旧版作业源码:虚拟人生(仅供参考)
- bin目录:
Simulated_life_start.py
1 #!usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # auther:Mr.chen 4 # 描述: 5 6 7 import sys 8 sys.path.append(‘..‘) 9 from src import users_business 10 11 12 users_business.user_Main()
- lib目录:
Small_monster_model.py
1 #!usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # auther:Mr.chen 4 # 描述:教师模型类 5 6 import random,time,os,sys 7 sys.path.append(‘..‘) 8 from lib import common 9 DIR = os.path.dirname(__file__) 10 DIR = DIR.replace(‘src‘, ‘db/‘) 11 DICT = common.log_info_read(DIR + ‘config_conf‘) 12 13 class small_monster_Model: 14 ‘‘‘ 15 小怪物模型类 16 ‘‘‘ 17 def __init__(self,name,hurt): 18 self.Name = name # 怪物名 19 self.Hurt = hurt # 破坏力 20 self.Drop = [‘大还丹‘,‘小还丹‘] # 掉宝 21 22 23 def __str__(self): 24 return self.Name
Lock_demon_tower_model.py
1 #!usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # auther:Mr.chen 4 # 描述: 5 6 import random,time,sys,os 7 sys.path.append(‘..‘) 8 from lib import common 9 10 11 12 13 class lock_demon_tower_Model: 14 ‘‘‘ 15 锁妖塔模型类 16 ‘‘‘ 17 18 19 20 def __init__(self,lname,difficulty,mlist_obj): 21 self.Lname = lname #塔名 22 self.Difficulty = difficulty #难度(小怪攻击力倍增) 23 self.Mlist_obj = mlist_obj #小怪列表 24 25 26 def __str__(self): 27 return self.Lname
Players_model.py
1 #!usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # auther:Mr.chen 4 # 描述: 5 import random,time,os,sys 6 sys.path.append(‘..‘) 7 import common 8 9 DIR = os.path.dirname(__file__) 10 DIR = DIR.replace(‘src‘, ‘db/‘) 11 DICT = common.log_info_read(DIR + ‘config_conf‘) 12 13 14 class players_Model: 15 ‘‘‘ 16 玩家模型类 17 ‘‘‘ 18 19 20 def __init__(self,name,age,nationality,specialty,gamemode,tlist_obj): 21 self.Name = name # 姓名 22 self.Age = age # 年龄 23 self.Nationality = nationality # 国籍 24 self.Specialty = specialty # 特长 25 self.Strength = 1000 # 体力 26 self.GameMode = gamemode # 游戏模式 27 self.Tlist_obj = tlist_obj # 锁妖塔层关数列表 28 self.Force = random.randrange(40, 60) # 随机武力 29 self.IQ= random.randrange(40,60) # 随机智力 30 self.Charm= random.randrange(40,60) # 随机魅力 31 self.Item = {‘大还丹‘:0,‘小还丹‘:0} # 背包栏 32 self.schedule = {} 33 self.num = {} 34 for obj in self.Tlist_obj: 35 self.schedule[obj] = 0 #锁妖塔每层进度率 36 self.num[obj] = 0 #闯塔次数 37 38 39 40 def Begins(self,tobj): #闯塔 41 time.sleep(1) 42 print("{0}慢慢的走了过去,用尽力量推开了{1}的大门,第{2}次闯塔开始!").format(self.Name,tobj,str(self.num[tobj]+1)) 43 re = self.success_Radio() 44 if re != True: 45 self.Battle(tobj) 46 else: 47 time.sleep(1) 48 print ("很幸运,这次没遇到敌人!") 49 self.schedule[tobj] += 10 50 self.num[tobj] += 1 51 time.sleep(1) 52 print ("{0}结束了本次创塔,{1}的进度率变为{2}%,".format(self.Name, tobj, self.schedule[tobj])) 53 if self.schedule[tobj] == 100: 54 return False 55 else: 56 return True 57 58 59 60 61 def Battle(self,tobj): #战斗 62 num = random.randrange(1,len(tobj.Mlist_obj)) 63 bum = random.randrange(1,1000) 64 if bum > self.Charm * 10 : #暴击判定 65 hurt = (int(tobj.Mlist_obj[num - 1].Hurt) - (self.Force / 20)) * int(tobj.Difficulty) * 2 66 self.Strength = self.Strength - hurt 67 time.sleep(1) 68 print ("{0}对你发起了毁灭性攻击(暴击),造成了{1}体力的伤害,你还剩余{2}体力".format(tobj.Mlist_obj[num - 1].Name, hurt, self.Strength)) 69 else: 70 hurt = (int(tobj.Mlist_obj[num - 1].Hurt) - (self.Force / 20)) * int(tobj.Difficulty) 71 self.Strength = self.Strength - hurt 72 time.sleep(1) 73 print ("{0}对你发起了打击,造成了{1}体力的伤害,你还剩余{2}体力".format(tobj.Mlist_obj[num - 1].Name, hurt, self.Strength)) 74 num = random.randrange(1,1000) 75 if num >= 800: 76 print ("费尽艰辛,你终于打败了怪物,从一堆渣子中你发现了大还丹!!") 77 self.Item[‘大还丹‘] +=1 78 elif num >500 and num <800: 79 print ("费尽艰辛,你终于打败了怪物,从一堆渣子中你发现了小还丹!!") 80 self.Item[‘小还丹‘] += 1 81 else: 82 print ("费劲艰辛打败怪物你的,仍旧一无所获。。。") 83 84 85 def success_Radio(self): #遇敌判定 86 num = random.randrange(1, 1100) 87 if num <= self.IQ * 10: 88 return True 89 else: 90 a = random.randrange(1,5) 91 # print (type(a)) 92 players_Model.event(str(a)) 93 return False 94 95 96 @staticmethod 97 def event(num): #战斗事件 98 dict = {‘1‘:‘你不小心猜了一坨屎,没想到当中居然有个怪物,突然向你袭来‘,‘2‘:‘你看到一幅画,画里的人正是灵儿,突然它看了过来...‘, 99 ‘3‘:‘一个怪物坐在一个独木桥中间,没办法你只能向它杀了过去‘,‘4‘:‘一个胡同黑乎乎的,正当你想该往哪走的时候,有个东西摸了你的背后...‘, 100 ‘5‘:‘你静悄悄的缓步绕路,意图躲开怪物,但是它的同伴却发现了你....‘} 101 time.sleep(1) 102 print (dict[num])
common.py
1 #!usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # auther:Mr.chen 4 # 描述: 5 6 #!/usr/bin/python 7 # -*- coding: utf-8 -*- 8 # 公共方法层 9 10 import os,time,random,pickle 11 12 DIR = os.path.dirname(__file__) 13 DIR = DIR.replace(‘lib‘,‘db/‘) 14 15 16 TAG = True #循环控制标志 17 18 19 def Exit(): 20 ‘‘‘ 21 系统退出 22 :return:None 23 ‘‘‘ 24 print (‘程序退出!‘) 25 exit() 26 27 28 def MD5(password): 29 ‘‘‘ 30 加密函数 31 :param firstsite: 密码字符串 32 :return: 加密字符串 33 ‘‘‘ 34 import hashlib 35 return hashlib.md5(password).hexdigest() 36 37 38 def Verification_input(): 39 ‘‘‘ 40 登录验证码校验 41 :return: True 42 ‘‘‘ 43 while TAG: 44 re = Verification_Code() 45 code = raw_input(‘请输入括号里的验证码,不区分大小写({0}):‘.format(re)) 46 if code.strip().lower() != re.lower(): 47 print(‘您输入的验证码有误,请重新输入!‘) 48 else: 49 return True 50 51 52 def Verification_Code(): 53 ‘‘‘ 54 生成随机的6位验证码:大小写字母数字的组合 55 :return: 验证码 56 ‘‘‘ 57 code = ‘‘ 58 b = random.randrange(0, 5) 59 c = random.randrange(0, 5) 60 for i in range(6): 61 if i == b: 62 a = random.randrange(1, 9) 63 code = code + str(a) 64 else: 65 a = random.randrange(65, 90) 66 if i == c: 67 code = code + chr(a).lower() 68 else: 69 code = code + chr(a) 70 return code 71 72 73 74 75 76 def log_info_read(dir): 77 ‘‘‘ 78 配置文件全部读取 79 :param user:用户名 80 :return:dict字典 81 如果无文件返回False 82 ‘‘‘ 83 if os.path.exists(dir): 84 with open(dir,‘r‘) as f: 85 dict = pickle.load(f) 86 return dict 87 else: 88 return False 89 90 91 92 93 def log_info_write(dir,dict): 94 ‘‘‘ 95 配置文件全部写入 96 :param user:用户名 97 :param dict: 日志字典 98 :return: True or False 99 ‘‘‘ 100 #if os.path.exists(user+‘_log‘): 101 #print (DIR+user+‘_log‘) 102 with open(dir,‘w‘) as f: 103 pickle.dump(dict,f) 104 return True
- src目录:
users_business.py
1 #!usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # auther:Mr.chen 4 # 描述: 5 6 LOGIN = [] 7 TAG = True 8 import os,sys 9 sys.path.append(‘..‘) 10 from lib import common 11 from lib.Players_model import players_Model 12 import Story_start 13 14 DIR = os.path.dirname(__file__) 15 DIR = DIR.replace(‘src‘,‘db/‘) 16 17 18 19 def user_Login(): 20 num = 0 21 List = [] 22 dict = common.log_info_read(DIR + ‘config_conf‘) 23 if dict == False: 24 print ("请让管理员先创建怪物及锁妖塔模型后再来!") 25 return 26 if len(dict[‘players‘]) == 0: 27 print ("请注册角色以后再来!") 28 return 29 while TAG: 30 text = """ 31 你一共创建了{0}个角色如下: 32 """.format(str(len(dict[‘players‘]))) 33 print (text) 34 for P in dict[‘players‘]: 35 print ("{0},姓名:{1},年龄:{2},国籍:{3},特长:{4},体力:{5},武力:{6},智力:{7},魅力:{8},游戏模式:{9}" 36 .format(str(num+1),P.Name,P.Age,P.Nationality,P.Specialty,P.Strength,P.Force,P.IQ,P.Charm,P.GameMode)) 37 num += 1 38 List.append(str(num)) 39 choose = raw_input("请输入索引选择登陆角色(单选):") 40 if choose in List: 41 LOGIN.insert(0,dict[‘players‘][int(choose)-1]) 42 print ("{0}角色登陆成功!".format(LOGIN[0].Name)) 43 return 44 else: 45 print ("您的选择有误,请重新选择!") 46 num = 0 47 48 49 50 51 52 53 54 def login_Check(): 55 dict = common.log_info_read(DIR + ‘config_conf‘) 56 57 name = raw_input("请输入你的姓名:") 58 age = raw_input("请输入你的年龄:") 59 nationality = raw_input("请输入你的国籍:") 60 61 text = """ 62 游戏可选特长如下: 63 1,无双(初始武力+10,武力越高,敌人的伤害越低) 64 2,奇才 (初始智力+10,智力越高遇敌率越低) 65 3,妖异 (初始魅力+10,魅力越高,敌人暴击率越低) 66 4,守财 (初始体力+300,体力越高越耐打) 67 """ 68 while TAG: 69 print(text) 70 specialty = raw_input("请输入索引选择你的特长(单选):") 71 Dic = {‘1‘:‘无双‘,‘2‘:‘奇才‘,‘3‘:‘妖异‘,‘4‘:‘守财‘} 72 if specialty in Dic.keys(): 73 specialty = Dic[specialty] 74 break 75 else: 76 print ("你的输入有误,请重新输入!") 77 while TAG: 78 decide = raw_input("是否开启作弊模式?(y/n)") 79 if decide == ‘y‘: 80 gamemode = ‘作弊模式‘ 81 break 82 elif decide == ‘n‘: 83 gamemode = ‘正常模式‘ 84 break 85 else: 86 print ("你的输入有误!") 87 text = """ 88 你的注册信息如下: 89 姓名:{0} 90 年龄:{1} 91 国籍:{2} 92 特长:{3} 93 模式:{4} 94 """.format(name,age,nationality,specialty,gamemode) 95 while TAG: 96 print (text) 97 decide = raw_input("是否确认(y/n):") 98 if decide == ‘y‘: 99 P = players_Model(name,age,nationality,specialty,gamemode,dict[‘towers‘]) 100 # Dict = {‘无双‘: ‘Force‘, ‘奇才‘: ‘IQ‘, ‘妖异‘: ‘Charm‘} 101 if specialty == ‘无双‘: 102 P.Force += 10 103 elif specialty == ‘奇才‘: 104 P.IQ += 10 105 elif specialty == ‘妖异‘: 106 P.Charm += 10 107 else: 108 P.Strength += 300 109 if gamemode == ‘作弊模式‘: 110 P.Force = 100 111 P.IQ = 100 112 P.Charm = 100 113 P.Strength = 100000 114 115 dict[‘players‘].append(P) 116 common.log_info_write(DIR + ‘config_conf‘, dict) 117 print (‘信息注册成功‘) 118 return 119 elif decide == ‘n‘: 120 return 121 else: 122 print (‘你的输入有误!‘) 123 124 125 126 127 128 129 130 def user_Main(): 131 132 text = """ 133 欢迎体验模拟的人生 134 1,角色选择 135 2,角色注册 136 3,游戏开始 137 4,游戏退出 138 """ 139 while TAG: 140 print (text) 141 dict = {‘1‘:user_Login,‘2‘:login_Check,‘3‘:Story_start.Pre_chapter,‘4‘:common.Exit} 142 choose = raw_input("请输入你的选择:") 143 if choose in dict.keys(): 144 if choose == ‘3‘ and LOGIN != []: 145 dict[choose](LOGIN[0]) 146 elif choose == ‘3‘: 147 print ("请登陆角色后再来!") 148 else: 149 dict[choose]() 150 else: 151 print ("你的输入有误!") 152 153 if __name__ == "__main__": 154 user_Main()
admin_business.py
1 #!usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # auther:Mr.chen 4 # 描述: 5 6 import os,sys 7 sys.path.append(‘..‘) 8 from lib.Small_monster_model import small_monster_Model 9 from lib.Lock_demon_tower_model import lock_demon_tower_Model 10 from lib import common 11 12 DIR = os.path.dirname(__file__) 13 DIR = DIR.replace(‘src‘,‘db/‘) 14 15 TAG = True 16 17 def create_monsters_model(): 18 """ 19 创建小怪模型 20 :return: None 21 """ 22 while TAG: 23 name = raw_input("请输入怪物的姓名:") 24 hurt = raw_input("请输入怪物的破坏力:") 25 text = """ 26 怪物信息如下: 27 姓名: {0} 28 破坏力:{1} 29 """.format(name,hurt) 30 print (text) 31 decide = raw_input("是否确认(y/n):") 32 if decide == ‘y‘: 33 M = small_monster_Model(name,hurt) 34 dict = common.log_info_read(DIR+‘config_conf‘) 35 if dict != False: 36 dict[‘monsters‘].append(M) 37 common.log_info_write(DIR + ‘config_conf‘, dict) 38 print ("怪物信息保存成功!") 39 return 40 else: 41 dict = { 42 ‘monsters‘:[M], 43 ‘towers‘:[], 44 ‘players‘:[] 45 } 46 common.log_info_write(DIR+‘config_conf‘,dict) 47 print ("怪物信息保存成功!") 48 return 49 elif decide == ‘n‘: 50 break 51 else: 52 print ("您的输入有误!") 53 54 55 56 def create_Tower_model(): 57 """ 58 创建锁妖塔模型 59 :return: None 60 """ 61 62 dict = common.log_info_read(DIR + ‘config_conf‘) 63 if dict == False: 64 print ("请先创建怪物模型后再来!") 65 return 66 name = raw_input("请输入锁妖塔的名称:") 67 difficulty = raw_input("请输入本层的难度(倍增小怪攻击力):") 68 T= lock_demon_tower_Model(name,difficulty,dict[‘monsters‘]) 69 while TAG: 70 text = """ 71 课程的信息如下: 72 塔名: {0} 73 难度: {1} 74 """.format(name,difficulty) 75 print (text) 76 decide = raw_input("是否确认(y/n):") 77 if decide == ‘y‘: 78 dict[‘towers‘].append(T) 79 common.log_info_write(DIR + ‘config_conf‘, dict) 80 return 81 elif decide == ‘n‘: 82 return 83 else: 84 print ("您的输入有误!") 85 86 87 88 89 90 91 92 93 94 def model_Config(): 95 """ 96 查看已经创建的模型 97 :return: None 98 """ 99 num = 0 100 Num = 0 101 dict = common.log_info_read(DIR + ‘config_conf‘) 102 if dict == False: 103 print ("请先创建怪物模型后再来!") 104 return 105 print ("已经创建的怪物模型,如下:".format(str(len(dict[‘monsters‘])))) 106 for M in dict[‘monsters‘]: 107 print ("{0}:怪物名:{1},破坏力:{2},掉宝:{3}".format(str(num + 1), M.Name, M.Hurt, M.Drop)) 108 num += 1 109 print ("已经创建的塔模型,如下:".format(str(len(dict[‘towers‘])))) 110 for P in dict[‘towers‘]: 111 print ("{0}:塔名:{1},难度:{2},怪物列表:{3}".format(str(Num + 1), P.Lname, P.Difficulty, P.Mlist_obj)) 112 Num += 1 113 114 115 116 117 def admin_Main(log = None): 118 """ 119 管理员管理界面 120 :param log: 用户登录标志 121 :return: None 122 """ 123 while TAG: 124 text = """ 125 欢迎来到管理员界面 {0}登陆中 126 1,创建怪物模组 127 2,创建锁妖塔模组 128 3,查看模组配置 129 4,系统退出 130 """.format(log) 131 print (text) 132 while TAG: 133 choose = raw_input(‘请输入你的选择:‘) 134 if choose == ‘1‘: 135 create_monsters_model() 136 break 137 elif choose == ‘2‘: 138 create_Tower_model() 139 break 140 elif choose == ‘3‘: 141 model_Config() 142 break 143 elif choose == ‘4‘: 144 common.Exit() 145 else: 146 print (‘您的输入有误!‘) 147 148 if __name__ == "__main__": 149 admin_Main(‘admin‘)
Story_start.py
1 #!usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # auther:Mr.chen 4 # 描述: 5 6 import time,os,sys 7 sys.path.append(‘..‘) 8 from lib import common 9 # from lib.Players_model import players_Model 10 DIR = os.path.dirname(__file__) 11 DIR = DIR.replace(‘src‘,‘db/‘) 12 TAG = True 13 14 15 def Pre_chapter(user): 16 time.sleep(2) 17 title = """ 18 * * * * * * * * * * * * * * * * * * * * * * *预章:传说* * * * * * * * * * * * * * * * * * * * * * * 19 """ 20 print (title) 21 time.sleep(5) 22 text = """ 23 相传很久以前,于古国疆域,有一奇人姓夸名父. 24 以大力闻于世间,以才智惊于圣贤,以风韵传于万载.. 25 忽一日,慕之者至.询问之,其曰... 26 吾父乃真之才,生于凡中.无师而达天地... 27 终其一生教化万民,此乃吾真之所持.. 28 父之事迹.且听我慢慢道来... 29 30 """ 31 for i in text.decode(‘utf-8‘): 32 if i != ‘ ‘: 33 time.sleep(0.5) 34 print i.encode(‘utf-8‘), 35 else: 36 print i.encode(‘utf-8‘), 37 The_first_chapter(user) 38 39 40 def The_first_chapter(user): 41 42 # dict = common.log_info_read(DIR + ‘config_conf‘) 43 # for S in dict[‘students‘]: 44 # if S.Name == user.Name: 45 time.sleep(2) 46 introduce = """ 47 登场人物介绍 48 49 姓名:{0} 50 年龄:{1} 51 国籍:{2} 52 特长:{3} 53 体力:{4} 54 武力:{5} 55 智力:{6} 56 魅力:{7} 57 秘籍:无 58 59 点评:屌丝,唯撩妹甚 60 61 姓名:灵儿 62 年龄:22 63 国籍:china 64 特长: 65 体力:1000 66 武力:70 67 智力:70 68 魅力:100 69 秘籍:游戏保护,万法不侵 70 71 点评:白富美 72 """.format(user.Name,user.Age,user.Nationality,user.Specialty,user.Strength,user.Force,user.IQ,user.Charm) 73 for i in introduce.decode(‘utf-8‘): 74 if i != ‘ ‘: 75 time.sleep(0.2) 76 print i.encode(‘utf-8‘), 77 else: 78 print i.encode(‘utf-8‘), 79 time.sleep(2) 80 title = """ 81 * * * * * * * * * * * * * * * * * * * * * * *第一章:缘启* * * * * * * * * * * * * * * * * * * * * * * 82 """ 83 print (title) 84 time.sleep(5) 85 text = """ 86 我的父亲叫做{0},本是一介草民,少时机缘之下, 87 救助了一个跳河自杀之人,本也并无所求,只因 88 我父那时在河中捕鱼,闲河中波澜太盛,吓跑鱼儿, 89 故,救之,以安抚鱼心。谁想此人竟是一小门派 90 掌教之子,因修炼走火,盲目间跌落河中。恰逢我父 91 出海,机缘所致,掌教有感我父恩德,故收其为徒, 92 传功授法,指引修行。说来也怪,我父不论武力{1}, 93 智力{1}魅力{2}尽数低于常人,但唯独撩妹能力 94 极其出众,故派中最小师妹灵儿常伴左右,个中滋味 95 不足为外人道也。 96 97 98 """.format(user.Name,user.Force,user.IQ,user.Charm) 99 for i in text.decode(‘utf-8‘): 100 if i != ‘ ‘: 101 time.sleep(0.5) 102 print i.encode(‘utf-8‘), 103 else: 104 print i.encode(‘utf-8‘), 105 The_second_chapter(user) 106 107 108 def The_second_chapter(user): 109 time.sleep(2) 110 introduce = """ 111 登场人物介绍 112 113 姓名:高富帅 114 年龄:34 115 国籍:china 116 特长:有钱有势 117 体力:1000 118 武力:70 119 智力:70 120 魅力:70 121 秘籍:无 122 123 点评:如其名 124 125 126 """ 127 for i in introduce.decode(‘utf-8‘): 128 if i != ‘ ‘: 129 time.sleep(0.2) 130 print i.encode(‘utf-8‘), 131 else: 132 print i.encode(‘utf-8‘), 133 time.sleep(2) 134 title = """ 135 * * * * * * * * * * * * * * * * * * * * * * *第二章:幻灭* * * * * * * * * * * * * * * * * * * * * * * 136 """ 137 print (title) 138 time.sleep(5) 139 text = """ 140 我父和灵儿就这样朝夕相处,日久生情,只待谈婚论嫁之时。 141 但,世事难料。一日,掌门大寿,宴请四方,祝寿者繁多。 142 有一人姓高名富帅,乃当朝一品大员之子,见灵儿貌美, 143 意欲图之。在其下手一刻,幸被我父所阻,于是心生恨意, 144 命其下人,禀报大员,以圣上赐婚为由,向掌门施压。怎料, 145 掌门欲息事宁人,遂命灵儿随高富帅回京,奉旨完婚。师命 146 难违,灵儿纵千般不愿,亦感无可奈何。临行前,挥泪别过, 147 劝我父放下仇恨,勿思勿念。我父伤心之余,亦感自身渺小。 148 暗发宏愿,以期报仇雪恨,救灵儿于水火之间。 149 """ 150 for i in text.decode(‘utf-8‘): 151 if i != ‘ ‘: 152 time.sleep(0.5) 153 print i.encode(‘utf-8‘), 154 else: 155 print i.encode(‘utf-8‘), 156 The_third_chapter(user) 157 158 def The_third_chapter(user): 159 time.sleep(2) 160 title = """ 161 * * * * * * * * * * * * * * * * * * * * * * *第三章:暗涛* * * * * * * * * * * * * * * * * * * * * * * 162 """ 163 print (title) 164 time.sleep(5) 165 text = """ 166 灵儿事毕,我父再无心静修,辞别掌教,下山入世。 167 得一高人指点,拜于一隐门之中,勤学苦练,终得 168 真传。我父正欲出山报仇,被隐门上士所阻,言道 169 京城宦官家有一大内高手田伯光,武力高达90有余, 170 欲胜之需闯本门的锁妖塔拿一绝世宝物(双倍暴击率) 171 方可成行。 172 """ 173 for i in text.decode(‘utf-8‘): 174 if i != ‘ ‘: 175 time.sleep(0.5) 176 print i.encode(‘utf-8‘), 177 else: 178 print i.encode(‘utf-8‘), 179 time.sleep(2) 180 while TAG: 181 text = """ 182 剧情分支选择如下: 183 1,听劝 184 2,不听劝 185 186 """ 187 print (text) 188 choose = raw_input("请输入索引进行选择") 189 if choose == ‘1‘: 190 Lock_demon_tower(user) 191 elif choose == ‘2‘: 192 Fail_ending_one() 193 else: 194 print ("你的选择有误!") 195 196 197 198 def Lock_demon_tower(user): 199 List = [] 200 dict = common.log_info_read(DIR + ‘config_conf‘) 201 for pobj in dict[‘players‘]: 202 if pobj.Name == user.Name: 203 P = pobj 204 205 time.sleep(2) 206 title = """ 207 * * * * * * * * * * * * * * * * * * * * * * *第四章:勇闯锁妖塔* * * * * * * * * * * * * * * * * * * * * * * 208 """ 209 print (title) 210 time.sleep(5) 211 text = """ 212 反复思量,我父还是决定暂缓报仇,遵从隐士的看法, 213 独自一人来到锁妖塔前,看者前方雄伟的高达{0} 214 层的锁妖塔,暗下决心,要尽快完成闯塔拿到宝物. 215 于是,我父来到了塔下的驿站里... 216 """.format(str(len(user.Tlist_obj))) 217 for i in text.decode(‘utf-8‘): 218 if i != ‘ ‘: 219 time.sleep(0.5) 220 print i.encode(‘utf-8‘), 221 else: 222 print i.encode(‘utf-8‘), 223 while TAG: 224 test = """ 225 请问现在你想去哪? 226 1,闯塔 227 2,打开背包(吃药) 你还有{0}体力 228 3,不闯了,直接去报仇 229 """.format(str(P.Strength)) 230 print (test) 231 choose = raw_input("请输入索引进行选择:") 232 num = 0 233 bum = 0 234 if choose == ‘1‘: 235 for tobj in dict[‘towers‘]: 236 if P.schedule[tobj] == 100: 237 schedule = ‘已达成‘ 238 bum += 1 239 else: 240 schedule = P.schedule[tobj] 241 print ("{0},{1},难度系数:{2},进度率:{3}%,创塔次数:{4}次".format(str(num+1),tobj.Lname,tobj.Difficulty,str(schedule),str(P.num[tobj]))) 242 if bum == len(P.Tlist_obj): 243 print ("{0},锁妖塔顶层,难度系统:0".format(str(num+2))) 244 num += 1 245 List.append(str(num)) 246 decide = raw_input("请输入索引进行选择:") 247 if decide == str(len(P.Tlist_obj)+1) and bum == len(P.Tlist_obj): 248 Lock_demon_tower_Top(user) 249 if decide in List: 250 if P.schedule[dict[‘towers‘][int(decide)-1]] < 100: 251 for i in range(10): 252 re = P.Begins(dict[‘towers‘][int(decide)-1]) 253 if re == False: 254 common.log_info_write(DIR + ‘config_conf‘, dict) 255 break 256 else: 257 common.log_info_write(DIR + ‘config_conf‘, dict) 258 else: 259 print ("本层已经闯过了!") 260 else: 261 print ("你的输入有误!") 262 263 264 elif choose == ‘2‘: 265 while TAG: 266 text = """ 267 背囊物品如下: 你还有{0}体力 268 1,大还丹:{1}个 269 2,小还丹 {2}个 270 """.format(str(P.Strength),str(P.Item[‘大还丹‘]),str(P.Item[‘大还丹‘])) 271 print (text) 272 choose = raw_input("请输入索引进行选择:") 273 if choose == ‘1‘: 274 if P.Item[‘大还丹‘] > 0 : 275 P.Item[‘大还丹‘] -= 1 276 P.Strength += 500 277 common.log_info_write(DIR + ‘config_conf‘, dict) 278 break 279 else: 280 print ("大还丹个数为0") 281 break 282 elif choose == ‘2‘: 283 if P.Item[‘小还丹‘] > 0: 284 P.Item[‘小还丹‘] -= 1 285 P.Strength += 200 286 common.log_info_write(DIR + ‘config_conf‘, dict) 287 break 288 else: 289 print ("小还丹个数为0") 290 break 291 else: 292 print ("你的输入有误!请重新输入!") 293 294 elif choose == ‘3‘: 295 Fail_ending_one() 296 else: 297 print ("你的输入有误!") 298 299 300 def Lock_demon_tower_Top(user): 301 dict = common.log_info_read(DIR + ‘config_conf‘) 302 for pobj in dict[‘players‘]: 303 if pobj.Name == user.Name: 304 P = pobj 305 time.sleep(2) 306 title = """ 307 * * * * * * * * * * * * * * * * * * * * * * *第五章:锁妖塔顶* * * * * * * * * * * * * * * * * * * * * * * 308 """ 309 print (title) 310 time.sleep(5) 311 text = """ 312 克服磨难,吾父终至,锁妖塔顶。与前相比,此地奇静。 313 地方不大,有水缸一口,两人高有余。好奇之下, 314 侧身观之,怎料竟有活人居于缸内,遂上前,救出。 315 原来此人就是灵儿。询问下,方知,那日毕,其心已死, 316 趁高富帅不备,遂逃出,寻短见,幸被隐门上士所救,居 317 此疗伤,恰逢我父闯塔,喜得相逢。至此,我父恍然,直呼, 318 此宝胜万宝也(主角瞬间满怒体力翻倍) 319 """ 320 for i in text.decode(‘utf-8‘): 321 if i != ‘ ‘: 322 time.sleep(0.5) 323 print i.encode(‘utf-8‘), 324 else: 325 print i.encode(‘utf-8‘), 326 P.Strength = P.Strength * 2 327 common.log_info_write(DIR + ‘config_conf‘, dict) 328 Wu_Duo(user) 329 330 331 def Wu_Duo(user): 332 333 334 time.sleep(2) 335 title = """ 336 * * * * * * * * * * * * * * * * * * * * * * *终章:武夺* * * * * * * * * * * * * * * * * * * * * * * 337 """ 338 print (title) 339 time.sleep(5) 340 text = """ 341 经过不懈的努力,战胜了诸多困苦(实在懒得编了), 342 我们的主角终于和美女团结友爱的在一起生活,剧终 343 344 """ 345 for i in text.decode(‘utf-8‘): 346 if i != ‘ ‘: 347 time.sleep(0.5) 348 print i.encode(‘utf-8‘), 349 else: 350 print i.encode(‘utf-8‘), 351 exit() 352 353 354 355 def Fail_ending_one(): 356 357 358 359 time.sleep(2) 360 title = """ 361 * * * * * * * * * * * * * * * * * * * * * * *终章:武夺* * * * * * * * * * * * * * * * * * * * * * * 362 """ 363 print (title) 364 time.sleep(5) 365 text = """ 366 报仇心切,我父终是不肯听劝,遂一人趁夜逃出隐门, 367 数日后,进京踩点,待万事俱备只欠东风之时,奈何 368 大员祖宅大内高手,先知先觉,早已暗随我父三日有余, 369 眼见我父正待出手,遂突袭之,我父重伤,感叹报仇无望, 370 自此隐居山林,不问世事.....BAD END...... 371 372 """ 373 for i in text.decode(‘utf-8‘): 374 if i != ‘ ‘: 375 time.sleep(0.5) 376 print i.encode(‘utf-8‘), 377 else: 378 print i.encode(‘utf-8‘), 379 exit()
Python07旧版作业源码:虚拟人生(仅供参考)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。