Commit 9c1a871e by BellCodeEditor

auto save

parent 9a581ef4
Showing with 23 additions and 6 deletions
# 英雄角色类 # 英雄角色类
import random
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.level = 1 self.level = 1
...@@ -6,9 +7,26 @@ class Hero(object): ...@@ -6,9 +7,26 @@ class Hero(object):
self.attack = 40 self.attack = 40
self.name = name self.name = name
def combat(): # 攻击 def combat(self,duifang):
??? duifang.hp = duifang.hp - self.attack # 攻击
info1 = self.name+'攻击了'+duifang.name+','
info2 = duifang.name+'减少了'+str(self.attack)+'点血量,'
if duifang.hp >0:
info3 = duifang.name+'还剩下'+str(duifang.hp)+'点血。'
info=info1+info2+info3
print(info)
else:
info3 = duifang.name+'阵亡。'
info=info1+info2+info3
print(info)
yase = Hero("垭瑟") wjh= Hero("王锦辉")
houyi= Hero("后羿") ljl= Hero("李锦隆")
yase.combat(houyi) lzt = Hero('李梓滔')
\ No newline at end of file lyl = Hero('李奕隆')
ct = Hero('TT')
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