def playing_slime_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_slime_on_event_actor_kill_npc") proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_REQUEST_COMPLETE,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_slime_on_event_playing_actor_request_complete") playing = slime_types.PlayingManager.get(message.playing_) if playing == None: return None now = time.time() actor = playing.get_actor() if actor == 0: playing.set_start_time(now) playing.set_actor(message.actor_) # 消耗玩家副本次数 request = ccrequest.playing.ttypes.RequestPlayingIncreaseComplete() # request.actor_ = message.actor_ # request.playing_template_ = message.template_ request.playing_ = message.playing_ # 发送请求 proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INCREASE_COMPLETE,\ request) proxy.Timer.add(message.playing_, slime_types.Config.get_slime_time() * 1000, 1, "playing_slime_on_timer_slime") # 副本管理器中建立一个玩家ID和副本ID的映射关系 slime_types.PlayingManager.add_actor(message.actor_, message.playing_) # 请求初始化玩家 request = ccrequest.playing.ttypes.RequestPlayingInitializeActor() request.actor_ = message.actor_ request.spend_time_ = now - playing.get_start_time() # datas = [剩余体力, 阶段, 当前阶段剩余时间] request.datas_ = [] request.datas_.append(slime_types.Config.get_max_power() - playing.get_spend_power()) if playing.get_section_boss() == True: request.datas_.append(2) request.datas_.append(now - playing.get_boss_summon_time()) else: request.datas_.append(1) # 第一阶段剩下的时间 elapse_time = now - playing.get_start_time() if elapse_time <= slime_types.Config.get_slime_time(): request.datas_.append(slime_types.Config.get_slime_time() - elapse_time) else: request.datas_.append(0) request.scores_ = [] request.scores_.append(ccentity.playing.ttypes.PlayingScoreField(\ ccentity.playing.ttypes.PlayingScoreType.KILL_NPC, 0, playing.get_score())) request.scores_.append(ccentity.playing.ttypes.PlayingScoreField(\ ccentity.playing.ttypes.PlayingScoreType.POWER, 0,\ slime_types.Config.get_max_power() - playing.get_spend_power())) proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR,\ request) # 转为临时技能形态 facade_request.change_skill_form(ccentity.entity.ttypes.EntityType.TYPE_ACTOR,\ message.actor_, ccentity.skill.ttypes.SkillFormType.TEMP) # 增加临时技能 facade_request.add_temp_skill(ccentity.entity.ttypes.EntityType.TYPE_ACTOR,\ message.actor_, 100, 1) facade_request.add_temp_skill(ccentity.entity.ttypes.EntityType.TYPE_ACTOR,\ message.actor_, 200, 1) facade_request.add_temp_skill(ccentity.entity.ttypes.EntityType.TYPE_ACTOR,\ message.actor_, 300, 1) proxy.Logging.debug("[slime] actor(%d) enter into playing" % message.actor_)
def playing_monsters_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_monsters_on_event_actor_kill_npc") proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_REQUEST_COMPLETE,\ message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\ "playing_monsters_on_event_playing_actor_request_complete") playing = monsters_types.PlayingManager.get(message.playing_) if playing == None: return None now = time.time() actor = playing.get_actor() if actor == 0: playing.set_start_time(now) playing.set_actor(message.actor_) # 消耗玩家副本次数 request = ccrequest.playing.ttypes.RequestPlayingIncreaseComplete() request.actor_ = message.actor_ request.playing_template_ = message.template_ # 发送请求 proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INCREASE_COMPLETE,\ request) proxy.Timer.add(message.playing_, monsters_types.Config.get_playing_time(),\ 1, "playing_monsters_on_timer_playing_time") # 副本管理器中建立一个玩家ID和副本ID的映射关系 monsters_types.PlayingManager.add_actor(message.actor_, message.playing_) # 请求初始化玩家 request = ccrequest.playing.ttypes.RequestPlayingInitializeActor() request.actor_ = message.actor_ request.spend_time_ = now - playing.get_start_time() ######################################## # TODO: 考虑做为分数进行同步 # datas = [祭坛1(0为未完成1为完成)+祭坛2+祭坛3+祭坛4+祭坛5+祭坛6] request.datas_ = [] cages = playing.get_cages() for i in range(0, len(cages)): if cages[i].get_current_round() < cages[i].get_max_round(): request.datas_.append(0) else: request.datas_.append(1) ######################################## request.scores_ = [] # 循环获取玩家杀死的每个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); proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR,\ request) proxy.Logging.debug("[monsters] actor(%d) enter into playing" % message.actor_)