Commit 9b4fd95d by BellCodeEditor

save project

parent d493d152
Showing with 24 additions and 7 deletions
...@@ -4,9 +4,26 @@ class Hero: ...@@ -4,9 +4,26 @@ class Hero:
self.name=name self.name=name
self.hp=hp self.hp=hp
self.attack=attack self.attack=attack
yase=Hero('yase',300,20) # def update(self):
hy=Hero('hy',250,23) # self.level+=1
k=Hero('K',5600,199) # self.hp+=50
print(yase.attack) # self.attack+=100
print(hy.attack) # yase=Hero("亚瑟",500,20)
print(k.attack) # yase.update()
\ No newline at end of file # print( "攻击力为",yase.attack)
def combat(self,enemy):
enemy.hp-=self.attack
a=self.name+"对"+enemy.name+"发起进攻,"
b="造成"+str(self.attack)+"点伤害,"
if enemy.hp>0:
c=enemy.name+"还剩"+str(enemy.hp)+"血量."
d=a+b+c
print(d)
else:
c=enemy.name+"已阵亡."
d=a+b+c
print(d)
yase=Hero("亚瑟",100,10)
houyi=Hero("后裔",100,1000)
yase.combat(houyi)
\ No newline at end of file
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