Commit 58ce5fb5 by BellCodeEditor

save project

parent 8f4bec25
Showing with 13 additions and 27 deletions
n=0
n=n+1000909099
print(n*n*n*n*n)
\ No newline at end of file
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 = 2800
self.attack = 40 self.attack = 40
self.max_hp = self.hp self.max_hp=self.hp
def cure(self): # 治疗 def cure(self): # 治疗
self.hp+=55 self.hp=self.hp+60
self.max_hp=self.hp
if self.hp>self.max_hp: if self.hp>self.max_hp:
self.hp=self.max_hp slf.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp) print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击 def combat(self, enemy): # 普通攻击
...@@ -31,7 +33,7 @@ class Hero(object): ...@@ -31,7 +33,7 @@ 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 = 200 self.hp = 2000
self.attack = 50 self.attack = 50
self.max_hp = self.hp self.max_hp = self.hp
self.hero_type = hero_type self.hero_type = hero_type
...@@ -48,24 +50,5 @@ class Player(Hero): ...@@ -48,24 +50,5 @@ class Player(Hero):
houyi = Player("射手", "后羿") houyi = Player("射手", "后羿")
yase = Hero("垭瑟") yase = Hero("垭瑟")
while True:
print('-'*30)
a=input("请选择技能:1攻击/2治疗")
if int(a)==1:
houyi.combat(yase)
elif int(a)==2:
houyi.cure()
elif a=="q":
print('游戏结束')
break
else:
print('重输!')
continue
b=random.randint(1,3)
if b==3:
yase.cure()
else:
yase.combat(houyi)
houyi.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