Commit 139e8187 by BellCodeEditor

save project

parent 0ee52890
Showing with 9 additions and 3 deletions
......@@ -6,9 +6,14 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,enemy): # 攻击
self.hp -=self.attack
info1 = str(self.name)+"对"+str(enemy.name)+"发动攻击,"
info2 = "造成"+str(self.attack)+"点攻击,"
info3 = str(enemy.name)+"还剩下"+str(self.hp)+"血量"
info = info1+info2+info3
print(info)
yase = 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