def playing_soul_on_event_actor_kill_npc(message_type, channel, channel_type, serialize): # 事件消息 message = ccevent.actor.ttypes.EventActorKillNpc() TSerialization.deserialize(message, serialize) # 获取玩家所在副本ID playing_id = soul_types.PlayingManager.get_actor_playing(message.actor_) if playing_id == None or playing_id == 0: proxy.Logging.error("[soul] PlayingManager.get_actor_playing(%d) failed" % message.actor_) return None playing = soul_types.PlayingManager.get(playing_id) if playing == None: proxy.Logging.error("[soul] PlayingManager.get(%d) failed" % playing_id) return None actor = playing.get_actor(message.actor_) if actor == None: proxy.Logging.error("[soul] playing.get_actor(%d) failed" % message.actor_) return None if message.npc_template_ == soul_types.Config.get_boss(): request = ccrequest.playing.ttypes.RequestPlayingComplete() request.playing_ = playing_id result = ccentity.playing.ttypes.PlayingResultField() result.values_ = [] result.award_count_ = 1 result.paid_award_count_ = 0; result.awarded_ = False request.result_ = result request.awards_ = [] # 得到奖励 awards = soul_types.Config.get_awards() if awards == None: proxy.Logging.error("[soul] Config.get_awards() failed") return None for i in range(0, len(awards) - 1): request.awards_.append(awards[i]) request.draw_awards_ = [] # 得到抽奖奖励 draw_awards = soul_types.Config.get_draw_awards() if draw_awards == None: proxy.Logging.error("[soul] Config.get_draw_awards() failed") return None draw_awards_size = len(draw_awards) if draw_awards_size > 0: request.draw_award_ = draw_awards[random.randint(0, draw_awards_size - 1)] actor.set_draw_award(request.draw_award_) else: return None # 发送请求 proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_COMPLETE,\ request) # 消耗玩家副本次数 request = ccrequest.playing.ttypes.RequestPlayingIncreaseComplete() request.playing_ = playing_id # 发送请求 proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INCREASE_COMPLETE,\ request) playing.set_complete() # 取消定时器 proxy.Timer.remove(playing_id, "playing_soul_on_timer_playing") proxy.Logging.debug("[soul] complete playing") proxy.Logging.debug("[soul] actor(%d) kill npc(%d)" % (message.actor_, message.npc_template_))
def playing_team_on_event_actor_kill_npc(message_type, channel, channel_type, serialize): # 事件消息 message = ccevent.actor.ttypes.EventActorKillNpc() TSerialization.deserialize(message, serialize) # 获取玩家所在副本ID playing_id = team_types.PlayingManager.get_actor_playing(message.actor_) if playing_id == None or playing_id == 0: proxy.Logging.error("[team] PlayingManager.get_actor_playing(%d) failed" % message.actor_) return None playing = team_types.PlayingManager.get(playing_id) if playing == None: proxy.Logging.error("[team] PlayingManager.get(%d) failed" % playing_id) return None playing_config = team_types.Config.get(playing.get_template()) if playing_config == None: proxy.Logging.error("[team] team_types.Config.get(%d) failed." % playing.get_template()) return None playing_cell = playing_types.Config.get(playing.get_template()) if playing_cell == None: proxy.Logging.debug("[team] playing_types.Config.get(%d) failed." % playing.get_template()) return None actor = playing.get_actor(message.actor_) if actor == None: proxy.Logging.error("[team] playing.get_actor(%d) failed" % message.actor_) return None playing.inc_kill_npc(message.npc_template_) actors = playing.get_actors() if actors == None: proxy.Logging.error("[team] playing.get_actors() failed") return None if playing_config.summon_next_npc(playing.get_scene(), playing.get_next_pos()) == False: playing_team_sync_ranking(playing_id) request = ccrequest.playing.ttypes.RequestPlayingComplete() request.playing_ = playing_id result = ccentity.playing.ttypes.PlayingResultField() result.values_ = [] result.award_count_ = 1 result.paid_award_count_ = 0; result.awarded_ = False # result.value1: 花费时间 request.result_ = result request.awards_ = [] for award in playing_cell.awards_: request.awards_.append(award) proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_COMPLETE,\ request) # 设置副本已完成 playing.set_complete() # 取消定时器 proxy.Timer.remove(playing_id, "playing_team_on_timer_playing") proxy.Timer.remove(playing_id, "playing_team_on_timer_sync_ranking") # 同步一次排行 proxy.Logging.debug("[team] complete playing") # 同步得分 for (k,v) in actors.items(): request = ccrequest.playing.ttypes.RequestPlayingSynchronizeScore() request.actor_ = k # 分数对象(得分类型=杀死NPC, key=NPC模板ID, value=当前杀死的个数) score_field = ccentity.playing.ttypes.PlayingScoreField(ccentity.playing.ttypes.PlayingScoreType.KILL_NPC,\ message.npc_template_, playing.get_kill_npc(message.npc_template_)) request.score_ = score_field # 发送请求 proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_SYNCHRONIZE_SCORE,\ request) if playing.get_complete() == True: award_actor = playing.get_actor(k) if award_actor == None: proxy.Logging.debug("[team] playing.get_actor(%d) failed." % k) return None # 不在副本内不给奖励 if award_actor.get_leave() == False: # 直接给奖励 request_award = ccrequest.playing.ttypes.RequestPlayingAwardActor() request_award.actor_ = k request_award.playing_template_ = playing.get_template() request_award.awards_ = [] for award in playing_cell.awards_: request_award.awards_.append(award) proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_AWARD_ACTOR, request_award) proxy.Logging.debug("[team] add_award award") playing.next_pos() proxy.Logging.debug("[team] actor(%d) kill npc(%d)" % (message.actor_, message.npc_template_))
def playing_soul_on_event_actor_kill_npc(message_type, channel, channel_type, serialize): # 事件消息 message = ccevent.actor.ttypes.EventActorKillNpc() TSerialization.deserialize(message, serialize) # 获取玩家所在副本ID playing_id = soul_types.PlayingManager.get_actor_playing(message.actor_) if playing_id == None or playing_id == 0: proxy.Logging.error( "[soul] PlayingManager.get_actor_playing(%d) failed" % message.actor_) return None playing = soul_types.PlayingManager.get(playing_id) if playing == None: proxy.Logging.error("[soul] PlayingManager.get(%d) failed" % playing_id) return None actor = playing.get_actor(message.actor_) if actor == None: proxy.Logging.error("[soul] playing.get_actor(%d) failed" % message.actor_) return None if message.npc_template_ == soul_types.Config.get_boss(): request = ccrequest.playing.ttypes.RequestPlayingComplete() request.playing_ = playing_id result = ccentity.playing.ttypes.PlayingResultField() result.values_ = [] result.award_count_ = 1 result.paid_award_count_ = 0 result.awarded_ = False request.result_ = result request.awards_ = [] # 得到奖励 awards = soul_types.Config.get_awards() if awards == None: proxy.Logging.error("[soul] Config.get_awards() failed") return None for i in range(0, len(awards) - 1): request.awards_.append(awards[i]) request.draw_awards_ = [] # 得到抽奖奖励 draw_awards = soul_types.Config.get_draw_awards() if draw_awards == None: proxy.Logging.error("[soul] Config.get_draw_awards() failed") return None draw_awards_size = len(draw_awards) if draw_awards_size > 0: request.draw_award_ = draw_awards[random.randint( 0, draw_awards_size - 1)] actor.set_draw_award(request.draw_award_) else: return None # 发送请求 proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_COMPLETE,\ request) # 消耗玩家副本次数 request = ccrequest.playing.ttypes.RequestPlayingIncreaseComplete() request.playing_ = playing_id # 发送请求 proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INCREASE_COMPLETE,\ request) playing.set_complete() # 取消定时器 proxy.Timer.remove(playing_id, "playing_soul_on_timer_playing") proxy.Logging.debug("[soul] complete playing") proxy.Logging.debug("[soul] actor(%d) kill npc(%d)" % (message.actor_, message.npc_template_))