转载自:https://blog.csdn.net/cookie_xq/article/details/102528049
import time import random print('''欢迎来到「七七的小世界」! 七七对你的到来表示十二万分的兴高采烈w''') time.sleep(1.5) print('--------------------------') print('''今天天气真好呢! 或许...''') time.sleep(1.5) print('你想和七七一起做游戏嘛(星星眼)') time.sleep(1.5) print('--------------------------') print('【请选择】') print('(七七温馨提示:要输入大写的字母鸭)') a1 = input('A.想 B.不想 ') if a1 == 'B': print('真遗憾,下次有缘再见咯~') time.sleep(2) elif a1 == 'A': while True: print('(σ´∀`)σ 七七超开心,并努力抑制喜悦于言表') time.sleep(1.5) print('那么,你想和七七玩儿什么呢') a2 = input('A.猜数字 B.打小怪兽 C.大人的游戏 ') if a2 == 'A': print('''嗯嗯!那就来猜一个50以内的整数好啦 来猜猜七七心里想的数是多少? 一共有五次机会哟''') time.sleep(1.5) right = random.randint(0, 50) for i in range(5): print('--------------------------') char = int(input('请输入:')) if char == right: print('猜对啦,七七超级佩服你!') break elif char > right: print('猜大了捏') else: print('猜小了捏') else: print('五次机会都没有猜中,你失败啦') elif a2 == 'B': blood = random.randint(1, 100) attack = random.randint(1, 100) print('经过七七灵魂的透视,你的属性是:') print('血量:' + str(blood)) print('攻击:' + str(attack)) time.sleep(1.5) if blood > 80 or attack > 80: print('哇!!真是天赋异禀(七七趁你不注意偷偷擦口水)') elif blood < 20 or attack < 20: print('emmm,接下来的路要小心啊!') else: print('海星啊兄dei!加把劲我们可以干掉小怪兽~') time.sleep(1.5) print('--------------------------') while blood > 0: time.sleep(1.5) blood2 = random.randint(1, 80) attack2 = random.randint(1, 80) money2 = random.randint(1, 10) print('遇到了一只小怪兽') print('【请选择】') choice = input('A.攻击 B.我要肥家 ') if choice == 'A': print('--------------------------') time.sleep(1) print('【小怪兽】 血量:%d 攻击:%d' % (blood2, attack2)) print('--------------------------') time.sleep(1) while blood > 0 and blood2 > 0: blood = blood - attack2 blood2 = blood2 - attack print('你发起了攻击,【小怪兽】的血量%d' % blood2) print('同时,小怪兽向你发起了攻击,【你】的血量%d' % blood) print('--------------------------') time.sleep(1.2) if blood > 0 and blood2 <= 0: print('小怪兽死翘翘了,七七超级崇拜你!') print('获得了金币¥10!') print('要给七七买小零食嘛?') print('【请选择】') buy = input('A.要 B.不要 ') if buy == 'A': print('--------------------------') appetizer = ['香蕉可丽饼', '草莓蛋糕', '薄荷冰淇淋'] print('七七收到了你的礼物...啊!竟然是七七最爱的' + random.choice(appetizer)) print('七七开心到飞起来啦!') time.sleep(1.5) elif buy == 'B': print('好叭qwq哭唧唧') print('--------------------------') elif blood <= 0 and blood2 > 0: print('啊呜呜qwq小怪兽把你干掉了!') else: print('哎呀呀,你和小怪兽都死翘翘了!') elif choice == 'B': print('--------------------------') break print('''好啦好啦,你超棒der! (七七给你揉揉并送你回家休息♡''') time.sleep(1.5) elif a2 == 'C': print('''诶诶诶/// 大人的游戏是什么辣(捂脸) 七七只和有缘的人玩这个游戏哦''') time.sleep(1.5) name = input('请输入你的名字:') if name == '小叭': print('如果是小叭的话///可以噢') print('咕嘿嘿嘿嘿嘿嘿') else: print('诶,真遗憾。你和七七不是有缘人呢') time.sleep(1.5) print('-------------------------- 还要继续和七七一起玩儿嘛? 【请选择】 A.要! B.七七拜拜,下次再和你一起玩辣') a = input('你的选择是: ') if a == 'B': print('拜拜咯|ू・ω・` )七七会想你的唔!') time.sleep(2) break
界面效果: