Commit fa148596 by BellCodeEditor

auto save

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