import random
class God_mountain: # 类名 神天兵
def __init__(self,role,hp,spell,mp,skill,skill1,skill2):
self.role = role
self.hp = hp
self.spell = spell
self.mp = mp
self.skill = skill
self.skill1 = skill1
self.skill2 = skill2
def spell_attacks1(self, inferno): # 法师攻击 技能1
if self.hp > 0:
crit = random.randint(50,self.spell) # spell 法术攻击 100
n = random.randint(0,1)
if n == 0:
inferno.hp -= self.spell
print('%s使出了%s攻击了%s'%(self.role,self.skill,inferno.role))
else:
inferno.hp -= (self.spell + crit)
print('%s使出了%s攻击了%s引发了法术暴击' % (self.role, self.skill, inferno.role))
def spell_attacks2(self, inferno): # 技能2
if self.hp > 0:
crit = random.randint(50,self.spell)
n = random.randint(0,1)
if n == 0:
inferno.hp -= self.spell
print('%s使出了%s攻击了%s'%(self.role,self.skill1,inferno.role))
else:
inferno.hp -= (self.spell + crit)
print('%s使出了%s攻击了%s引发了法术暴击' % (self.role, self.skill1, inferno.role))
def spell_attacks3(self, inferno): # 技能3
if self.hp > 0:
crit = random.randint(50,self.spell)
n = random.randint(0,1)
if n == 0:
inferno.hp -= self.spell
print('%s使出了%s攻击了%s'%(self.role,self.skill2,inferno.role))
else:
inferno.hp -= (self.spell + crit)
print('%s使出了%s攻击了%s引发了法术暴击' % (self.role, self.skill2, inferno.role))
class Mix_monty: # 类名 混天魔
def __init__(self, role,hp,attack,mp,skill):
self.role = role
self.hp = hp
self.attack = attack
self.mp = mp
self.skill = skill
def physical_attacks(self,Wizards): # Wizards 仙族
if self.hp > 0:
crit = random.randint(50, self.attack)
n = random.randint(0,1)
if n == 0:
Wizards.hp -= self.attack
print('%s仰天长啸攻击了%s'%(self.role,Wizards.role))
else:
Wizards.hp -= (self.attack + crit)
print('%s仰天长啸使出了%s攻击了%s引发了雷霆暴击'%(self.role,self.skill,Wizards.role))
deity = God_mountain('神天兵',1000,100,2000,'袖里乾坤','天诛地灭','九龙冰封') #仙族 神天兵的信息
demon = Mix_monty('混天魔',1000,100,1000,'乾坤一棍') # 魔族 混天魔的信息
import time #引用倒计时
print('\r准备决斗',end='')
time.sleep(0.5)
print('\r3',end='')
time.sleep(0.5)
print('\r2',end='')
time.sleep(0.5)
print('\r1',end='')
time.sleep(0.5)
print('\r开始',end='')
time.sleep(0.5)
print('\r ',end='')
def func():
demon.physical_attacks(deity)
if deity.hp < 0:
deity.hp = 0
print('神天兵剩余HP', deity.hp)
print('----------------------------')
time.sleep(0.5)
if random.randint(0,1):
func()
while 1:
if deity.hp > 0 and demon.hp > 0:
random.choice([deity.spell_attacks1,
deity.spell_attacks2,
deity.spell_attacks3])(demon)
if demon.hp < 0:
demon.hp = 0
print('混天魔剩余HP',demon.hp)
print('----------------------------')
time.sleep(0.5)
func()
if demon.hp <= 0:
demon.hp = 0
print('\n%s阵亡!仰天大吼一声,生而为民,死亦何憾!'%(demon.role))
break
if deity.hp <= 0:
deity.hp = 0
print('\n%s阵亡,发出神灵叹息,来生再战'%(deity.role))
break