# 人间重开模拟器import random
import sys
import time
print('---------------------------------------------')print('| 花有重开日,人无再少年 |')print('| 欢迎来到,人生重开模拟器 |')print('---------------------------------------------')# 设置初始属性,总和不能超过20# 颜值,体质,智力,家境whileTrue:print('请设置初始属性值(可用点数总和为20)')
face =int(input('请输入颜值(1-10):'))
strong =int(input('请输入体质(1-10):'))
iq =int(input('请输入智力(1-10):'))
home =int(input('请输入家境(1-10):'))# 判断初始属性值输入是否正确if face <1or face >10:print('颜值输入有误')continueif strong <1or strong >10:print('体质输入有误')continueif iq <1or iq >10:print('智力输入有误')continueif home <1or home >10:print('家境输入有误')continueif face + strong + iq + home >20:print('总和输入超出限制,请重新输入')continue# 此时,如果输入上述条件都没有触发,可以跳出循环结束print('初始属性设置完毕')print(f"颜值:{face},体质:{strong},智力:{iq},家境:{home}")break# 生成角色性别,这里使用random.randint()生成[x,y]的随机整数
point = random.randint(1,6)if point %2==1:
gender ='boy'print('你是个男孩')else:
gender ='girl'print('你是个女孩')# 设置角色的出生点,生成1-3的随机整数
point = random.randint(1,3)if home ==10:# 第一档print('你出生在帝都,你的父母是高官政要')
home +=1
iq +=1
face +=1elif7<= home <=9:# 第二档if point ==1:print('你出生在大城市,你的父母是公务员')
face +=2elif point ==2:print('你出生在大城市,你的父母是企业高管')
home +=2else:print('你出生在大城市,你的父母是大学教授')
iq +=2elif4<= home <=6:# 第三档if point ==1:print('你出生在三线城市,你的父母是医生')
strong +=1elif point ==2:print('你出生在镇上,你的父母是老师')
iq +=1else:print('你出生在镇上,你的父母是个体户')
home +=1else:# 第四档if point ==1:print('你出生在三线城市,你的父母是辛苦劳作的农民')
strong +=1
face -=2elif point ==2:print('你出生在穷乡僻壤,你的父母是无业游民')
home -=1else:print('你出生在镇上,你的父母感情不和')
strong -=1# 幼年阶段for age inrange(1,11):# 把一整年的打印都整理到字符串中,在这一年的结尾统一打印
info =f'你今年{age}岁'# 生成1-3的随机整数,与性别联合触发时间
point = random.randint(1,3)# 性别触发事件if gender =='girl'and home <=3and point ==1:
info +='你的家里重男轻女思想非常严重,你被遗弃了'print(info)
sys.exit(0)# 体质触发事件elif strong <6and point <3:
info +='你生了一场病'if home >=5:
info +='在父母的悉心照料下,你康复了'
strong +=1
home -=1else:
info +='你的父母没有精力管你,你的身体状况更加糟糕了'
strong -=1# 颜值触发的时间elif face <=4and age >=7:
info +='你长得太丑了,别的小朋友不喜欢你'if iq >5:
info +='你决定用学习填充自己!'
iq +=1else:if gender =='boy':
info +='你和别的小朋友经常打架!'
strong +=1
iq -=1else:
info +='你被别的小朋友欺负!'
strong -=1# 智商触发事件elif iq <5:
info +='你看起来傻傻的'if home >=8and age >=6:
info +='你的父母把你送到更好的学校学习'
iq +=1elif4<= home <=7:if gender =='boy':
info +='你的父母鼓励你多运动,争取成为运动员'
strong +=1else:
info +='你的父母鼓励你多打扮自己'
face +=1else:
info +='你的父母为此经常吵架'if point ==1:
strong -=1elif point ==2:
iq -=1else:passelse:
info +='你健康成才了'if point ==1:
info +='你看起来更加结实了'
strong +=1elif point ==2:
info +='你看起来更加好看了'
face +=1else:pass# 打印这一年所发生的事情print(info)print(f'颜值:{face},体质:{strong},智力:{iq},家境:{home}')print('----------------------------------------------------')# 为了观察方便,加一个小小的暂停事件
time.sleep(2)