Commit 9c1a871e by BellCodeEditor

auto save

parent 9a581ef4
Showing with 23 additions and 6 deletions
# 英雄角色类
import random
class Hero(object):
def __init__(self, name):
self.level = 1
......@@ -6,9 +7,26 @@ class Hero(object):
self.attack = 40
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)
wjh= Hero("王锦辉")
ljl= Hero("李锦隆")
lzt = Hero('李梓滔')
lyl = Hero('李奕隆')
ct = Hero('TT')
yase = Hero("垭瑟")
houyi= Hero("后羿")
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