Commit fb097064 by BellCodeEditor

save project

parent aa07b241
Showing with 18 additions and 8 deletions
# 英雄角色类
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.hp = 254
self.attack = 27
self.name = name
def combat(): # 攻击
???
Def 函数名(self,name1)
name1.hp-=self.attack
Info1=self.name+”还剩”+str(name1)
Inof2=”造成”+str(self.attack)+”点伤害”
If name1.hp>0:
Info3=name1.”还剩下”+str(name1.hp)+”血量”
Info=info1+info2+info#
Print(info)
Else:
Info3= name1.name+”阵亡,游戏结束”
Info=info1+info2+info3
Print(info)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
Tran = Hero("Tran")
Law= Hero("Law")
Tran.combat(Law)
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