Commit 32343300 by BellCodeEditor

save project

parent 9a581ef4
Showing with 22 additions and 5 deletions
# 英雄角色类 # 英雄角色类
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name,a,b,da,db):
self.level = 1 self.level = 1
self.hp = 250 self.hp = 250
self.attack = 40 self.attack = 40
self.name = name self.name = name
self.a = a
self.da = da
self.b = b
self.db = db
def combat(): # 攻击 def combat(self,en): # 攻击
??? en.hp-=self.attack
at="普通攻击"
print("-"*30)
print(self.name,"对",en.name,"使用了"+at,"\n造成了"+str(self.attack)+"点伤害")
print("对方还剩",en.hp,"点血")
if self.hp < 1:
print("您已阵亡")
exit()
elif en.hp < 1:
print("对方已阵亡")
exit()
print("-"*30)
yase = Hero("垭瑟")
houyi= Hero("后羿") yase = Hero("伏拉夫","吃火锅",100,"吃小孩",105)
houyi= Hero("蔡徐坤","鸡你太美",115,"打篮球",75)
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