Commit ae5b2bac by BellCodeEditor

save project

parent c96da38c
Showing with 21 additions and 7 deletions
import random
class Hero(object):
def __init__(self, name):
self.name = name
......@@ -6,11 +7,11 @@ class Hero(object):
self.attack = 40
self.max_hp = self.hp
def cure(self,enemy):
def cure(self):
self.hp+=65 # 治疗
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:", 65,",目前的血量为:",self.hp)
print(self.name+"使用了治疗,血量增加:", 65,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻,"
......@@ -35,12 +36,26 @@ class Player(Hero):
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
print('-'*30)
print(' 战斗开始')
while True:
print('-'*30)
a=input('请输入技能:1治疗/2攻击')
\ No newline at end of file
print('-'*30)
a=input('请输入技能:1治疗/2攻击')
if a=='q':
print('游戏结束!!!')
elif a== '1':
houyi.cure()
elif a=='2':
houyi.combat(yase)
else:
print('请重新输入!!!')
continue
nam=random.randint(1,3)
if nam==1:
yase.cure()
else:
yase.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