Commit e5882d95 by BellCodeEditor

save project

parent 6394be11
Showing with 16 additions and 6 deletions
from time import sleep
# 英雄角色类
class Hero(object):
def __init__(self, name):
......@@ -7,12 +9,20 @@ class Hero(object):
self.name = name
def combat(self, enemy): # 攻击
enemy.hp -= self.attack;
info1 = enemy.name + "对" + self.name + "发起进攻,";
info2 = "造成" + str(self.attack) + "伤害";
info3 = enemy.name + "还剩下" + str(enemy.hp) + "点血量";
info = info1 + info2 + info3;
print(info);
while True:
enemy.hp -= self.attack;
info1 = enemy.name + "对" + self.name + "发起进攻,";
info2 = "造成" + str(self.attack) + "伤害";
info3 = enemy.name + "还剩下" + str(enemy.hp) + "点血量";
info = info1 + info2 + info3;
if self.hp <= 0:
print(enemy.name + "对" + self.name + "发起进攻," + self.name + "阵亡");
break;
elif enemy.hp < 0:
print(self.name + "对" + enemy.name + "发起进攻," + enemy.name + "阵亡")
break;
print(info);
sleep(0.5);
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