From 0b3f40819839317c616525e8997d163dacf933b2 Mon Sep 17 00:00:00 2001
From: BellCodeEditor <bellcode_dev@bell.ai>
Date: Wed, 3 Feb 2021 14:39:39 +0800
Subject: [PATCH] save project

---
 diy1.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/diy1.py b/diy1.py
index 4084c2e..bbdb068 100644
--- a/diy1.py
+++ b/diy1.py
@@ -4,10 +4,19 @@ class Hero(object):
         self.level = 1
         self.hp = 250
         self.attack = 40
-        self.name = name
+        self.name = name    
+    def combat(self,enemy):
+        self.hp-=enemy.attack
+        info1=enemy.name+'对'+self.name+'发起了进攻,'
+        info2='造成了'+str(enemy.attack)+'点伤害'
+        if self.hp > 0:
+            info3=self.name+'还剩'+str(self.hp)+'血量'
+            info=info1+info2+info3
+            print(info)
+        else:
+            print(info1+info2+self.name+'已阵亡')
+            exit()
         
-    def combat():    # 攻击
-        ???
 
 yase = Hero("垭瑟")
 houyi= Hero("后羿")
--
libgit2 0.25.0