def generate_array_detail(worldboss, user): """生成阵容详情返回 """ teams = [] for array_id in worldboss.get_arrays_id(): array = data_loader.WorldBossArrayBasicInfo_dict[array_id] #buff和tech是针对整个阵容生效的 buffs_id = array.buffIds techs_id = array.techIds heroes = [] for i in range(len(array.heroIds)): basic_id = array.heroIds[i] star = array.heroStars[i] equipments_id = [] equipments_id.append(array.heroEquipmentIds[i * 3]) equipments_id.append(array.heroEquipmentIds[i * 3 + 1]) equipments_id.append(array.heroEquipmentIds[i * 3 + 2]) evolution_level = array.heroEvolutionLevels[i] soldier_basic_id = array.soldierBasicIds[i] soldier_level = array.soldierLevels[i] soldier = SoldierInfo.create(user.id, soldier_basic_id, soldier_level) hero = HeroInfo.create_special(user.id, user.level, basic_id, user.level, star, soldier, [], techs_id, equipments_id, buffs_id, False, evolution_level, False) heroes.append(hero) teams.append(heroes) return teams
def _mock_hero(self, basic_id, star, level): USER_ID = 0 USER_LEVEL = int( float(data_loader.OtherBasicInfo_dict["MaxMonarchLevel"].value)) hero_id = HeroInfo.generate_id(USER_ID, basic_id) soldier_basic_id = HeroInfo.get_default_soldier_basic_id(basic_id) soldier = SoldierInfo.create(USER_ID, soldier_basic_id) hero = HeroInfo.create_special(USER_ID, USER_LEVEL, basic_id, level, star, soldier, [], technology_basic_ids=[]) return hero
def _default_generate_array_detail(dungeon, battle_level, user, detail_type): """默认生成阵容方法""" if battle_level == 0: level = dungeon.level(user.level) else: battle_id = "%d_%d" % (dungeon.basic_id, battle_level) level = data_loader.ExpandDungeonBattleBasicInfo_dict[battle_id].enemyLevel array_id = "%d_%d" % (dungeon.basic_id, level) if detail_type == 'enemy': array = data_loader.ExpandDungeonEnemyBasicInfo_dict[array_id] else: array = data_loader.ExpandDungeonOwnBasicInfo_dict[array_id] buffs_id = array.buffIds techs_id = array.techIds heroes = [] for i in range(len(array.heroIds)): basic_id = array.heroIds[i] hero_level = array.heroLevels[i] star = array.heroStarLevels[i] equipments_id = array.heroEquipmentIds[i*3 : i*3 + 3] evolution_level = array.heroEvolutionLevels[i] herostars_id = array.heroHeroStars[i*6 : i*6 + 6] soldier_basic_id = array.soldierBasicIds[i] soldier_level = array.soldierLevels[i] soldier = SoldierInfo.create(user.id, soldier_basic_id, soldier_level) if basic_id == 0: heroes.append(None) else: hero = HeroInfo.create_special(user.id, user.level, basic_id, hero_level, star, soldier, [], techs_id, equipments_id, buffs_id, False, evolution_level, False, herostars_id) heroes.append(hero) return heroes
def _calc_add_hero(self, data, req, timer): hero_basic_id = req.hero.basic_id soldier_basic_id = HeroInfo.get_default_soldier_basic_id(hero_basic_id) soldier_id = SoldierInfo.generate_id(data.id, soldier_basic_id) soldier = data.soldier_list.get(soldier_id, True) skill_ids = [] skill_ids.append(req.hero.first_skill_id) skill_ids.append(req.hero.second_skill_id) skill_ids.append(req.hero.third_skill_id) skill_ids.append(req.hero.fourth_skill_id) user = data.user.get(True) #影响英雄所带兵种战力的科技 battle_technology_basic_id = technology_module.get_battle_technology_for_soldier( data.technology_list.get_all(True), soldier_basic_id) equipments_id = [] if (req.hero.HasField("equipment_weapon_id") and req.hero.HasField("equipment_armor_id") and req.hero.HasField("equipment_treasure_id")): equipments_id.append(req.hero.equipment_weapon_id) equipments_id.append(req.hero.equipment_armor_id) equipments_id.append(req.hero.equipment_treasure_id) stone_weapon = [] if len(req.hero.stone_weapon) == 4: stone_weapon.append(req.hero.stone_weapon[0]) stone_weapon.append(req.hero.stone_weapon[1]) stone_weapon.append(req.hero.stone_weapon[2]) stone_weapon.append(req.hero.stone_weapon[3]) stone_armor = [] if len(req.hero.stone_armor) == 4: stone_armor.append(req.hero.stone_armor[0]) stone_armor.append(req.hero.stone_armor[1]) stone_armor.append(req.hero.stone_armor[2]) stone_armor.append(req.hero.stone_armor[3]) stone_treasure = [] if len(req.hero.stone_treasure) == 4: stone_treasure.append(req.hero.stone_treasure[0]) stone_treasure.append(req.hero.stone_treasure[1]) stone_treasure.append(req.hero.stone_treasure[2]) stone_treasure.append(req.hero.stone_treasure[3]) evolution_level = 1 if req.hero.HasField("evolution_level"): evolution_level = req.hero.evolution_level hero = HeroInfo.create_special(user.id, user.level, hero_basic_id, req.hero.level, req.hero.star_level, soldier, skill_ids, battle_technology_basic_id, equipments_id, [], True, evolution_level, stones_weapon_id=stone_weapon, stones_armor_id=stone_armor, stones_treasure_id=stone_treasure) if hero is None: raise Exception("Create hero failed") data.hero_list.add(hero) hero_business.post_gain_hero(data, hero) return DataBase().commit(data)