예제 #1
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_)
예제 #2
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_)
예제 #3
0
def playing_slime_on_event_playing_actor_request_complete(message_type, channel, channel_type, serialize):
  # 事件消息
  message = ccevent.playing.ttypes.EventPlayingActorRequestComplete()
  # 反序列化
  TSerialization.deserialize(message, serialize)

  # 获取副本对象
  playing = slime_types.PlayingManager.get(message.playing_)
  if playing == None:
    proxy.Logging.error("[slime] PlayingManager.get(%d) failed." % message.playing_)
    return None

  if playing.get_section_boss() == False:
    proxy.Logging.error("[slime] finish failed get_section_boss().")
    return None

  if playing.get_kill_boss() == False:
    proxy.Logging.error("[slime] finish failed, get_kill_boss()")
    return None

  # 请求完成消息
  request = ccrequest.playing.ttypes.RequestPlayingComplete()
  # request.actor_ = message.actor_
  request.playing_ = message.playing_

  result = ccentity.playing.ttypes.PlayingResultField()
  result.values_ = []
  result.award_count_ = 1
  result.paid_award_count_ = 0;
  result.awarded_ = False
  request.result_ = result

  # 得到奖励配置对象
  award_config = slime_types.Config.get_award()
  if award_config == None:
    proxy.Logging.error("[slime] Config.get_award() failed.")
    return None

  # 抽奖
  draw_awards = award_config.get_draw_awards()
  if draw_awards == None:
    proxy.Logging.error("[slime] award_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)]
    playing.set_draw_award(request.draw_award_)
  else:
    return None

  # 固定奖励
  # request.awards_ = award_config.get_awards()
  request.awards_ = []
  awards = award_config.get_awards()
  for i in range(0, len(awards) - 1):
    request.awards_.append(awards[i])

  # 发送请求
  proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_COMPLETE,\
      request)

  # 取消BOSS定时器
  proxy.Timer.remove(message.playing_, "playing_slime_on_timer_boss")

  proxy.Logging.debug("[slime] actor(%d) complete playing.")
예제 #4
0
def playing_slime_on_event_playing_actor_request_complete(
        message_type, channel, channel_type, serialize):
    # 事件消息
    message = ccevent.playing.ttypes.EventPlayingActorRequestComplete()
    # 反序列化
    TSerialization.deserialize(message, serialize)

    # 获取副本对象
    playing = slime_types.PlayingManager.get(message.playing_)
    if playing == None:
        proxy.Logging.error("[slime] PlayingManager.get(%d) failed." %
                            message.playing_)
        return None

    if playing.get_section_boss() == False:
        proxy.Logging.error("[slime] finish failed get_section_boss().")
        return None

    if playing.get_kill_boss() == False:
        proxy.Logging.error("[slime] finish failed, get_kill_boss()")
        return None

    # 请求完成消息
    request = ccrequest.playing.ttypes.RequestPlayingComplete()
    # request.actor_ = message.actor_
    request.playing_ = message.playing_

    result = ccentity.playing.ttypes.PlayingResultField()
    result.values_ = []
    result.award_count_ = 1
    result.paid_award_count_ = 0
    result.awarded_ = False
    request.result_ = result

    # 得到奖励配置对象
    award_config = slime_types.Config.get_award()
    if award_config == None:
        proxy.Logging.error("[slime] Config.get_award() failed.")
        return None

    # 抽奖
    draw_awards = award_config.get_draw_awards()
    if draw_awards == None:
        proxy.Logging.error("[slime] award_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)]
        playing.set_draw_award(request.draw_award_)
    else:
        return None

    # 固定奖励
    # request.awards_ = award_config.get_awards()
    request.awards_ = []
    awards = award_config.get_awards()
    for i in range(0, len(awards) - 1):
        request.awards_.append(awards[i])

    # 发送请求
    proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_COMPLETE,\
        request)

    # 取消BOSS定时器
    proxy.Timer.remove(message.playing_, "playing_slime_on_timer_boss")

    proxy.Logging.debug("[slime] actor(%d) complete playing.")