DC_DC_Python_Practice/人生重开模拟器01.py

46 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#实现简化版本的人生重开模拟器
#初始属性
#开始游戏后,随机生成性比我和出生点
#每年都会生成人生的经历(随机)
print('-------------------------------')
print('| |')
print('| 花有重开日。人物在少年 |')
print('| |')
print('| 欢迎来到人生重开模拟器 |')
print('| |')
print('-------------------------------')
#设置初始属性
#颜值——体质——智力——家境总和不超过20每一项取值都是1~10之间
#使用循环,使得玩家输入有误时,重新输入
while True:
print("请设置初始属性可用点数总数为20):")
face = int(input("请输入颜值1~10"))
strong = int(input("请输入体质1~10"))
iq = int(input("请输入智力1~10"))
home = int(input("请输入家境1~10"))
#通过条件语句,对于用户输入的属性值进行校验检查
#这段逻辑可用使用elif效果相同
#使用elif则是多个分支只能使用1个一旦某个条件满足就不会再走其他分支
if face < 1 or face > 10:
print('颜值设置有误')
continue
if strong < 1 or strong > 10:
print('体质设置有误')
continue
if iq < 1 or iq > 10:
print('智商设置有误')
continue
if home < 1 or home > 10:
print('家境设置有误')
continue
if face + strong + iq + home > 20:
print("总属性和超过20设置有误请重新输入")
continue
#如果上述条件都未被触发,则玩家的输入都是正确的
print("属性输入完毕~")
print(f'颜值{face},体质{strong},智力{iq},家境{home}')
break