def hp_min_attack(value, attacker, target_units): target_units_lst = target_units.values() target_units_lst = sorted(target_units_lst, key=lambda unit: unit.hp_percent) logger_cal.debug("hp百分比最少:") logger_cal.debug("%s" % target_units_lst) return target_units_lst[:value]
def perform_round(self): """ perform mock battle, logger_cal.debug(battle process.) """ logger_cal.debug("回合开始前,执行buff") self.perform_buff(self._red_units) self.perform_buff(self._blue_units) for i in range(1, 7): red_unit = self._red_units.get(i) self.handle_mock_special_skill(self._red_best_skill) if red_unit: logger_cal.debug(("red_%d" % i) + "-" * 20 + "我方攻击" + "-" * 20) self.perform_one_skill(self._red_units, self._blue_units, red_unit.skill) self._red_best_skill.add_mp() self._blue_best_skill.add_mp() logger_cal.debug(" ") self.handle_mock_special_skill(self._blue_best_skill) blue_unit = self._blue_units.get(i) if blue_unit: logger_cal.debug(("blue_%d" % i) + "-" * 20 + "敌方攻击" + "-" * 20) self.perform_one_skill(self._blue_units, self._red_units, blue_unit.skill) self._red_best_skill.add_mp() self._blue_best_skill.add_mp() logger_cal.debug(" ") self.remove_buff(self._red_units) self.remove_buff(self._blue_units) return self._red_units, self._blue_units
def perform_round(self): """ perform mock battle, logger_cal.debug(battle process.) """ logger_cal.debug("回合开始前,执行buff") self.perform_buff(self._red_units) self.perform_buff(self._blue_units) for i in range(1, 7): red_unit = self._red_units.get(i) self.handle_mock_special_skill(self._red_best_skill) if red_unit: logger_cal.debug(("red_%d" % i) + "-" * 20 + "我方攻击" + "-" * 20) self.perform_one_skill(self._red_units, self._blue_units, red_unit.skill) self._red_best_skill.add_mp() self._blue_best_skill.add_mp() logger_cal.debug(" ") self.handle_mock_special_skill(self._blue_best_skill) blue_unit = self._blue_units.get(i) if blue_unit: logger_cal.debug(("blue_%d" % i) + "-" * 20 + "敌方攻击" + "-" * 20) self.perform_one_skill(self._blue_units, self._red_units, blue_unit.skill) self._red_best_skill.add_mp() self._blue_best_skill.add_mp() logger_cal.debug(" ") self.remove_buff(self._red_units) self.remove_buff(self._blue_units) return self._red_units, self._blue_units
def perform_buff(self, owner): if not self._target_side: return effect_id = self._skill_buff_info.effectId if effect_id in [1, 2, 3, 8, 9, 26]: logger_cal.debug("执行buff %s" % self._skill_buff_info.id) self._continue_num -= 1 if effect_id in [1, 2]: block_or_not = False if self._skill_buff_info.skill_key == 1: block_or_not = self._is_block else: block_or_not = check_block(self._attacker, owner, self._skill_buff_info) execute_demage(self._attacker, owner, self._skill_buff_info, block_or_not) elif effect_id in [3]: execute_pure_demage(self._attacker, owner, self._skill_buff_info) elif effect_id in [8, 9]: execute_mp(owner, self._skill_buff_info) elif effect_id in [26]: execute_treat(self._attacker, owner, self._skill_buff_info) if owner.hp<=0 and owner.slot_no in self._target_side: logger.debug(owner.hp) logger.debug(self._target_side) logger.debug(owner.slot_no) del self._target_side[owner.slot_no] logger_cal.debug("%s死了。" % owner.unit_no)
def perform_buff(self, owner): if not self._target_side: return effect_id = self._skill_buff_info.effectId if effect_id in [1, 2, 3, 8, 9, 26]: logger_cal.debug("执行buff %s" % self._skill_buff_info.id) self._continue_num -= 1 if effect_id in [1, 2]: block_or_not = False if self._skill_buff_info.skill_key == 1: block_or_not = self._is_block else: block_or_not = check_block(self._attacker, owner, self._skill_buff_info) execute_demage(self._attacker, owner, self._skill_buff_info, block_or_not) elif effect_id in [3]: execute_pure_demage(self._attacker, owner, self._skill_buff_info) elif effect_id in [8, 9]: execute_mp(owner, self._skill_buff_info) elif effect_id in [26]: execute_treat(self._attacker, owner, self._skill_buff_info) if owner.hp <= 0 and owner.slot_no in self._target_side: logger.debug(owner.hp) logger.debug(self._target_side) logger.debug(owner.slot_no) del self._target_side[owner.slot_no] logger_cal.debug("%s死了。" % owner.unit_no)
def process(self): """docstring for process""" battle_round = BattleRound() if not battle_round.init_round(self._red_units, self._red_best_skill, self._blue_units, self._blue_best_skill, self._firent_skill): return True logger_cal.debug("开始战斗...") #return True, 0 blue_units = None for i in range(game_configs.base_config.get("max_times_fight")): i = i + 1 logger_cal.debug("第%d回合......" % i) red_units, blue_units = battle_round.perform_round() result = battle_round.result if result == 0: continue if result == 1: logger_cal.debug("我赢了。") return True, 0 if result == -1: logger_cal.debug("我输了。") return False, blue_units.get(5).hp logger_cal.debug("我输了。") return False, blue_units.get(5).hp
def mp_max_attack(value, attacker, target_units): target_units_lst = target_units.values() target_units_lst = sorted(target_units_lst, key=lambda unit: unit.mp, reverse=True) logger_cal.debug("mp最多:") logger_cal.debug("%s" % target_units_lst) return target_units_lst[:value]
def execute_mp(target, skill_buff_info): """ mp: 8,9 """ if skill_buff_info.effectId == 8: logger_cal.debug("mp 增加%s" % skill_buff_info.valueEffect) target.mp += skill_buff_info.valueEffect elif skill_buff_info.effectId == 9: target.mp -= skill_buff_info.valueEffect logger_cal.debug("mp 减少%s" % skill_buff_info.valueEffect)
def execute_mp(target, skill_buff_info): """ mp: 8,9 """ if skill_buff_info.effectId == 8: logger_cal.debug("mp 增加%s" % skill_buff_info.valueEffect) target.mp += skill_buff_info.valueEffect elif skill_buff_info.effectId == 9: target.mp -= skill_buff_info.valueEffect logger_cal.debug("mp 减少%s" % skill_buff_info.valueEffect)
def remove(self): """docstring for remove""" for k, value in self._buffs.items(): temp = [] for buff in value: buff.continue_num -= 1 if buff.continue_num > 0: temp.append(buff) else: logger_cal.debug("去除buff %s", buff.skill_buff_info.id) self._buffs[k] = temp
def remove(self): """docstring for remove""" for k, value in self._buffs.items(): temp = [] for buff in value: buff.continue_num -= 1 if buff.continue_num > 0: temp.append(buff) else: logger_cal.debug("去除buff %s", buff.skill_buff_info.id) self._buffs[k] = temp
def init_round(self, red_units, red_best_skill, blue_units, blue_best_skill, friend_skill): self._red_units = copy.deepcopy(red_units) # copy.deepcopy(red_units) self._red_best_skill = red_best_skill self._blue_units = copy.deepcopy(blue_units) self._blue_best_skill = blue_best_skill self._friend_skill = friend_skill if len(self._blue_units) == 0: logger_cal.debug("敌方人数为0!") return False self.enter_battle() return True
def perform_best_skill(self, army, enemy, skill): """执行技能:无双""" if not skill.is_full(): return for skill_buff_info in skill.skill_buffs: target_units, target_side = find_target_units(None, army, enemy, skill_buff_info, None) demage_hp = skill.player_level * skill_buff_info.levelEffectValue for target_unit in target_units: target_unit.hp -= demage_hp logger_cal.debug("无双的伤害值为 %s" % demage_hp) skill.reset_mp()
def set_mp(self, is_mp_skill): """ 攻击结束后,修改怒气值。 """ if not is_mp_skill: self._mp += self._mp_step logger_cal.debug("正常添加 mp:%s" % self._mp_step) if self._mp > self._mp_max: self._mp = self._mp_max else: self._mp = self._owner._mp_base logger_cal.debug("重置 mp: %s" % self._mp)
def set_mp(self, is_mp_skill): """ 攻击结束后,修改怒气值。 """ if not is_mp_skill: self._mp += self._mp_step logger_cal.debug("正常添加 mp:%s" % self._mp_step) if self._mp > self._mp_max: self._mp = self._mp_max else: self._mp = self._owner._mp_base logger_cal.debug("重置 mp: %s" % self._mp)
def perform_best_skill(self, army, enemy, skill): """执行技能:无双""" if not skill.is_full(): return for skill_buff_info in skill.skill_buffs: target_units, target_side = find_target_units( None, army, enemy, skill_buff_info, None) demage_hp = skill.player_level * skill_buff_info.levelEffectValue for target_unit in target_units: target_unit.hp -= demage_hp logger_cal.debug("无双的伤害值为 %s" % demage_hp) skill.reset_mp()
def init_round(self, red_units, red_best_skill, blue_units, blue_best_skill, friend_skill): self._red_units = copy.deepcopy(red_units) # copy.deepcopy(red_units) self._red_best_skill = red_best_skill self._blue_units = copy.deepcopy(blue_units) self._blue_best_skill = blue_best_skill self._friend_skill = friend_skill if len(self._blue_units) == 0: logger_cal.debug("敌方人数为0!") return False self.enter_battle() return True
def process(self): """docstring for process""" battle_round = BattleRound() battle_round.init_round(self._red_units, self._red_best_skill, self._blue_groups.pop(0), friend_skill=self._friend_skill) while True: battle_round.perform_round() result = battle_round.result if result == 0: continue if result == 1 and self.blue_groups: battle_round.init_round(self._red_units, self._red_best_skill, self._blue_groups.pop(0), friend_skill=self._friend_skill) continue if result == 1: logger_cal.debug("I finally win the battle.") break if result == -1: logger_cal.debug("I finally lose the battle.") break
def add(self, buff): """ add a buff. """ if not check_trigger(buff.skill_buff_info): return logger_cal.debug("添加buff: %s" % buff.skill_buff_info.id) effect_id = buff.skill_buff_info.effectId if effect_id not in self._buffs: self._buffs[effect_id] = [] if buff.skill_buff_info.overlay: self._add_buff(buff, effect_id) elif not buff.skill_buff_info.overlay: if self._buffs[effect_id]: temp = self._buffs[effect_id][0] if temp.skill_buff_info.replace <= buff.skill_buff_info.replace: self._add_buff(buff, effect_id, True) else: self._add_buff(buff, effect_id)
def add(self, buff): """ add a buff. """ if not check_trigger(buff.skill_buff_info): return logger_cal.debug("添加buff: %s" % buff.skill_buff_info.id) effect_id = buff.skill_buff_info.effectId if effect_id not in self._buffs: self._buffs[effect_id] = [] if buff.skill_buff_info.overlay: self._add_buff(buff, effect_id) elif not buff.skill_buff_info.overlay: if self._buffs[effect_id]: temp = self._buffs[effect_id][0] if temp.skill_buff_info.replace <= buff.skill_buff_info.replace: self._add_buff(buff, effect_id, True) else: self._add_buff(buff, effect_id)
def enter_battle(self): """ 在战斗开始前,进行触发类别为2的突破技能buff """ logger_cal.debug(" 进入战场,添加的buff...") for temp in self._red_units.values(): for skill_buff_info in temp.skill.begin_skill_buffs(): target_units, target_side = find_target_units( temp, self._red_units, self._blue_units, skill_buff_info) self.handle_skill_buff(temp, target_side, target_units, skill_buff_info) if DEBUG: target_nos = [] for temp in target_units: target_nos.append(temp.slot_no) logger_cal.debug(" 作用目标: %s" % (target_nos)) for temp in self._blue_units.values(): for skill_buff_info in temp.skill.begin_skill_buffs(): target_units, target_side = find_target_units( temp, self._blue_units, self._red_units, skill_buff_info) self.handle_skill_buff(temp, target_side, target_units, skill_buff_info) if DEBUG: target_nos = [] for temp in target_units: target_nos.append(temp.slot_no) logger_cal.debug(" 作用目标: %s" % (target_nos))
def process(self): """docstring for process""" battle_round = BattleRound() battle_round.init_round(self._red_units, self._red_best_skill, self._blue_groups.pop(0), friend_skill=self._friend_skill) while True: battle_round.perform_round() result = battle_round.result if result == 0: continue if result == 1 and self.blue_groups: battle_round.init_round(self._red_units, self._red_best_skill, self._blue_groups.pop(0), friend_skill=self._friend_skill) continue if result == 1: logger_cal.debug("I finally win the battle.") break if result == -1: logger_cal.debug("I finally lose the battle.") break
def handle_skill_buff(self, attacker, target_side, target_units, skill_buff_info): """ 根据作用位置找到攻击目标,然后执行技能或者添加buff """ logger_cal.debug("-" * 80) for target_unit in target_units: buff = Buff(target_side, attacker, skill_buff_info) target_unit.buff_manager.add(buff) logger_cal.debug(" 技能或buffID:%s, 受击后的状态:" % (skill_buff_info.id)) for temp in target_units: if temp.hp > 0: logger_cal.debug(" %s" % temp) logger_cal.debug("-" * 80)
def process(self): """docstring for process""" battle_round = BattleRound() if not battle_round.init_round(self._red_units, self._red_best_skill, self._blue_units, self._blue_best_skill, self._firent_skill): return True logger_cal.debug("开始战斗...") #return True, 0 blue_units = None for i in range(game_configs.base_config.get("max_times_fight")): i = i + 1 logger_cal.debug("第%d回合......" % i) red_units, blue_units = battle_round.perform_round() result = battle_round.result if result == 0: continue if result == 1: logger_cal.debug("我赢了。") return True, 0 if result == -1: logger_cal.debug("我输了。") return False, blue_units.get(5).hp logger_cal.debug("我输了。") return False, blue_units.get(5).hp
def handle_skill_buff(self, attacker, target_side, target_units, skill_buff_info): """ 根据作用位置找到攻击目标,然后执行技能或者添加buff """ logger_cal.debug("-" * 80) for target_unit in target_units: buff = Buff(target_side, attacker, skill_buff_info) target_unit.buff_manager.add(buff) logger_cal.debug(" 技能或buffID:%s, 受击后的状态:" % (skill_buff_info.id)) for temp in target_units: if temp.hp > 0: logger_cal.debug(" %s" % temp) logger_cal.debug("-" * 80)
def enter_battle(self): """ 在战斗开始前,进行触发类别为2的突破技能buff """ logger_cal.debug(" 进入战场,添加的buff...") for temp in self._red_units.values(): for skill_buff_info in temp.skill.begin_skill_buffs(): target_units, target_side = find_target_units(temp, self._red_units, self._blue_units, skill_buff_info) self.handle_skill_buff(temp, target_side, target_units, skill_buff_info) if DEBUG: target_nos = [] for temp in target_units: target_nos.append(temp.slot_no) logger_cal.debug(" 作用目标: %s" % (target_nos)) for temp in self._blue_units.values(): for skill_buff_info in temp.skill.begin_skill_buffs(): target_units, target_side = find_target_units(temp, self._blue_units, self._red_units, skill_buff_info) self.handle_skill_buff(temp, target_side, target_units, skill_buff_info) if DEBUG: target_nos = [] for temp in target_units: target_nos.append(temp.slot_no) logger_cal.debug(" 作用目标: %s" % (target_nos))
def __init__(self, red_units, red_best_skill_no, red_player_level, blue_units, blue_best_skill_no, blue_player_level): self._red_units = red_units self._blue_units = blue_units self._red_best_skill = BestSkill( red_best_skill_no, red_player_level) if red_best_skill_no else BestSkillNone() self._blue_best_skill = BestSkill( blue_best_skill_no, blue_player_level) if blue_best_skill_no else BestSkillNone() self._firent_skill = FriendSkillNone() logger_cal.debug("我方阵容:") for k, v in self._red_units.items(): logger_cal.debug("%d %s" % (k, v)) logger_cal.debug("-" * 80) logger_cal.debug("敌方阵容:") for k, v in self._blue_units.items(): logger_cal.debug("%d %s" % (k, v)) logger_cal.debug("-" * 80)
def __init__(self, red_units, red_player_level, red_best_skill_no, blue_units, debuff_no=0): self._red_units = red_units self._blue_units = blue_units # add debuff skill_info = game_configs.skill_config.get(debuff_no) if skill_info: for k, v in blue_units.items(): for temp in skill_info.group: skill_buff_info = game_configs.skill_buff_config.get(temp) if not skill_buff_info: continue buff = Buff(blue_units, None, skill_buff_info) v.buff_manager.add(buff) self._red_best_skill = BestSkill(red_best_skill_no, red_player_level) if red_best_skill_no else BestSkillNone() self._blue_best_skill = BestSkillNone() self._firent_skill = FriendSkillNone() logger_cal.debug("我方阵容:") for k, v in self._red_units.items(): logger_cal.debug("%d %s" % (k, v)) logger_cal.debug("-" * 80) logger_cal.debug("敌方阵容:") for k, v in self._blue_units.items(): logger_cal.debug("%d %s" % (k, v)) logger_cal.debug("-" * 80)
def __init__(self, red_units, red_best_skill, red_player_level, blue_groups, blue_player_level, friend_skill): super(BattlePVEProcess, self).__init__() self._red_units = red_units self._blue_groups = blue_groups self._red_best_skill = red_best_skill self._friend_skill = friend_skill logger_cal.debug("我方阵容:") for k, v in self._red_units.items(): logger_cal.debug(k, v) logger_cal.debug("-" * 80) logger_cal.debug("敌方阵容:") for item in blue_groups: for k, v in item.items(): logger_cal.debug(k, v) logger_cal.debug('next group:') logger_cal.debug("-" * 80)
def mp_min_attack(value, attacker, target_units): target_units_lst = target_units.values() target_units_lst = sorted(target_units_lst, key=lambda unit: unit.mp) logger_cal.debug("mp最少:") logger_cal.debug("%s" % target_units_lst) return target_units_lst[:value]
def execute_demage(attacker, target, skill_buff_info, is_block): """ 执行技能[1,2] """ logger_cal.debug(" 攻方 no(%d), unit_no(%d), name(%s), hp(%f), mp(%f), buff(%s)" % (attacker.slot_no, attacker.unit_no, attacker.unit_name, attacker.hp, attacker.mp, attacker.buff_manager)) logger_cal.debug(" 守方 no(%d), unit_no(%d), name(%s), hp(%f), mp(%f), buff(%s)" % (target.slot_no, target.unit_no, target.unit_name, target.hp, target.mp, target.buff_manager)) is_cri = False # 是否暴击 if check_cri(attacker.cri, target.ductility): is_cri = True k1 = attacker.atk # 攻方总实际攻击力 k2 = 0 # 守方总物理或者魔法防御 if skill_buff_info.effectId == 1: k2 = target.physical_def elif skill_buff_info.effectId == 2: k2 = target.magic_def # 1.base_demage_value 基础伤害值 base_demage_vars = dict(atkArray=k1, def2=k2, heroLevel=attacker.level) base_demage_formula = game_configs.formula_config.get("baseDamage").get("formula") assert base_demage_formula!=None, "baseDamage formula can not be None!" base_demage_value = eval(base_demage_formula, base_demage_vars) # 2.cri_coeff 暴击伤害系数 cri_coeff_vars = dict(criCoeffArray1=attacker.cri_coeff, criDedCoeffArray2=target.cri_ded_coeff) cri_coeff_formula = game_configs.formula_config.get("criDamage").get("formula") assert cri_coeff_formula!=None, "criDamage formula can not be None!" cri_coeff = eval(cri_coeff_formula, cri_coeff_vars) # 3. levelDamage 等级压制系数 level_coeff_vars = dict(heroLevel1=attacker.level, heroLevel2=target.level) level_coeff_formula = game_configs.formula_config.get("levelDamage").get("formula") assert level_coeff_formula!=None, "levelDamage formula can not be None!" level_coeff = eval(level_coeff_formula, level_coeff_vars) # 4. floatDamage 等级压制系数 temp = game_configs.base_config.get("a6") # 伤害浮动调整参数 k1, k2 = temp[0], temp[1] # float_coeff_vars = dict(k1=k1, k2=k2, random=get_random_int(0, 99)) float_coeff_formula = game_configs.formula_config.get("floatDamage").get("formula") assert float_coeff_formula!=None, "levelDamage formula can not be None!" float_coeff = eval(float_coeff_formula, float_coeff_vars) # 5. allDamage total_demage_vars = dict(baseDamage=base_demage_value, isHit=True, criDamage=cri_coeff, isCri=is_cri, isBlock=is_block, levelDamage=level_coeff, floatDamage=float_coeff) total_demage_formula = game_configs.formula_config.get("allDamage").get("formula") assert total_demage_formula!=None, "allDamage formula can not be None!" total_demage = eval(total_demage_formula, total_demage_vars) # 总伤害值 all_vars = dict( skill_buff=skill_buff_info, allDamage=total_demage, valueEffect=skill_buff_info.valueEffect, levelEffectValue=skill_buff_info.levelEffectValue, heroLevel=attacker.level ) actual_demage_1 = actual_value("damage_1", all_vars) actual_demage_2 = actual_value("damage_2", all_vars) logger_cal.debug(" 技能ID(%d),暴击(%s),格挡(%s),基础伤害值(%s),暴击伤害系数(%s),等级压制系数(%s),伤害浮动系数(%s),总伤害值(%s),攻方实际伤害值(%s)" \ % (skill_buff_info.id, is_cri, is_block, base_demage_value, cri_coeff, level_coeff, float_coeff, total_demage, actual_demage_1)) target.hp = target.hp - actual_demage_1 - actual_demage_2
def perform_buff(self, units): for k, temp in units.items(): logger_cal.debug("武将: %s" % temp.unit_no) temp.buff_manager.perform_buff()
def execute_demage(attacker, target, skill_buff_info, is_block): """ 执行技能[1,2] """ logger_cal.debug( " 攻方 no(%d), unit_no(%d), name(%s), hp(%f), mp(%f), buff(%s)" % (attacker.slot_no, attacker.unit_no, attacker.unit_name, attacker.hp, attacker.mp, attacker.buff_manager)) logger_cal.debug( " 守方 no(%d), unit_no(%d), name(%s), hp(%f), mp(%f), buff(%s)" % (target.slot_no, target.unit_no, target.unit_name, target.hp, target.mp, target.buff_manager)) is_cri = False # 是否暴击 if check_cri(attacker.cri, target.ductility): is_cri = True k1 = attacker.atk # 攻方总实际攻击力 k2 = 0 # 守方总物理或者魔法防御 if skill_buff_info.effectId == 1: k2 = target.physical_def elif skill_buff_info.effectId == 2: k2 = target.magic_def # 1.base_demage_value 基础伤害值 base_demage_vars = dict(atkArray=k1, def2=k2, heroLevel=attacker.level) base_demage_formula = game_configs.formula_config.get("baseDamage").get( "formula") assert base_demage_formula != None, "baseDamage formula can not be None!" base_demage_value = eval(base_demage_formula, base_demage_vars) # 2.cri_coeff 暴击伤害系数 cri_coeff_vars = dict(criCoeffArray1=attacker.cri_coeff, criDedCoeffArray2=target.cri_ded_coeff) cri_coeff_formula = game_configs.formula_config.get("criDamage").get( "formula") assert cri_coeff_formula != None, "criDamage formula can not be None!" cri_coeff = eval(cri_coeff_formula, cri_coeff_vars) # 3. levelDamage 等级压制系数 level_coeff_vars = dict(heroLevel1=attacker.level, heroLevel2=target.level) level_coeff_formula = game_configs.formula_config.get("levelDamage").get( "formula") assert level_coeff_formula != None, "levelDamage formula can not be None!" level_coeff = eval(level_coeff_formula, level_coeff_vars) # 4. floatDamage 等级压制系数 temp = game_configs.base_config.get("a6") # 伤害浮动调整参数 k1, k2 = temp[0], temp[1] # float_coeff_vars = dict(k1=k1, k2=k2, random=get_random_int(0, 99)) float_coeff_formula = game_configs.formula_config.get("floatDamage").get( "formula") assert float_coeff_formula != None, "levelDamage formula can not be None!" float_coeff = eval(float_coeff_formula, float_coeff_vars) # 5. allDamage total_demage_vars = dict(baseDamage=base_demage_value, isHit=True, criDamage=cri_coeff, isCri=is_cri, isBlock=is_block, levelDamage=level_coeff, floatDamage=float_coeff) total_demage_formula = game_configs.formula_config.get("allDamage").get( "formula") assert total_demage_formula != None, "allDamage formula can not be None!" total_demage = eval(total_demage_formula, total_demage_vars) # 总伤害值 all_vars = dict(skill_buff=skill_buff_info, allDamage=total_demage, valueEffect=skill_buff_info.valueEffect, levelEffectValue=skill_buff_info.levelEffectValue, heroLevel=attacker.level) actual_demage_1 = actual_value("damage_1", all_vars) actual_demage_2 = actual_value("damage_2", all_vars) logger_cal.debug(" 技能ID(%d),暴击(%s),格挡(%s),基础伤害值(%s),暴击伤害系数(%s),等级压制系数(%s),伤害浮动系数(%s),总伤害值(%s),攻方实际伤害值(%s)" \ % (skill_buff_info.id, is_cri, is_block, base_demage_value, cri_coeff, level_coeff, float_coeff, total_demage, actual_demage_1)) target.hp = target.hp - actual_demage_1 - actual_demage_2
def mp_min_attack(value, attacker, target_units): target_units_lst = target_units.values() target_units_lst = sorted(target_units_lst, key=lambda unit: unit.mp) logger_cal.debug("mp最少:") logger_cal.debug("%s" % target_units_lst) return target_units_lst[:value]
def hp_min_attack(value, attacker, target_units): target_units_lst = target_units.values() target_units_lst = sorted(target_units_lst, key=lambda unit: unit.hp_percent) logger_cal.debug("hp百分比最少:") logger_cal.debug("%s" % target_units_lst) return target_units_lst[:value]
def __init__(self, red_units, red_player_level, red_best_skill_no, blue_units, debuff_no=0): self._red_units = red_units self._blue_units = blue_units # add debuff skill_info = game_configs.skill_config.get(debuff_no) if skill_info: for k, v in blue_units.items(): for temp in skill_info.group: skill_buff_info = game_configs.skill_buff_config.get(temp) if not skill_buff_info: continue buff = Buff(blue_units, None, skill_buff_info) v.buff_manager.add(buff) self._red_best_skill = BestSkill( red_best_skill_no, red_player_level) if red_best_skill_no else BestSkillNone() self._blue_best_skill = BestSkillNone() self._firent_skill = FriendSkillNone() logger_cal.debug("我方阵容:") for k, v in self._red_units.items(): logger_cal.debug("%d %s" % (k, v)) logger_cal.debug("-" * 80) logger_cal.debug("敌方阵容:") for k, v in self._blue_units.items(): logger_cal.debug("%d %s" % (k, v)) logger_cal.debug("-" * 80)
def mp_max_attack(value, attacker, target_units): target_units_lst = target_units.values() target_units_lst = sorted(target_units_lst, key=lambda unit: unit.mp, reverse=True) logger_cal.debug("mp最多:") logger_cal.debug("%s" % target_units_lst) return target_units_lst[:value]
def __init__(self, red_units, red_best_skill, red_player_level, blue_groups, blue_player_level, friend_skill): super(BattlePVEProcess, self).__init__() self._red_units = red_units self._blue_groups = blue_groups self._red_best_skill = red_best_skill self._friend_skill = friend_skill logger_cal.debug("我方阵容:") for k, v in self._red_units.items(): logger_cal.debug(k, v) logger_cal.debug("-" * 80) logger_cal.debug("敌方阵容:") for item in blue_groups: for k, v in item.items(): logger_cal.debug(k, v) logger_cal.debug('next group:') logger_cal.debug("-" * 80)
def perform_one_skill(self, army, enemy, skill): """执行技能:普通技能或者怒气技能""" attacker = skill.owner is_mp_skill = skill.is_mp_skill() logger_cal.debug("is_mp_skill %s" % is_mp_skill) logger_cal.debug(" 进行攻击: 攻击者位置(%d), 攻击者(%d), 主技能ID(%d), buff(%s)" % \ (attacker.slot_no, attacker.unit_no, skill.main_skill_buff.id, attacker.buff_manager)) if not attacker.buff_manager.is_dizzy(): logger_cal.debug(" 攻击者在buff中,无法攻击!") return main_target_units, main_target_side = find_target_units(attacker, army, enemy, skill.main_skill_buff) # 主技能作用目标 # 1.计算命中, 格挡 # 规则:主技能作用多个目标,只要有一个命中的,则判定命中 is_main_hit = False main_target_unit_infos = [] for target_unit in main_target_units: if check_hit(skill.main_skill_buff, attacker.hit, target_unit.dodge): is_main_hit = True block_or_not = check_block(attacker, target_unit, skill.main_skill_buff) main_target_unit_infos.append((target_unit, block_or_not)) logger_cal.debug(" 是否命中:%s" % is_main_hit) # 2.主技能释放前,触发的buff logger_cal.debug(" 1. 攻击前, 添加的buff") for skill_buff_info in skill.before_skill_buffs(is_main_hit): target_units, target_side = find_target_units(attacker, army, enemy, skill_buff_info, main_target_units) self.handle_skill_buff(attacker, target_side, target_units, skill_buff_info) # 3.触发攻击技能 logger_cal.debug(" 2. 攻击...") for skill_buff_info in skill.attack_skill_buffs(): if not is_main_hit and skill_buff_info.skill_key and skill_buff_info.effectId in (1, 2, 3): # 当攻击主技能没有命中,则退出 break if skill_buff_info.skill_key: self.handle_skill_buff(attacker, main_target_side, main_target_units, skill_buff_info) continue target_units, target_side = find_target_units(attacker, army, enemy, skill_buff_info, main_target_units) self.handle_skill_buff(attacker, target_side, target_units, skill_buff_info) # 4.主技能释放后,触发的buff logger_cal.debug(" 3. 攻击后的buff...") for skill_buff_info in skill.after_skill_buffs(is_main_hit): target_units, target_side = find_target_units(attacker, army, enemy, skill_buff_info, main_target_units) self.handle_skill_buff(attacker, target_side, target_units, skill_buff_info) # 在攻击技能触发完成后,处理mp skill.set_mp(is_mp_skill) # 5. 反击 for backer, is_block in main_target_unit_infos: for skill_buff_info in backer.skill.back_skill_buffs(is_main_hit, is_block): target_units, target_side = find_target_units(backer, army, enemy, skill_buff_info, main_target_units=None, target=attacker) target_nos = [] for temp in target_units: target_nos.append(temp.slot_no) logger_cal.debug(" 反击目标: %s" % (target_nos)) buff = Buff(target_side, attacker, skill_buff_info, is_block) target_unit.buff_manager.add(buff)
def __init__(self, red_units, red_best_skill_no, red_player_level, blue_units, blue_best_skill_no, blue_player_level): self._red_units = red_units self._blue_units = blue_units self._red_best_skill = BestSkill(red_best_skill_no, red_player_level) if red_best_skill_no else BestSkillNone() self._blue_best_skill = BestSkill(blue_best_skill_no, blue_player_level) if blue_best_skill_no else BestSkillNone() self._firent_skill = FriendSkillNone() logger_cal.debug("我方阵容:") for k, v in self._red_units.items(): logger_cal.debug("%d %s" % (k, v)) logger_cal.debug("-" * 80) logger_cal.debug("敌方阵容:") for k, v in self._blue_units.items(): logger_cal.debug("%d %s" % (k, v)) logger_cal.debug("-" * 80)
def perform_one_skill(self, army, enemy, skill): """执行技能:普通技能或者怒气技能""" attacker = skill.owner is_mp_skill = skill.is_mp_skill() logger_cal.debug("is_mp_skill %s" % is_mp_skill) logger_cal.debug(" 进行攻击: 攻击者位置(%d), 攻击者(%d), 主技能ID(%d), buff(%s)" % \ (attacker.slot_no, attacker.unit_no, skill.main_skill_buff.id, attacker.buff_manager)) if not attacker.buff_manager.is_dizzy(): logger_cal.debug(" 攻击者在buff中,无法攻击!") return main_target_units, main_target_side = find_target_units( attacker, army, enemy, skill.main_skill_buff) # 主技能作用目标 # 1.计算命中, 格挡 # 规则:主技能作用多个目标,只要有一个命中的,则判定命中 is_main_hit = False main_target_unit_infos = [] for target_unit in main_target_units: if check_hit(skill.main_skill_buff, attacker.hit, target_unit.dodge): is_main_hit = True block_or_not = check_block(attacker, target_unit, skill.main_skill_buff) main_target_unit_infos.append((target_unit, block_or_not)) logger_cal.debug(" 是否命中:%s" % is_main_hit) # 2.主技能释放前,触发的buff logger_cal.debug(" 1. 攻击前, 添加的buff") for skill_buff_info in skill.before_skill_buffs(is_main_hit): target_units, target_side = find_target_units( attacker, army, enemy, skill_buff_info, main_target_units) self.handle_skill_buff(attacker, target_side, target_units, skill_buff_info) # 3.触发攻击技能 logger_cal.debug(" 2. 攻击...") for skill_buff_info in skill.attack_skill_buffs(): if not is_main_hit and skill_buff_info.skill_key and skill_buff_info.effectId in ( 1, 2, 3): # 当攻击主技能没有命中,则退出 break if skill_buff_info.skill_key: self.handle_skill_buff(attacker, main_target_side, main_target_units, skill_buff_info) continue target_units, target_side = find_target_units( attacker, army, enemy, skill_buff_info, main_target_units) self.handle_skill_buff(attacker, target_side, target_units, skill_buff_info) # 4.主技能释放后,触发的buff logger_cal.debug(" 3. 攻击后的buff...") for skill_buff_info in skill.after_skill_buffs(is_main_hit): target_units, target_side = find_target_units( attacker, army, enemy, skill_buff_info, main_target_units) self.handle_skill_buff(attacker, target_side, target_units, skill_buff_info) # 在攻击技能触发完成后,处理mp skill.set_mp(is_mp_skill) # 5. 反击 for backer, is_block in main_target_unit_infos: for skill_buff_info in backer.skill.back_skill_buffs( is_main_hit, is_block): target_units, target_side = find_target_units( backer, army, enemy, skill_buff_info, main_target_units=None, target=attacker) target_nos = [] for temp in target_units: target_nos.append(temp.slot_no) logger_cal.debug(" 反击目标: %s" % (target_nos)) buff = Buff(target_side, attacker, skill_buff_info, is_block) target_unit.buff_manager.add(buff)
def perform_buff(self, units): for k, temp in units.items(): logger_cal.debug("武将: %s" % temp.unit_no) temp.buff_manager.perform_buff()