Commit a9bd63ac by BellCodeEditor

save project

parent 1908b6f2
Showing with 98 additions and 37 deletions
class Hero(object):
def __init__(self, name):
self.name = name
import random
class Pokemon:
def __init__(self,name,hp,attack,defense):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
self.hp = hp
self.attack = attack
self.defense = defense
self.max_hp = self.hp
def cure(self): # 治疗
???
print(self.name+"使用了治疗,血量增加:", 60,",目前的血量为:",self.hp)
def combat(self, enemy): # 普通攻击
info1 = self.name+"对"+enemy.name+"发起进攻,"
info2 = "造成"+str(self.attack)+"点伤害,"
enemy.hp -= self.attack
# self.speed = speed
# self.SA = SA
# self.SD = SD
# print('玩家您好,您选择的宝可梦是'+str(self.name))
# print('宝可梦的血量值为'+str(self.hp))
# print('宝可梦的攻击力为'+str(self.attack))
# print('宝可梦的防御值为'+str(self.defense))
# print('-----------------------------------------------------------')
def combat(self,enemy):
info1 = self.name + '对' +enemy.name + '发动了抓击!'
info2 = enemy.name + '收到了' + str(self.attack*0.25) + '点伤害!'+'防御减免'+ str(enemy.defense*0.2)+'点伤害。'
enemy.hp = enemy.hp - self.attack*0.25 + enemy.defense*0.2
if enemy.hp > 0:
info3 = enemy.name+"还剩下"+str(enemy.hp)+"血量"
info = info1+info2+info3
info3 = enemy.name+'剩余'+str(enemy.hp)+'血量!'
info = info1 + info2 + info3
print(info)
else:
info3 = enemy.name+"阵亡,游戏结束"
info = info1+info2+info3
print(info)
exit()
info3 = enemy.name+'的hp不足,进入濒死状态.'+self.name+'胜利'
print(info3)
def cure(self):
self.hp=self.hp+self.hp*0.3
if self.hp > self.max_hp:
self.hp = self.max_hp
print(self.name + '使用了hp药水!hp增加了'+str(self.hp*0.3)+'点,目前的血量为:'+str(self.hp))
class Player(Pokemon):
def __init__(self,name,hp,attack,defense,Pokemon_type):
super().__init__(name,hp,attack,defense)
self.hp = 45
self.attack = 49
self.defense = 49
self.Pokemon_type = Pokemon_type
print('玩家您好,您选择的宝可梦是'+str(self.name)+'.宝可梦属性为'+self.Pokemon_type)
print('宝可梦的血量值为'+str(self.hp))
print('宝可梦的攻击力为'+str(self.attack))
print('宝可梦的防御值为'+str(self.defense))
print('-'*30)
print(' 战斗开始')
def cure(self):
blood=self.hp+random.randint(10,16)
self.hp = self.hp + blood
if self.hp > self.max_hp:
self.hp = self.max_hp
print(self.name + '使用了hp药水!hp增加了'+blood+'点,目前的血量为:'+str(self.hp))
a = Pokemon('妙蛙种子',45,49,49)
b = Pokemon('小火龙',39,52,43)
c = Pokemon('杰尼龟',44,48,65)
miaowazhongzi = Player('妙蛙种子',45,49,49,'草')
shunxu = a
while True:
print('-'*30)
print(a.name+'hp'+str(a.hp)+b.name+'hp'+str(b.hp))
choice = input('请选择释放技能(1 抓击/2 hp药水)')
if choice == 'q':
print('战斗结束')
break
elif choice == '1':
a.combat(b)
elif choice == '2':
a.cure()
else:
print('请重新输入')
continue
status = random.randint(1,3)
if status == 1:
b.combat(a)
else:
b.cure()
# a = Pokemon('妙蛙种子',45,49,49,45,65,65,'寄生种子')
# b = Pokemon('小火龙',39,52,43,65,60,50,'火花')
# c = Pokemon('杰尼龟',44,48,65,50,64,43,'水沫')
# a.upgrade()
# b.upgrade()
# c.upgrade()
# def upgrade(self):
# self.level = self.level+1
# self.hp = self.hp+self.hp*0.3
# self.attack = self.attack+self.attack*0.2
# self.defense = self.defense+self.defense*0.2
# self.speed = self.speed+self.speed*0.2
# self.SA = self.SA+self.SA*0.3
# self.SD = self.SD+self.SD*0.3
class Player(Hero):
def __init__(self,hero_type,name):
super().__init__(name)
self.hp = 200
self.attack = 50
self.max_hp = self.hp
self.hero_type = hero_type
print("角色"+self.name+"创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:",self.level,self.hp,self.attack)
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
houyi.combat(yase)
yase.combat(houyi)
houyi.cure()
yase.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