Commit c8a64b23 by BellCodeEditor

save project

parent f9d541e5
Showing with 47 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
...@@ -21,7 +22,7 @@ class Hero(object): ...@@ -21,7 +22,7 @@ class Hero(object):
info = info1+info2+info3 info = info1+info2+info3
print(info) print(info)
else: else:
info3 = enemy.name+"阵亡,游戏结束" info3 = enemy.name+"阵亡,游戏结束"'
info = info1+info2+info3 info = info1+info2+info3
print(info) print(info)
exit() exit()
...@@ -29,16 +30,44 @@ class Hero(object): ...@@ -29,16 +30,44 @@ 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 = 220
self.attack = 50 self.attack = 70
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)
def cure(self): # 治疗
bob = random.randint(35,55)
self.hp += bob
if self.hp>self.max_hp:
self.hp=self.max_hp
print(self.name+"使用了治疗,血量增加:", bob,",目前的血量为:",self.hp)
houyi = Player("射手", "后羿") houyi = Player("射手", "后羿")
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi.combat(yase) print('-'*30)
yase.combat(houyi) print(' 战斗开始')
houyi.cure() while True:
yase.cure() print('-'*30)
\ No newline at end of file choice = input('请选择英雄技能(1攻击/2治疗)')
if choice == "1":
houyi.combat(yase)
elif choice == '2':
houyi.cure()
elif choice == 'q':
break
else:
houyi.combat(houyi)
print('请从新选择1/2')
continue
rum = random.randint(1,3)
if rum == 1:
yase.cure()
else:
yase.combat(houyi)
from turtle import*
color('green')
pensize('10')
fillcolor('yellow')
begin_fill()
for i in range(5):
forward(100)
right(144)
end_fill()
done()
\ 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