Commit fa148596 by BellCodeEditor

auto save

parent fb097064
Showing with 13 additions and 13 deletions
# 英雄角色类
class Hero(object):
class Hero:
def __init__(self, name):
self.hp = 254
self.attack = 27
self.name = name
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)
def combat(self,name1):
info1=self.name+"对"+name1.name+"发起进攻"
info2="造成"+str(self.attack)+"点伤害"
name1.hp-=self.attack
if name1.hp>0:
info3=name1.name+"还剩下"+str(name1.hp)+"血量"
info=info1+info2+info3
print(info)
else:
info3= name1.name+"阵亡,游戏结束"
info=info1+info2+info3
print(info)
Tran = Hero("Tran")
......
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