Commit a3b53b0e by BellCodeEditor

save project

parent 4994250d
Showing with 12 additions and 6 deletions
# 英雄角色类
import random()
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
self.name = name
def combat(self,duifang): # 攻击
duifang.hp-=self.attack
if duifang.hp>0:
print(self.name+"对"+duifang.name+"发起攻击,"+duifang.name+"减少"+self.attack+"血量,"+duifang.name+"还剩"+duifang.hp+"血量")
print(self.name+"对"+duifang.name+"发起攻击,"+duifang.name+"减少"+str(self.attack)+"血量,"+duifang.name+"还剩"+str(duifang.hp)+"血量")
else:
print(duifang.name+"已阵亡,游戏结束")
print("You Win")
exit()
def zhiliao(self):
if self.hp<250:
self.hp+=40
else:
print("血量已满,加血无效!")
while True:
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
houyi= Hero("后羿")
\ 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