Commit f434d16d by BellCodeEditor

save project

parent 46968e4a
Showing with 34 additions and 3 deletions
# 英雄角色类
import random
class Hero(object):
def __init__(self, name):
self.level = 1
......@@ -14,8 +17,36 @@ class Hero(object):
def combat(self,enemy):
info1 = self.name + "对" + str(enemy.hp) + "血量"
info2 = "造成" +
info2 = "造成" + str(self.attack) + "点伤害,"
enemy.hp -= self.attack
if enemy.hp > 0:
info3 = enemy.name + "还剩下" + str(enemy.hp) + "血量"
info= info1 + info2 + info3
print(info)
else:
info3 = enemy.name + "阵亡,游戏结束"
info= info1 + info2 + info3
print(info)
exit()
class pleyer(hero):
def__init__(self,hero_type,name):
super().__init__(name)
self.hp = 200
self.attack = 50
self.max_hp = self.hp
self.hero_type = hero_type
print("角色" + self.name + "创建成功,英雄类型为:",self.hero__type)
print("当前血量、血量、攻击分别为:",sself.level,self.hp,self.attack)
houyi = pleyer()
yase = Hero("垭瑟")
houyi= Hero("后羿")
......
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