本帖最后由 达不六 于 2017-8-25 10:19 编辑 # -*- coding: utf-8 -*-
import time
star = time.clock()
def gen_skill(boss_skill):
skill = {"普通攻击":15, "致命一击":25, "斩杀":45, "攻击":10, "搏命一击":20}
nm_pg = boss_skill.count('普通攻击')
nm_zm = boss_skill.count('致命一击')
nm_zs = boss_skill.count('斩杀')
hurt = (nm_pg*15+nm_zm*25+nm_zs*45)/30 # 技能列表中每个回合的平均伤害
if 15 <= hurt <25 : # 对技能列表的难度分为两级
e = 4
elif 25 <= hurt <35:
e = 3
hp_boss = 100
hp_player = 100
buff = []
player = []
for r in range(len(boss_skill)):
b = boss_skill[r]
if buff:
hp_player = min(hp_player+buff.pop(0),100)
hp_boss = min(hp_boss+3,100)
if r == 0: # 第一回合
if b=='普通攻击' or '致命一击': # 如果boss的技能不是斩杀
player.append('搏命一击')
hp_player -= skill[b]+10
hp_boss -= 20
print 'boss:',b
print '玩家:','搏命击'
else: # 如果boss 的技能是斩杀
player.append('治疗')
hp_player = min(hp_player+30,100)
buff = [10,10]
hp_player -= 45
print 'boss:',b
print '玩家:','治疗一次'
else: # 第二回合以上
if b=='斩杀':
player.append('躲闪')
print 'boss:',b
print '玩家:','躲闪一次'
elif r % e == 0 and player[r-1] != '治疗': #每隔 e 回合治疗一次,如果上回合使用了治疗,则这个回合不用治疗
player.append('治疗')
hp_player = min(hp_player+30,100)
buff = [10,10]
hp_player -= skill[b]
print 'boss:',b
print '玩家:','治疗一次'
elif hp_player <=30 and player[r-1]!='治疗': # 当血量小于30 时且上回合没有使用治疗时,治疗
player.append('治疗')
hp_player = min(hp_player+30,100)
buff = [10,10]
hp_player -= skill[b]
print 'boss:',b
print '玩家:','治疗一次'
else: # 否则 玩家 使用 搏命一击
player.append('搏命一击')
hp_player -= skill[b]+10
hp_boss -= 20
print 'boss:',b
print '玩家:','搏命一击'
print('Round %d: Boss HP: %d, Player HP: %d' % \
(r+1, hp_boss, hp_player))
if hp_player <= 0:
return 'Player Lose! Round: %d' % (r+1),player
if hp_boss <= 0:
return 'Player Win! Round: %d' % (r+1),player
[b][b][b]
五个boss技能列表,击杀boss所用回合分别为10,11,20,13,20[/b][/b][/b] |