游戏纯属娱乐!!!
声明:笔者的Python在学习阶段,能力有限。程序存在较多的缺漏,请多多包涵
1 import random as ran 2 fish_1 = 10 3 po = 3 4 5 class Turtle: 6 def eat(): 7 po = 3 8 a = ran.randint(5,25) 9 fishes = fish_1 10 print('|----------------------------------------------------------') 11 print('|@游戏名称:小乌龟喂食') 12 print('|@版本号:v2.1.3') 13 print('|@设计者:红脸白脸') 14 print('|@游戏规则:小乌龟满血有三滴血,玩家需要在小乌龟血量耗尽前将小鱼喂食完毕才能通关') 15 print('|----------------------------------------------------------') 16 count = 1 17 while True: 18 Test.food(fishes) 19 num = input('你需要喂给乌龟几条鱼:') 20 fish = int(num) 21 if fish == 0: 22 po = po-1 23 elif po<3: 24 po = po + 1 25 elif fish<0: 26 print('你调皮了,输入有误!') 27 if fish>2: 28 print('小乌龟被噎死了,游戏结束!') 29 break 30 elif fish <= fishes and fish>=0: 31 fishes = fishes - fish 32 if fishes == 0: 33 print('喂食乌龟任务完成,游戏结束!') 34 break 35 if po==0: 36 print('您的小乌龟已经饿死了,游戏结束!') 37 break 38 else: 39 print('小乌龟的血量剩余'+'❤'*po+',小乌龟正在挨饿……') 40 print('===========|第%s局执行完成|==========='%count) 41 if a == count: 42 print('小乌龟得了瘟疫死了,游戏结束!') 43 break 44 count+=1 45 46 class Test: 47 def food(fishes): 48 print('现在有%s条鱼'%fishes) 49 50 Turtle.eat()
运行结果: