def inherit_equipment_152(pro_data, player): """ 装备传承 """ request = inherit_pb2.InheritEquipmentRequest() request.ParseFromString(pro_data) origin_id = request.origin target_id = request.target response = common_pb2.CommonResponse() if is_not_open(player, FO_INHERIT): response.result = False response.result_no = 837 return response.SerializeToString() origin = player.equipment_component.get_equipment(origin_id) target = player.equipment_component.get_equipment(target_id) # print origin.attribute.strengthen_lv, target.attribute.strengthen_lv, "+"*10 if not origin or (not target): logger.error("equip %s or %s not exists" % (origin_id, target_id)) response.result = False return response.SerializeToString() if origin.attribute.strengthen_lv <= target.attribute.strengthen_lv: logger.error( "origin equip %s strengthen_lv <= target equip %s strengthen_lv!" % (origin_id, target_id)) response.result = False return response.SerializeToString() if origin.equipment_config_info.get( "quality") != target.equipment_config_info.get("quality"): logger.error("origin.quality!=target.quality") response.result = False return response.SerializeToString() i_value = 0 def func(): """docstring for func""" target.attribute.strengthen_lv = origin.attribute.strengthen_lv i_value = target.attribute.strengthen_lv origin.attribute.strengthen_lv = 1 # 传承强化过程 target.enhance_record.enhance_record = origin.enhance_record.enhance_record origin.enhance_record.enhance_record = [] target.save_data() origin.save_data() print origin.attribute.strengthen_lv, target.attribute.strengthen_lv, "+" * 10 gold = game_configs.base_config.get("equInheritPrice") player.pay.pay(gold, const.INHERIT_EQUIPMENT, func) response.result = True tlog_action.log('Inherit', player, 2, origin.base_info.id, origin.base_info.equipment_no, target.base_info.id, target.base_info.equipment_no, i_value) return response.SerializeToString()
def invite_1908(data, player): """发送/接受邀请""" request = escort_pb2.InviteEscortTaskRequest() request.ParseFromString(data) logger.debug("request %s" % request) response = common_pb2.CommonResponse() task_id = request.task_id send_or_in = request.send_or_in protect_or_rob = request.protect_or_rob task_guild_id = request.task_guild_id rob_no = request.rob_no escort_open_time_item = game_configs.base_config.get("EscortOpenTime") if not is_in_period(escort_open_time_item): logger.error("feature not open!") response.result = False response.result_no = 30000 return response.SerializePartialToString() res = None if send_or_in == 1: res = send_invite(player, task_id, protect_or_rob, task_guild_id, rob_no) elif send_or_in == 2: res = in_invite(player, task_id, protect_or_rob, task_guild_id, rob_no) response.result = res.get('result') if not res.get('result'): response.result_no = res.get('result_no') return response.SerializePartialToString() tlog_action.log('GuildTaskInvite', player, task_id, task_guild_id, send_or_in, protect_or_rob, rob_no) response.result = True return response.SerializePartialToString()
def settle_1252(data, player): request = mine_pb2.MineSettleRequest() response = common_pb2.CommonResponse() request.ParseFromString(data) pos = request.pos result = request.result is_pvp = player.mine.is_pvp(pos) # 根据矿所在位置判断pve or pvp logger.debug("pos %s, mine_info %s" % (pos, is_pvp)) pve_check_result = pve_process_check(player, result, request.steps, const.BATTLE_MINE_PVE) if is_pvp is False and not pve_check_result: logger.error("mine pve_process_check error!!!!!") res = response.res res.result = False res.result_no = 9041 return response.SerializePartialToString() # todo: set settle time to calculate acc_mine process_mine_result(player, pos, result, None, 0, 1) # 7日奖励 占领矿点 mine_id = player.mine._mine[pos].get("mine_id") mine_item = game_configs.mine_config.get(mine_id) logger.debug("mine_id %s mine_item %s" % (mine_id, mine_item)) if mine_item: player.act.mine_win(mine_item.quality) target_update(player, [57]) response.result = True return response.SerializePartialToString()
def inherit_refine_151(pro_data, player): """ 炼体传承 """ request = inherit_pb2.InheritRefineRequest() request.ParseFromString(pro_data) origin_id = request.origin target_id = request.target response = common_pb2.CommonResponse() origin = player.hero_component.get_hero(origin_id) target = player.hero_component.get_hero(target_id) if is_not_open(player, FO_INHERIT): response.result = False response.result_no = 837 return response.SerializeToString() print "origin:", origin.refine, "target:", target.refine if not origin or (not target): logger.error("hero %s or %s not exists" % (origin_id, target_id)) response.result = False return response.SerializeToString() if not origin.refine: logger.error("origin hero %s do not have refine!" % origin_id) response.result = False return response.SerializeToString() if origin.refine <= target.refine: logger.error("origin hero %s refine <= target hero %s refine!" % (origin_id, target_id)) response.result = False return response.SerializeToString() i_value = 0 def func(): target.refine = origin.refine origin.refine = 0 target.save_data() origin.save_data() i_value = target.refine gold = game_configs.base_config.get("heroInheritPrice") player.pay.pay(gold, const.INHERIT_REFINE, func) player.finance.save_data() response.result = True tlog_action.log('Inherit', player, 1, 0, origin_id, 0, target_id, i_value) return response.SerializeToString()
def cancel_escort_task_1906(data, player): """取消劫运任务""" request = escort_pb2.CancelEscortTaskRequest() request.ParseFromString(data) logger.debug("request %s" % request) task_id = request.task_id task_guild_id = request.task_guild_id rob_no = request.rob_no if rob_no == -1: logger.debug("rob_no can not be None!!") remote_gate["world"].cancel_rob_task_remote(task_guild_id, task_id, rob_no) response = common_pb2.CommonResponse() tlog_action.log('CancelEscortTask', player, task_id, task_guild_id) response.result = True return response.SerializePartialToString()
def receive_escort_task_1905(data, player): """接受押运任务""" request = escort_pb2.ReceiveEscortTaskRequest() request.ParseFromString(data) logger.debug("request %s" % request) task_id = request.task_id #protect_or_rob = request.protect_or_rob #task_guild_id = request.task_guild_id response = common_pb2.CommonResponse() res = receive_protect_task(player, task_id) if not res.get('result'): response.result_no = res.get('result_no') response.result = res.get('result') tlog_action.log('ReceiveEscortTask', player, task_id) return response.SerializePartialToString()
def inherit_upara_153(pro_data, player): """ 无双传承 """ request = inherit_pb2.InheritUnparaRequest() request.ParseFromString(pro_data) origin_id = request.origin target_id = request.target response = common_pb2.CommonResponse() if is_not_open(player, FO_INHERIT): response.result = False response.result_no = 837 return response.SerializeToString() origin_level = player.line_up_component.unpars.get(origin_id) target_level = player.line_up_component.unpars.get(target_id) if not origin_level: logger.error("unpara %s or %s not exists" % (origin_id, target_id)) response.result = False return response.SerializeToString() if origin_level <= target_level: logger.error("origin.level!=target.level") response.result = False return response.SerializeToString() def func(): player.line_up_component.unpars[target_id] = origin_level player.line_up_component.unpars[origin_id] = 1 player.line_up_component.save_data() need_gold = game_configs.base_config.get("warriorsInheritPrice") player.pay.pay(need_gold, const.INHERIT_UPARA, func) response.result = True tlog_action.log('Inherit', player, 1, 0, origin_id, 0, target_id, 0) return response.SerializeToString()
def trigger_boss_1259(self, message): response = common_pb2.CommonResponse() response.ParseFromString(message) print response
def cancel_escort_task_1906(self, message): print "cancel_escort_task_1906===================" response = common_pb2.CommonResponse() response.ParseFromString(message) self.on_command_finish()
def receive_task_1905(self, message): print "receive_task_1905===================" response = common_pb2.CommonResponse() response.ParseFromString(message) self.on_command_finish()
def invite_1908(self, message): print "invite_1908===================" response = common_pb2.CommonResponse() response.ParseFromString(message) self.on_command_finish()