Commit 72002e78 by BellCodeEditor

save project

parent bf0c6f97
Showing with 22 additions and 2 deletions
import random
class Hero: class Hero:
def __init__(self,name): def __init__(self,name):
self.level=1 self.level=1
...@@ -26,12 +27,13 @@ class Hero: ...@@ -26,12 +27,13 @@ class Hero:
class Player(Hero): class Player(Hero):
def __init__(self,name): def __init__(self,name,hero_type):
super().__init__(name) super().__init__(name)
self.hp=190 self.hp=190
self.attack=70 self.attack=70
self.maxhp=self.hp self.maxhp=self.hp
print('角色'+self.name+'创建成功,英雄类型为:',self.hero_tape) self.hero_type=hero_type
print('角色'+self.name+'创建成功,英雄类型为:',self.hero_type)
print('当前等级,血量,攻击力为:',self.level,self.hp,self.att) print('当前等级,血量,攻击力为:',self.level,self.hp,self.att)
player=Player('后羿') player=Player('后羿')
...@@ -42,3 +44,21 @@ player=Player('后羿') ...@@ -42,3 +44,21 @@ player=Player('后羿')
yase = Hero('亚瑟') yase = Hero('亚瑟')
houyi = Hero('后羿') houyi = Hero('后羿')
while True:
print(30*'-')
choice=input('1攻击,2治疗,q退出')
if choice=='q':
print('游戏结束')
break
elif choice=='1':
houyi.combat(yase)
elif choice=='2':
houyi.cure()
else:
print('输入1、2、q')
continue
num=random.randint(1,3)
if num==1:
yase.cure()
else:
yas .combat(houyi)
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