예제 #1
0
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_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_)
예제 #3
0
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_)
예제 #4
0
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_)
예제 #5
0
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_)
예제 #6
0
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_)
예제 #7
0
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_)
예제 #8
0
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_)