Commit fa40b254 by BellCodeEditor

save project

parent 91715a0c
Showing with 24 additions and 5 deletions
import random
class Hero: class Hero:
def __init__(self,name): def __init__(self,name):
self.level=1 self.level=1
...@@ -28,11 +29,30 @@ class Player(Hero): ...@@ -28,11 +29,30 @@ class Player(Hero):
self.hp=200 self.hp=200
self.attack=50 self.attack=50
self.hero_type=hero_type self.hero_type=hero_type
print('-'*30)
print('恭喜你成功创造角色:'+self.name+'他的英雄类型为:'+self.hero_type) print('恭喜你成功创造角色:'+self.name+'他的英雄类型为:'+self.hero_type)
print('他的属性为等级:',self.level,'血量:',self.hp,'攻击力:',self.attack) print('他的属性为等级:',self.level,'血量:',self.hp,'攻击力:',self.attack)
yase=Hero('亚瑟') yase=Hero('亚瑟')
houyi=Player('后羿','射手') houyi=Player('后羿','射手')
yase.combat(houyi) print('-'*30)
houyi.cure() print(' 战斗开始')
print(houyi.hp) while True:
print(yase.hp) print('-'*30)
\ No newline at end of file k=input('请选择英雄技能(1攻击/2治疗):')
g=random.randint(1,2)
if k=='1':
houyi.combat(yase)
elif k=='2':
houyi.cure()
elif k='q':
else:
print('请重新输入(1或2)')
continue
if g==1:
yase.combat(houyi)
else:
yase.cure()
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