Commit 1359a703 by BellCodeEditor

save project

parent 1f73b3c5
Showing with 23 additions and 8 deletions
import random
class Hero(object): class Hero(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
self.level = 1 self.level = 1
self.hp = 250 self.hp = 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
self.attack = 40 self.attack = 8888888888888888888888888888888888888888888888888888888888888888888888
self.max_hp = self.hp self.max_hp = self.hp
def cure(self): # 治疗 def cure(self): # 治疗
...@@ -29,15 +30,15 @@ class Hero(object): ...@@ -29,15 +30,15 @@ class Hero(object):
class Player(Hero): class Player(Hero):
def __init__(self,hero_type,name): def __init__(self,hero_type,name):
super().__init__(name) super().__init__(name)
self.hp = 999999999999999999999999999999999999999999999999999 self.hp = 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
self.attack = 50 self.attack =88888888888888888888888888888888888888
self.max_hp = self.hp self.max_hp = self.hp
self.hero_type = hero_type self.hero_type = hero_type
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)
houyi = Player("射手", "后羿") liyunlong = Player("射手", "李云龙")
yase = Hero("垭瑟") huaqiang = Hero("华强")
#houyi.combat(yase) #houyi.combat(yase)
#yase.combat(houyi) #yase.combat(houyi)
#houyi.cure() #houyi.cure()
...@@ -47,4 +48,18 @@ print(' 战斗开始') ...@@ -47,4 +48,18 @@ print(' 战斗开始')
while True: while True:
print('_'*30) print('_'*30)
choice=input('请选择技能1战斗/2治疗') choice=input('请选择技能1战斗/2治疗')
if choice=='q':
\ No newline at end of file print('game over')
break
elif choice=='2':
huaqiang.cure()
elif choice=='1':
huaqiang.combat(liyunlong)
else:
print('输入无效,请重新输入1,2或q')
continue
w=random.randint(1,3)
if w==1:
liyunlong.combat(huaqiang)
else:
liyunlong.cure()
\ No newline at end of file
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