Commit 17ffb873 by BellCodeEditor

save project

parent 2bc01909
Showing with 25 additions and 6 deletions
......@@ -6,9 +6,28 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,enemy): # 攻击
enemy.hp = enemy.hp-self.attack
info1 = self.name+"dui"+enemy.name+"fa qi jin gong,"
info2 = "zao cheng"+str(self.attack)+"dian shang hai,"
if enemy.hp>0:
info3 = enemy.name+"hia sheng xia"+str(enemy.hp)+"xue liang."
info = info1+info2+info3
print(info)
else:
info3 = enemy.name+"zhen wang,you xi jie shu"
info = info1+info2+info3
print(info)
exit()
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
class Player(Hero):
def __init__(self,name,hero_type):
super().__init__(name)
self.attack = 50
self.hp = 200
self.hero_type = hero_type
print("jue se"+self.name+"chuang jian cheng gong,ying xiong lei xing wei:",self.hero_type)
print("jue se de deng ji xue liang gong ji fen bie wei:",self.level,self.hp,self.attack)
houyi = Player("后羿","she shou")
yase = Hero("垭瑟")
\ 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