Commit 959b1341 by BellCodeEditor

auto save

parent 5ec53ebb
class Hero:
def __init__(self, name):
self.name = name
self.level = 1
self.hp = 250
self.attack = 40
self.max_hp = self.hp
def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
enemy.hp -= self.attack
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1+info2+info3
print(info)
else:
info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3
print(info)
exit()
def cure(self):
self.hp=self.hp+60
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用治疗术血量增加:",60,",目前血量为 :",self.hp)
class Player(Hero):
def __init__(self,name,hero_type):
super().__init__(name)
self.hp=200
self.attack=50
self.hero_type=hero_type
self.max_hp = self.hp
print("角色"+self.name+"创建成功英雄类型为",self.hero_type)
print("当前等级,血量,攻击为",self.level,self.hp,self.attack)
player = Player("后羿","射手")
d'g'v'fdgvf
\ No newline at end of file
import diy1
data = diy1.new_input()
score = diy1.sum(data)
print("这位选手的总分为:"+str(score))
\ No newline at end of file
def new_input():
total = []
while True:
unit = input("请输入价格: ")
if unit =="q":
break
else:
try:
unit = int(unit)
except:
print("请输入整数!")
else:
total.append(unit)
print("🐱‍👓"*30)
return total
def sum(money):
count = 0
for i in money:
count +=i
return count
a = new_input()
b = sum(a)
print("总价:",b)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment