Commit 516efaac by BellCodeEditor

save project

parent 5ae6cf6d
Showing with 12 additions and 22 deletions
# 英雄角色类 from pyecharts.charts import Bar
class Hero(object):
def __init__(self, name): subjects=["语文","数学","英语","地理",
self.level = 1 "历史","政治","生物","化学","物理"]
self.hp = 250 scores = [88, 95, 96, 94, 62, 66, 64, 93, 89]
self.attack = 40 # 创建对应的图表对象
self.name = name bar = Bar()
# 传入x轴和y轴的数据
def combat(self,enemy): # 攻击 bar.add_xaxis(subjects)
enemy.hp-=self.attack bar.add_yaxis("浈浈的成绩", scores)
info1=self.name+"对"+enemy.name+"发起进攻," # 保存到本地文件
info2="造成"+str(self.attack)+"点伤害," bar.render("analysis.html")
if enemy.hp>0:
info3=info3=enemy.name+"还剩"+str(enemy.hp)+"点血。"
info=info1+info2+info3
print(info)
else:
info3=enemy.name+"死亡,游戏结束。"
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