Commit 00628d59 by BellCodeEditor

auto save

parent 9f70c81a
Showing with 35 additions and 11 deletions
import random
class Hero(object):
def __init__(self, name):
self.name = name
self.level = 1
self.hp = 250
self.attack = 40
self.level = 100
self.hp = 5000
self.attack = 450
self.max_hp = self.hp
def cure(self): # 治疗
self.hp=self.hp+60
boold=random.randint(250,700)
self.hp=self.hp+boold
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
print(self.name+"使用了治疗,血量增加:", boold,",目前的血量为:",self.hp)
def boold(self): # 治疗
self.hp=self.hp+boold
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
......@@ -25,12 +31,11 @@ class Hero(object):
info = info1+info2+info3
print(info)
exit()
class Player(Hero):
def __init__(self,hero_type,name):
super().__init__(name)
self.hp = 200
self.attack = 50
self.hp = 2600
self.attack = 675
self.max_hp = self.hp
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
......@@ -41,4 +46,22 @@ houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
while True:
print('-'*50)
input("请输入您的技能1攻击/2治疗")
\ No newline at end of file
nam = input("请输入您的技能1,4攻击/2,3治疗:")
if nam == 'q':
break
elif nam == '1':
houyi.combat(yase)
elif nam == '2':
houyi.cure()
elif nam == '4':
houyi.combat(yase)
elif nam == '3':
houyi.cure()
else:
print('请重新输入:')
continue
num = random.randint(1,3)
if num == 1 :
yase.combat(houyi)
else:
yase.cure()
\ No newline at end of file
++ "b/\350\256\270\350\257\272"
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