def query_1243(data, player): """ 查看矿点详细信息 """ request = mine_pb2.positionRequest() request.ParseFromString(data) response = mine_pb2.mineDetail() response.position = request.position detail_info = player.mine.detail_info(request.position) # print detail_info last_increase = detail_info.get('increase', 0) stype = detail_info['type'] mine_item = game_configs.mine_config[detail_info['mine_id']] limit = mine_item.outputLimited normal = detail_info['normal'] lucky = detail_info['lucky'] guard_time = detail_info.get('guard_time', 0) stage_id = detail_info.get('stage_id', 0) seek_help = detail_info.get('seek_help', 0) response.res.result = True mstatus = player.mine.mine_info(request.position) one_mine_info(player, mstatus, response.mine) response.limit = limit for sid, num in normal.items(): one_type = response.normal.add() one_type.stone_id = int(sid) one_type.stone_num = num for sid, num in lucky.items(): one_type = response.lucky.add() one_type.stone_id = int(sid) one_type.stone_num = num response.increase = int(last_increase) if stype == 2: response.stage_id = int(stage_id) response.seek_help = seek_help line_up_info(player, response.lineup) if stype == 1: response.accelerate_times = detail_info.get('accelerate_times', 0) _uid = detail_info['uid'] char_obj = tb_character_info.getObj(_uid) if char_obj.exists(): lineup = char_obj.hget('copy_slots') response.lineup.ParseFromString(lineup) mid = player.mine.mid(request.position) mine_item = game_configs.mine_config.get(mid) response.genUnit = mine_item.timeGroup1 / mine_item.outputGroup1 response.rate = mine_item.increase response.incrcost = mine_item.increasePrice response.guard_time = int(guard_time) player.mine.save_data() print response, '=========================aaa' return response.SerializePartialToString()
def save_data(self, prop_names=[]): props = { 'line_up_slots': dict([(slot_no, slot.dumps()) for slot_no, slot in self._line_up_slots.items()]), 'sub_slots': dict([(slot_no, sub_slot.dumps()) for slot_no, sub_slot in self._sub_slots.items()]), 'line_up_order': self._line_up_order, 'unpar_level': self._unpar_level, 'unpar_type': self._unpar_type, 'unpar_other_id': self._unpar_other_id, 'ever_have_heros': self._ever_have_heros, 'unpar_names': self._unpar_names, 'friend_fight_times': self._friend_fight_times, 'hight_power': self._hight_power, 'caption_pos': self._caption_pos, } if not prop_names or 'line_up_slots' in prop_names or 'sub_slots' in prop_names: power = self.combat_power props['attackPoint'] = power hook_task(self.owner, CONDITIONId.FIGHT_POWER, power) if ('copy_units' in prop_names) or (not prop_names): props['copy_units'] = self.owner.fight_cache_component.red_unit props['copy_slots'] = line_up_info(self.owner).SerializeToString() line_up_obj = tb_character_info.getObj(self.character_id) line_up_obj.hmset(props)
def new_data(self): __line_up_slots = dict([(slot_no, LineUpSlotComponent(self, slot_no).dumps()) for slot_no in self._line_up_slots.keys()]) __sub_slots = dict([(slot_no, LineUpSlotComponent(self, slot_no).dumps()) for slot_no in self._sub_slots.keys()]) data = dict(line_up_slots=__line_up_slots, sub_slots=__sub_slots, line_up_order=self._line_up_order, unpar_level=self._unpar_level, unpar_type=self._unpar_type, unpar_other_id=self._unpar_other_id, ever_have_heros=self._ever_have_heros, friend_fight_times=self._friend_fight_times, best_skill=0, attackPoint=0, hight_power=0, caption_pos=0, copy_units=self.owner.fight_cache_component.red_unit, copy_slots=line_up_info(self.owner).SerializeToString() ) return data
def refresh_rank_data(player, rank_id, skill, skill_level): red_units = cPickle.dumps(player.fight_cache_component.red_unit) slots = cPickle.dumps(line_up_info(player)) hero_nos = player.line_up_component.hero_nos best_skill = player.line_up_component.get_skill_id_by_unpar(skill) rank_data = dict(hero_ids=cPickle.dumps(hero_nos), level=player.level.level, nickname=player.base_info.base_name, best_skill=best_skill, unpar_skill=skill, unpar_skill_level=skill_level, ap=player.line_up_component.combat_power, character_id=player.base_info.id, units=red_units, slots=slots) prere = dict(id=rank_id) result = util.UpdateWithDict(PVP_TABLE_NAME, rank_data, prere) if not result: raise Exception('update pvp fail!! id:%s' % rank_id)
def new_data(self): __line_up_slots = dict([(slot_no, LineUpSlotComponent(self, slot_no).dumps()) for slot_no in self._line_up_slots.keys()]) __sub_slots = dict([(slot_no, LineUpSlotComponent(self, slot_no).dumps()) for slot_no in self._sub_slots.keys()]) data = dict(line_up_slots=__line_up_slots, sub_slots=__sub_slots, line_up_order=self._line_up_order, unpars=self._unpars, current_unpar=self._current_unpar, friend_fight_times=self._friend_fight_times, best_skill=0, attackPoint=0, hight_power=0, copy_units=self.owner.fight_cache_component.red_unit, copy_slots=line_up_info(self.owner).SerializeToString() ) return data
def new_data(self): __line_up_slots = dict([(slot_no, LineUpSlotComponent(self, slot_no).dumps()) for slot_no in self._line_up_slots.keys()]) __sub_slots = dict([(slot_no, LineUpSlotComponent(self, slot_no).dumps()) for slot_no in self._sub_slots.keys()]) data = dict(line_up_slots=__line_up_slots, sub_slots=__sub_slots, line_up_order=self._line_up_order, unpar_level=self._unpar_level, unpar_type=self._unpar_type, unpar_other_id=self._unpar_other_id, ever_have_heros=self._ever_have_heros, friend_fight_times=self._friend_fight_times, best_skill=0, attackPoint=0, hight_power=0, caption_pos=0, copy_units=self.owner.fight_cache_component.red_unit, copy_slots=line_up_info(self.owner).SerializeToString()) return data
def save_data(self, prop_names=[]): power = self.combat_power hook_task(self.owner, CONDITIONId.FIGHT_POWER, power) props = { 'line_up_slots': dict([(slot_no, slot.dumps()) for slot_no, slot in self._line_up_slots.items()]), 'sub_slots': dict([(slot_no, sub_slot.dumps()) for slot_no, sub_slot in self._sub_slots.items()]), 'line_up_order': self._line_up_order, 'unpars': self._unpars, 'current_unpar': self._current_unpar, 'friend_fight_times': self._friend_fight_times, 'attackPoint': power, 'hight_power': self._hight_power, 'best_skill': self.get_skill_id_by_unpar(self._current_unpar), } if ('copy_units' in prop_names) or (not prop_names): props['copy_units'] = self.owner.fight_cache_component.red_unit props['copy_slots'] = line_up_info(self.owner).SerializeToString() line_up_obj = tb_character_info.getObj(self.character_id) line_up_obj.hmset(props)
hero1.level = 1 hero1.break_level = 1 hero1.exp = 0 pvp_ranks = {} for rank in range(1, rank_length + 1): for k, v in game_configs.robot_born_config.items(): rank_period = v.get('period') if rank in range(rank_period[0] - 1, rank_period[1] + 1): level_period = v.get('level') level = random.randint(level_period[0], level_period[1]) hero_ids = init_line_up(player, v, level) red_units = player.fight_cache_component.red_unit print red_units red_units = cPickle.dumps(red_units) slots = cPickle.dumps(line_up_info(player)) rank_item = dict(nickname=nickname_set.pop(), character_id=1, level=level, id=rank, best_skill=0, unpar_skill=0, unpar_skill_level=0, hero_ids=cPickle.dumps(hero_ids), ap=player.line_up_component.combat_power, units=red_units, slots=slots) pvp_ranks[rank] = rank_item for _ in pvp_ranks.values():
if v.get('group') != 1: continue rank_period = v.get('period') if rank in range(rank_period[0] - 1, rank_period[1] + 1): level_period = v.get('level') level = random.randint(level_period[0], level_period[1]) hero_ids = init_line_up(player, v, level) # set player level to hero level for t_hero in player.hero_component.get_heros(): if t_hero.hero_no in hero_ids: t_hero.level = level hero_levels = player.line_up_component.hero_levels red_units = player.fight_cache_component.red_unit print red_units red_units = red_units slots = line_up_info(player).SerializeToString() ap = int(player.line_up_component.combat_power) rank_item = dict(nickname=nickname_set.pop(), character_id=rank, level=level, id=rank, hero_ids=hero_ids, hero_levels=hero_levels, attackPoint=ap, best_skill=0, unpar_skill=0, unpar_skill_level=0, copy_units=red_units, copy_slots=slots) print("hero_levels========", hero_levels) pvp_rank[rank] = rank_item break
if v.get('group') != 1: continue rank_period = v.get('period') if rank in range(rank_period[0] - 1, rank_period[1] + 1): level_period = v.get('level') level = random.randint(level_period[0], level_period[1]) hero_ids = init_line_up(player, v, level) # set player level to hero level for t_hero in player.hero_component.get_heros(): if t_hero.hero_no in hero_ids: t_hero.level = level hero_levels = player.line_up_component.hero_levels red_units = player.fight_cache_component.red_unit # print red_units red_units = red_units slots = line_up_info(player).SerializeToString() ap = int(player.line_up_component.combat_power) rank_item = dict(nickname=nickname_set.pop(), character_id=rank, level=level, id=rank, hero_ids=hero_ids, hero_levels=hero_levels, attackPoint=ap, best_skill=0, unpar_skill=0, unpar_skill_level=0, copy_units=red_units, copy_slots=slots) print("hero_levels========", hero_levels)
def pvb_fight_start_1705(pro_data, player): """开始战斗 """ logger.debug("fight start..") request = world_boss_pb2.PvbStartRequest() request.ParseFromString(pro_data) print request, "request" best_skill_id = request.unparalleled # 无双编号 line_up = request.lineup boss_id = request.boss_id boss = player.world_boss.get_boss(boss_id) base_config = boss.get_base_config() debuff_skill_no = boss.debuff_skill_no response = PvbFightResponse() res = response.res print("world_boss_line_up:", line_up) open_stage_id = game_configs.base_config.get('worldbossOpenStage') if player.stage_component.get_stage(open_stage_id).state != 1: response.res.result = False response.res.result_no = 837 return response.SerializeToString() if player.base_info.is_firstday_from_register(const.OPEN_FEATURE_WORLD_BOSS): response.res.result = False response.res.result_no = 150901 return response.SerializeToString() stage_id = boss.stage_id logger.debug("stage_id,%s" % stage_id) WORLD_BOSS = 6 stage_info = pve_process(stage_id, WORLD_BOSS, line_up, 0, player, best_skill_id) result = stage_info.get('result') res.result = result if stage_info.get('result_no'): res.result_no = stage_info.get('result_no') if not result: logger.info('进入关卡返回数据:%s', response) return response.SerializePartialToString(), stage_id red_units = stage_info.get('red_units') blue_units = stage_info.get('blue_units') blue_units = blue_units[0] blue_units[5].hp = remote_gate['world'].get_hp_left_remote(boss_id) logger.debug("blue_units===========%s" % blue_units[5].hp) logger.debug("--" * 40) if blue_units[5].hp <= 0: logger.debug("world boss already dead!") response.res.result = False response.res.result_no = 1705 return response.SerializePartialToString() # 根据鼓舞次数,增加伤害百分比 damage_rate = boss.encourage_coin_num * base_config.get("coin_inspire_atk", 0) + \ boss.encourage_gold_num * base_config.get("gold_inspire_atk", 0) # mock fight. player_info = {} player_info["player_id"] = player.base_info.id player_info["now_head"] = player.base_info.heads.now_head player_info["nickname"] = player.base_info.base_name player_info["level"] = player.base_info.level player_info["line_up_info"] = line_up_info(player).SerializePartialToString() str_red_units = cPickle.dumps(red_units) str_blue_units = cPickle.dumps(blue_units) logger.debug("--" * 40) print red_units print blue_units red_best_skill_no, red_best_skill_level = player.line_up_component.get_skill_info_by_unpar(best_skill_id) seed1, seed2 = get_seeds() #def pvb_fight_remote(str_red_units, red_best_skill, red_best_skill_level, str_blue_units, player_info, boss_id, seed1, seed2): result, demage_hp = remote_gate['world'].pvb_fight_remote(str_red_units, best_skill_id, red_best_skill_level, str_blue_units, player_info, boss_id, damage_rate, debuff_skill_no, seed1, seed2) if result == -1: logger.debug("world boss already gone!") response.res.result = False response.res.result_no = 1706 return response.SerializePartialToString() response.fight_result = result # 玩家信息更新 boss.fight_times += 1 boss.demages.append(demage_hp) boss.last_fight_time = get_current_timestamp() player.world_boss.save_data() logger.debug("fight end..") pvp_assemble_units(red_units, blue_units, response) response.red_best_skill= best_skill_id response.red_best_skill_level = red_best_skill_level response.debuff_skill_no = debuff_skill_no response.seed1 = seed1 response.seed2 = seed2 response.damage_rate = damage_rate if boss_id == 'world_boss': hook_task(player, CONDITIONId.PVBOSS_TIMES, 1) return response.SerializePartialToString()
hero1.level = 1 hero1.break_level = 1 hero1.exp = 0 pvp_ranks = {} for rank in range(1, rank_length+1): for k, v in game_configs.robot_born_config.items(): rank_period = v.get('period') if rank in range(rank_period[0] - 1, rank_period[1] + 1): level_period = v.get('level') level = random.randint(level_period[0], level_period[1]) hero_ids = init_line_up(player, v, level) red_units = player.fight_cache_component.red_unit print red_units red_units = cPickle.dumps(red_units) slots = cPickle.dumps(line_up_info(player)) rank_item = dict(nickname=nickname_set.pop(), character_id=1, level=level, id=rank, best_skill=0, unpar_skill=0, unpar_skill_level=0, hero_ids=cPickle.dumps(hero_ids), ap=player.line_up_component.combat_power, units=red_units, slots=slots) pvp_ranks[rank] = rank_item for _ in pvp_ranks.values():
def pvb_fight_start_1705(pro_data, player): """开始战斗 """ logger.debug("fight start..") request = stage_request_pb2.StageStartRequest() request.ParseFromString(pro_data) stage_id = request.stage_id # 关卡编号 unparalleled = request.unparalleled # 无双编号 logger.debug("unparalleled,%s" % unparalleled) line_up = {} # {hero_id:pos} for line in request.lineup: if not line.hero_id: continue line_up[line.hero_id] = line.pos stage_info = fight_start(stage_id, line_up, unparalleled, 0, player) result = stage_info.get('result') response = PvbFightResponse() res = response.res res.result = result if stage_info.get('result_no'): res.result_no = stage_info.get('result_no') if not result: logger.info('进入关卡返回数据:%s', response) return response.SerializePartialToString(), stage_id red_units = stage_info.get('red_units') blue_units = stage_info.get('blue_units') logger.debug("--" * 40) # 根据鼓舞次数,增加ATK百分比 atk_rate = player.world_boss.encourage_coin_num * base_config.get("worldbossInspireAtk", 0) + \ player.world_boss.encourage_gold_num * base_config.get("worldbossInspireAtkMoney", 0) for slot_no, red_unit in red_units.items(): red_unit.atk *= (1 + atk_rate) print red_units print blue_units for slot_no, red_unit in red_units.items(): red_add = response.red.add() assemble(red_add, red_unit) blue_units = blue_units[0] for no, blue_unit in blue_units.items(): blue_add = response.blue.add() assemble(blue_add, blue_unit) response.red_best_skill = unparalleled if unparalleled in player.line_up_component.unpars: response.red_best_skill_level = player.line_up_component.unpars[ unparalleled] # mock fight. player_info = {} player_info["player_id"] = player.base_info.id player_info["nickname"] = player.base_info.base_name player_info["level"] = player.level.level player_info["line_up_info"] = line_up_info( player).SerializePartialToString() str_red_units = cPickle.dumps(red_units) str_blue_units = cPickle.dumps(blue_units) logger.debug("--" * 40) print red_units print blue_units result = remote_gate['world'].pvb_fight_remote(str_red_units, unparalleled, str_blue_units, player_info) response.fight_result = result # 玩家信息更新 player.world_boss.fight_times += 1 player.world_boss.last_fight_time = get_current_timestamp() player.world_boss.save_data() print response logger.debug("fight end..") return response.SerializePartialToString()
def pvb_fight_start_1705(pro_data, player): """开始战斗 """ logger.debug("fight start..") request = world_boss_pb2.PvbStartRequest() request.ParseFromString(pro_data) best_skill_id = request.unparalleled # 无双编号 line_up = request.lineup boss_id = request.boss_id boss = player.world_boss.get_boss(boss_id) base_config = boss.get_base_config() debuff_skill_no = boss.debuff_skill_no response = PvbFightResponse() res = response.res if player.base_info.is_firstday_from_register( const.OPEN_FEATURE_WORLD_BOSS): response.res.result = False response.res.result_no = 150901 return response.SerializeToString() stage_id = boss.stage_id logger.debug("stage_id,%s" % stage_id) WORLD_BOSS = 7 stage_info = pve_process(stage_id, WORLD_BOSS, line_up, 0, player) result = stage_info.get('result') res.result = result if stage_info.get('result_no'): res.result_no = stage_info.get('result_no') if not result: logger.info('进入关卡返回数据:%s', response) return response.SerializePartialToString(), stage_id red_units = stage_info.get('red_units') blue_units = stage_info.get('blue_units') blue_units = blue_units[0] blue_units[5].hp = remote_gate['world'].get_hp_left_remote(boss_id) logger.debug("blue_units===========%s" % blue_units[5].hp) logger.debug("--" * 40) if blue_units[5].hp <= 0: logger.debug("world boss already dead!") response.res.result = False response.res.result_no = 1705 return response.SerializePartialToString() # 根据鼓舞次数,增加伤害百分比 damage_rate = boss.encourage_coin_num * base_config.get("coin_inspire_atk", 0) + \ boss.encourage_gold_num * base_config.get("gold_inspire_atk", 0) # mock fight. player_info = {} player_info["player_id"] = player.base_info.id player_info["vip_level"] = player.base_info.vip_level player_info["now_head"] = player.base_info.heads.now_head player_info["nickname"] = player.base_info.base_name player_info["level"] = player.base_info.level player_info["line_up_info"] = line_up_info( player).SerializePartialToString() str_red_units = cPickle.dumps(red_units) str_blue_units = cPickle.dumps(blue_units) logger.debug("--" * 40) print red_units print blue_units #red_best_skill_no, red_best_skill_level = player.line_up_component.get_skill_info_by_unpar(best_skill_id) seed1, seed2 = get_seeds() #def pvb_fight_remote(str_red_units, red_best_skill, red_best_skill_level, str_blue_units, player_info, boss_id, seed1, seed2): red_unpar_data = player.line_up_component.get_red_unpar_data() result, demage_hp = remote_gate['world'].pvb_fight_remote( str_red_units, red_unpar_data, str_blue_units, player_info, boss_id, damage_rate, debuff_skill_no, seed1, seed2) if result == -1: logger.debug("world boss already gone!") response.res.result = False response.res.result_no = 1706 return response.SerializePartialToString() response.fight_result = result # 玩家信息更新 boss.fight_times += 1 boss.demages.append(demage_hp) boss.last_fight_time = get_current_timestamp() player.world_boss.save_data() logger.debug("fight end..") pvp_assemble_units(red_units, blue_units, response) response.red_best_skill = best_skill_id response.red_best_skill_level = 0 response.debuff_skill_no = debuff_skill_no response.seed1 = seed1 response.seed2 = seed2 response.damage_rate = damage_rate if boss_id == 'world_boss': hook_task(player, CONDITIONId.PVBOSS_TIMES, 1) return response.SerializePartialToString()