Commit 8ba4c557 by BellCodeEditor

save project

parent 9a581ef4
Showing with 14 additions and 4 deletions
...@@ -3,12 +3,21 @@ class Hero(object): ...@@ -3,12 +3,21 @@ class Hero(object):
def __init__(self, name): def __init__(self, name):
self.level = 1 self.level = 1
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 20
self.name = name self.name = name
def combat(): # 攻击 def combat(self,enemy):
??? enemy.hp-=self.attack
a1=self.name+"对"+enemy.name+"发起了非常哟西的公鸡,\n"
a2=enemy.name+"受到了大佐八嘎呀路的公鸡"+"损失了"+str(self.attack)+"大大的生命值。\n"
if enemy.hp>0:
a3=enemy.name+"受了大大的伤,还剩"+str(enemy.hp)+"点血量\n"
a4=a1+"-"*126+a2+"-"*126+a3
print(a4)
else:
a3=enemy.name+"已经阵亡,死拉死拉的!\n"
a4=a1+"-"*126+a2+"-"*126+a3
print(a4)
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Hero("后羿")
yase.combat(houyi) 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