def playing_soul_on_event_playing_actor_enter(message_type, channel, channel_type, serialize): # 事件消息 message = ccevent.playing.ttypes.EventPlayingActorEnter() TSerialization.deserialize(message, serialize) # 关注玩家杀死NPC事件、请求完成副本事件 proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_soul_on_event_actor_kill_npc") playing = soul_types.PlayingManager.get(message.playing_) if playing == None: return None actor = playing.get_actor(message.actor_) if actor == None: actor = soul_types.Actor(message.actor_) playing.add_actor(actor) # 副本管理器中建立一个玩家ID和副本ID的映射关系 soul_types.PlayingManager.add_actor(message.actor_, message.playing_) now = time.time() # 请求初始化玩家 request = ccrequest.playing.ttypes.RequestPlayingInitializeActor() request.actor_ = message.actor_ request.spend_time_ = now - playing.get_start_time() request.datas_ = [] request.scores_ = [] # 发送请求 proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR,\ request) proxy.Logging.debug("[soul] actor(%d) enter into playing" % message.actor_)
def playing_idol_on_event_playing_actor_enter(message_type, channel, channel_type, serialize): # 获取事件交互代理 communicator_proxy = variable_table.get_variable( ccvariable.ttypes.Variable.COMMUNICATOR_PROXY) # 获取请求代理 request_proxy = variable_table.get_variable( ccvariable.ttypes.Variable.REQUEST_PROXY) # 事件消息 message = ccevent.playing.ttypes.EventPlayingActorEnter() # 反序列化 TSerialization.deserialize(message, serialize) # 关注玩家杀死NPC事件、角色被杀死事件 communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC, \ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \ "playing_idol_on_event_actor_kill_npc") communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_ROLE_KILLED, \ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \ "playing_idol_on_event_actor_killed") communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_REQUEST_COMPLETE,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_idol_on_event_playing_actor_request_complete") # 获取副本对象 playing = idol_types.PlayingManager.get(message.playing_) if playing == None: log.log_error("idol副本 获取 playing(%d) 失败" % message.playing_) return None now = time.time() # 获取玩家对象 actor = playing.get_actor(message.actor_) if actor == None: # 玩家不存在时,创建并加入副本管理器中 actor = idol_types.Actor(message.actor_, now) playing.add_actor(actor) # 副本管理器中加入一个玩家ID到副本ID的对应关系 idol_types.PlayingManager.add_actor(message.actor_, message.playing_) # 请求初始化玩家 request = ccrequest.playing.ttypes.RequestPlayingInitializeActor() request.actor_ = message.actor_ request.spend_time_ = now - actor.get_start_time() request.scores_ = [] request.datas_ = [] # 序列化消息 request_data = TSerialization.serialize(request) # 发送请求 request_proxy.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR, \ request_data, len(request_data)) log.log_debug("玩家(%d) 进入 idol副本(id=%d,template=%d)" % \ (message.actor_, message.playing_, message.template_))
def playing_idol_on_event_playing_actor_enter(message_type, channel, channel_type, serialize): # 获取事件交互代理 communicator_proxy = variable_table.get_variable(ccvariable.ttypes.Variable.COMMUNICATOR_PROXY) # 获取请求代理 request_proxy = variable_table.get_variable(ccvariable.ttypes.Variable.REQUEST_PROXY) # 事件消息 message = ccevent.playing.ttypes.EventPlayingActorEnter() # 反序列化 TSerialization.deserialize(message, serialize) # 关注玩家杀死NPC事件、角色被杀死事件 communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC, \ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \ "playing_idol_on_event_actor_kill_npc") communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_ROLE_KILLED, \ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \ "playing_idol_on_event_actor_killed") communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_REQUEST_COMPLETE,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_idol_on_event_playing_actor_request_complete") # 获取副本对象 playing = idol_types.PlayingManager.get(message.playing_) if playing == None: log.log_error("idol副本 获取 playing(%d) 失败" % message.playing_) return None now = time.time() # 获取玩家对象 actor = playing.get_actor(message.actor_) if actor == None: # 玩家不存在时,创建并加入副本管理器中 actor = idol_types.Actor(message.actor_, now) playing.add_actor(actor) # 副本管理器中加入一个玩家ID到副本ID的对应关系 idol_types.PlayingManager.add_actor(message.actor_, message.playing_) # 请求初始化玩家 request = ccrequest.playing.ttypes.RequestPlayingInitializeActor() request.actor_ = message.actor_ request.spend_time_ = now - actor.get_start_time() request.scores_ = [] request.datas_ = [] # 序列化消息 request_data = TSerialization.serialize(request) # 发送请求 request_proxy.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR, \ request_data, len(request_data)) log.log_debug("玩家(%d) 进入 idol副本(id=%d,template=%d)" % \ (message.actor_, message.playing_, message.template_))
def playing_slaughter_house_on_event_playing_actor_enter( message_type, channel, channel_type, serialize): message = ccevent.playing.ttypes.EventPlayingActorEnter() TSerialization.deserialize(message, serialize) proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_ROLE_KILLED,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_slaughter_house_on_event_actor_killed") proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_slaughter_house_on_event_actor_kill_npc") ccactor = proxy.EntityManager.get_actor(message.actor_) if ccactor == None: return None playing = slaughter_house_types.PlayingManager.get(message.playing_) if playing == None: proxy.Logging.error("[slaughter_house] slaughter_house_types.PlayingManager.get(%d) failed."\ % message.playing_) return None actor = playing.get_actor(message.actor_) if actor == None: actor = slaughter_house_types.Actor(message.actor_, ccactor.get_name()) playing.add_actor(actor) playing.ranking_.add_score(message.actor_, 0) sync_ranking_actor(message.playing_, message.actor_) actor.leaving_ = False slaughter_house_types.PlayingManager.add_actor(message.actor_, message.playing_) now = time.time() # 请求初始化玩家 request = ccrequest.playing.ttypes.RequestPlayingInitializeActor() request.actor_ = message.actor_ request.spend_time_ = now - playing.get_start_time() request.datas_ = [] request.scores_ = [] request.scores_.append( ccentity.playing.ttypes.PlayingScoreField( ccentity.playing.ttypes.PlayingScoreType.STAGE, 0, playing.group_)) proxy.Request.request( ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR, request) proxy.Logging.debug("[slaughter_house] actor(%d) enter into playing" % message.actor_)
def playing_slaughter_house_on_event_playing_actor_enter(message_type, channel, channel_type, serialize): message = ccevent.playing.ttypes.EventPlayingActorEnter() TSerialization.deserialize(message, serialize) proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_ROLE_KILLED,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_slaughter_house_on_event_actor_killed") proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_slaughter_house_on_event_actor_kill_npc") ccactor = proxy.EntityManager.get_actor(message.actor_) if ccactor == None: return None playing = slaughter_house_types.PlayingManager.get(message.playing_) if playing == None: proxy.Logging.error("[slaughter_house] slaughter_house_types.PlayingManager.get(%d) failed."\ % message.playing_) return None actor = playing.get_actor(message.actor_) if actor == None: actor = slaughter_house_types.Actor(message.actor_, ccactor.get_name()) playing.add_actor(actor) playing.ranking_.add_score(message.actor_, 0) sync_ranking_actor(message.playing_, message.actor_) actor.leaving_ = False; slaughter_house_types.PlayingManager.add_actor(message.actor_, message.playing_) now = time.time() # 请求初始化玩家 request = ccrequest.playing.ttypes.RequestPlayingInitializeActor() request.actor_ = message.actor_ request.spend_time_ = now - playing.get_start_time() request.datas_ = [] request.scores_ = [] request.scores_.append(ccentity.playing.ttypes.PlayingScoreField( ccentity.playing.ttypes.PlayingScoreType.STAGE, 0, playing.group_)) proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR, request) proxy.Logging.debug("[slaughter_house] actor(%d) enter into playing" % message.actor_)
def playing_team_on_event_playing_actor_enter(message_type, channel, channel_type, serialize): # 事件消息 message = ccevent.playing.ttypes.EventPlayingActorEnter() TSerialization.deserialize(message, serialize) proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_team_on_event_actor_kill_npc") proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_SKILL_ATTACK_HIT,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_team_on_event_skill_attack_hit") ccactor = proxy.EntityManager.get_actor(message.actor_) if ccactor == None: return None playing = team_types.PlayingManager.get(message.playing_) if playing == None: return None ranking = playing.get_ranking() if ranking == None: proxy.Logging.error("[team] playing.get_ranking() failed.") return None; actor = playing.get_actor(message.actor_) if actor == None: actor = team_types.Actor(message.actor_, ccactor.get_name()) playing.add_actor(actor) ranking.add_damage(message.actor_, 0) playing_team_sync_ranking_actor(message.playing_, message.actor_) # 消耗玩家副本次数 request = ccrequest.playing.ttypes.RequestPlayingActorIncreaseComplete() request.playing_template_ = playing.get_template() request.actor_ = message.actor_ # 发送请求 proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_ACTOR_INCREASE_COMPLETE,\ request) actor.set_leave(False) # 副本管理器中建立一个玩家ID和副本ID的映射关系 team_types.PlayingManager.add_actor(message.actor_, message.playing_) now = time.time() # 请求初始化玩家 request = ccrequest.playing.ttypes.RequestPlayingInitializeActor() request.actor_ = message.actor_ request.spend_time_ = now - playing.get_start_time() request.datas_ = [] request.scores_ = [] # 循环获取玩家杀死的每个NPC for (k,v) in playing.get_kill_npcs().items(): score_field = ccentity.playing.ttypes.PlayingScoreField() score_field.type_ = ccentity.playing.ttypes.PlayingScoreType.KILL_NPC score_field.key_ = k; score_field.value_ = v; request.scores_.append(score_field); # 发送请求 proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR,\ request) proxy.Logging.debug("[team] actor(%d) enter into playing" % message.actor_)
def playing_plot_on_event_playing_actor_enter(message_type, channel, channel_type, serialize): # 获取事件交互代理 communicator_proxy = variable_table.get_variable( ccvariable.ttypes.Variable.COMMUNICATOR_PROXY) # 获取请求代理 request_proxy = variable_table.get_variable( ccvariable.ttypes.Variable.REQUEST_PROXY) # 事件消息 message = ccevent.playing.ttypes.EventPlayingActorEnter() # 反序列化 TSerialization.deserialize(message, serialize) # 关注玩家杀死NPC事件、请求完成副本事件、角色被杀死事件 communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC, \ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \ "playing_plot_on_event_actor_kill_npc") communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_REQUEST_COMPLETE,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_plot_on_event_playing_actor_request_complete") communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_ROLE_KILLED, \ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \ "playing_plot_on_event_actor_killed") # 副本1需要关注玩家血量改变的事件 if message.template_ == 1: proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_ROLE_CHANGE_HP, \ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \ "playing_plot_on_event_role_change_hp") # 获取副本对象 playing = plot_types.PlayingManager.get(message.playing_) if playing == None: proxy.Logging.error("plot_types.PlayingManager.get(%d) failed." % message.playing_) return None now = time.time() # 获取玩家对象 actor = playing.get_actor(message.actor_) if actor == None: # 玩家不存在时,创建并加入副本中 actor = plot_types.Actor(message.actor_, now) playing.add_actor(actor) # 消耗玩家副本次数 request = ccrequest.playing.ttypes.RequestPlayingIncreaseComplete() # request.actor_ = message.actor_ # request.playing_template_ = message.template_ request.playing_ = message.playing_ # 序列化 request_data = TSerialization.serialize(request) # 发送请求 request_proxy.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INCREASE_COMPLETE, \ request_data, len(request_data)) # 副本管理器中加入一个玩家ID到副本ID的对应关系 plot_types.PlayingManager.add_actor(message.actor_, message.playing_) # 请求初始化玩家 request = ccrequest.playing.ttypes.RequestPlayingInitializeActor() request.actor_ = message.actor_ request.spend_time_ = now - actor.get_start_time() request.scores_ = [] request.datas_ = [] # 循环获取玩家杀死的每个NPC for (k, v) in actor.get_kill_npcs().items(): score_field = ccentity.playing.ttypes.PlayingScoreField() score_field.type_ = ccentity.playing.ttypes.PlayingScoreType.KILL_NPC score_field.key_ = k score_field.value_ = v request.scores_.append(score_field) # 序列化消息 request_data = TSerialization.serialize(request) # 发送请求 request_proxy.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR, \ request_data, len(request_data)) log.log_debug("玩家(%d)进入副本(id=%d,template=%d)" % \ (message.actor_, message.playing_, message.template_))
def playing_plot_on_event_playing_actor_enter(message_type, channel, channel_type, serialize): # 获取事件交互代理 communicator_proxy = variable_table.get_variable(ccvariable.ttypes.Variable.COMMUNICATOR_PROXY) # 获取请求代理 request_proxy = variable_table.get_variable(ccvariable.ttypes.Variable.REQUEST_PROXY) # 事件消息 message = ccevent.playing.ttypes.EventPlayingActorEnter() # 反序列化 TSerialization.deserialize(message, serialize) # 关注玩家杀死NPC事件、请求完成副本事件、角色被杀死事件 communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC, \ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \ "playing_plot_on_event_actor_kill_npc") communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_REQUEST_COMPLETE,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_plot_on_event_playing_actor_request_complete") communicator_proxy.follow(ccevent.ttypes.EventType.EVENT_ROLE_KILLED, \ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \ "playing_plot_on_event_actor_killed") # 副本1需要关注玩家血量改变的事件 if message.template_ == 1: proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_ROLE_CHANGE_HP, \ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \ "playing_plot_on_event_role_change_hp"); # 获取副本对象 playing = plot_types.PlayingManager.get(message.playing_) if playing == None: proxy.Logging.error("plot_types.PlayingManager.get(%d) failed." % message.playing_) return None now = time.time() # 获取玩家对象 actor = playing.get_actor(message.actor_) if actor == None: # 玩家不存在时,创建并加入副本中 actor = plot_types.Actor(message.actor_, now) playing.add_actor(actor) # 消耗玩家副本次数 request = ccrequest.playing.ttypes.RequestPlayingIncreaseComplete() # request.actor_ = message.actor_ # request.playing_template_ = message.template_ request.playing_ = message.playing_ # 序列化 request_data = TSerialization.serialize(request) # 发送请求 request_proxy.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INCREASE_COMPLETE, \ request_data, len(request_data)) # 副本管理器中加入一个玩家ID到副本ID的对应关系 plot_types.PlayingManager.add_actor(message.actor_, message.playing_) # 请求初始化玩家 request = ccrequest.playing.ttypes.RequestPlayingInitializeActor() request.actor_ = message.actor_ request.spend_time_ = now - actor.get_start_time() request.scores_ = [] request.datas_ = [] # 循环获取玩家杀死的每个NPC for (k,v) in actor.get_kill_npcs().items(): score_field = ccentity.playing.ttypes.PlayingScoreField() score_field.type_ = ccentity.playing.ttypes.PlayingScoreType.KILL_NPC score_field.key_ = k; score_field.value_ = v; request.scores_.append(score_field); # 序列化消息 request_data = TSerialization.serialize(request) # 发送请求 request_proxy.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR, \ request_data, len(request_data)) log.log_debug("玩家(%d)进入副本(id=%d,template=%d)" % \ (message.actor_, message.playing_, message.template_))