示例#1
0
def send_reward(act_id):
    instance = Ranking.instance('LimitHeroRank')
    rank_info = instance.get(1, 9999)
    rank = 0
    for (p_id, integral) in rank_info:
        rank += 1
        need_integral = game_configs.base_config. \
            get('CardTimeParticipateInAwards')

        mail_id = get_mail_id(rank, act_id)
        if mail_id:
            mail_data, _ = deal_mail(conf_id=mail_id,
                                     receive_id=int(p_id),
                                     rank=rank,
                                     integral=int(integral))
            for child in childsmanager.childs.values():
                child.push_message_remote('receive_mail_remote', int(p_id),
                                          mail_data)
                break

        need_integral = game_configs.base_config. \
            get('CardTimeParticipateInAwards')
        mail_id = game_configs.base_config. \
            get('CardTimeActivity2').get(act_id)[0]
        if int(integral) < need_integral:
            continue
        mail_data, _ = deal_mail(conf_id=mail_id, receive_id=int(p_id))
        for child in childsmanager.childs.values():
            child.push_message_remote('receive_mail_remote', int(p_id),
                                      mail_data)
            break
示例#2
0
def send_reward(act_id):
    instance = Ranking.instance('LimitHeroRank')
    rank_info = instance.get(1, 9999)
    rank = 0
    for (p_id, integral) in rank_info:
        rank += 1
        need_integral = game_configs.base_config. \
            get('CardTimeParticipateInAwards')

        mail_id = get_mail_id(rank, act_id)
        if mail_id:
            mail_data, _ = deal_mail(conf_id=mail_id, receive_id=int(p_id),
                                     rank=rank, integral=int(integral))
            for child in childsmanager.childs.values():
                child.push_message_remote('receive_mail_remote', int(p_id),
                                          mail_data)
                break

        need_integral = game_configs.base_config. \
            get('CardTimeParticipateInAwards')
        mail_id = game_configs.base_config. \
            get('CardTimeActivity2').get(act_id)[0]
        if int(integral) < need_integral:
            continue
        mail_data, _ = deal_mail(conf_id=mail_id, receive_id=int(p_id))
        for child in childsmanager.childs.values():
            child.push_message_remote('receive_mail_remote', int(p_id),
                                      mail_data)
            break
示例#3
0
def pvp_daily_award():
    logger.debug('pvp daily send award mail ')
    arena_award = game_configs.base_config.get('arena_day_points')
    records = tb_pvp_rank.zrangebyscore(0, 10000, withscores=True)

    childs = groot.childsmanager.childs
    for k, v in records:
        rank = int(v)
        character_id = int(k)
        if character_id < 10000:
            continue
        for up, down, mail_id in arena_award.values():
            if rank >= up and rank <= down:
                break
        else:
            logger.error('pvp daily award error:%s-%s', rank, character_id)
            continue

        mail_data, _ = deal_mail(conf_id=mail_id, receive_id=character_id)

        for child in childs.values():
            if 'gate' in child.name:
                result = child.pull_message_remote('receive_mail_remote',
                                                   character_id, (mail_data, ))
                if type(result) is bool and result:
                    break
                else:
                    logger.debug('pvp_daily_award_tick result:%s,%s,%s',
                                 result, k, mail_data)
        else:
            message_cache.cache_time('receive_mail_remote', character_id,
                                     60 * 60 * 24 * 180, mail_data)
        tlog_action.log('PvpDailyAward', character_id, mail_id, rank)
示例#4
0
def pvp_daily_award():
    logger.debug('pvp daily send award mail ')
    arena_award = game_configs.base_config.get('arena_day_points')
    records = tb_pvp_rank.zrangebyscore(0, 10000, withscores=True)

    childs = groot.childsmanager.childs
    for k, v in records:
        rank = int(v)
        character_id = int(k)
        if character_id < 10000:
            continue
        for up, down, mail_id in arena_award.values():
            if rank >= up and rank <= down:
                break
        else:
            logger.error('pvp daily award error:%s-%s', rank, character_id)
            continue

        mail_data, _ = deal_mail(conf_id=mail_id, receive_id=character_id)

        for child in childs.values():
            if 'gate' in child.name:
                result = child.pull_message_remote('receive_mail_remote',
                                                   character_id,
                                                   (mail_data,))
                if type(result) is bool and result:
                    break
                else:
                    logger.debug('pvp_daily_award_tick result:%s,%s,%s',
                                 result, k, mail_data)
        else:
            message_cache.cache_time('receive_mail_remote', character_id, 60*60*24*180, mail_data)
        tlog_action.log('PvpDailyAward', character_id, mail_id, rank)
示例#5
0
def send_mail(conf_id, receive_id, prize):
    mail_data, _ = deal_mail(conf_id=conf_id,
                             receive_id=int(receive_id),
                             prize=prize)
    get_remote_gate().push_message_to_transit_remote('receive_mail_remote',
                                                     int(receive_id),
                                                     mail_data)
示例#6
0
    def send_rank_reward_mails(self):
        """
        排行奖励
        """
        logger.debug("hjqy send_award_top_ten===========")
        award_info = game_configs.base_config.get("hjqyDayReward")
        for up, down, mail_id in award_info.values():
            ranks = self._rank_instance.get(up, down)
            for k, v in enumerate(ranks):
                player_id, val = v
                logger.debug("send_award_top_ten: player_id %s, value %s, mail_id %s" % (player_id, v, mail_id))
                mail_data, _ = deal_mail(conf_id=mail_id, receive_id=int(player_id))
                remote_gate = GlobalObject().child('gate')
                remote_gate.push_message_to_transit_remote('receive_mail_remote',
                                                           int(player_id), mail_data)

        #clear rankinfo
        self._rank_instance.clear_rank()
示例#7
0
    def send_rank_reward_mails(self):
        """
        排行奖励
        """
        logger.debug("hjqy send_award_top_ten===========")
        award_info = game_configs.base_config.get("hjqyDayReward")
        for up, down, mail_id in award_info.values():
            ranks = self._rank_instance.get(up, down)
            for k, v in enumerate(ranks):
                player_id, val = v
                logger.debug(
                    "send_award_top_ten: player_id %s, value %s, mail_id %s" %
                    (player_id, v, mail_id))
                mail_data, _ = deal_mail(conf_id=mail_id,
                                         receive_id=int(player_id))
                remote_gate = GlobalObject().child('gate')
                remote_gate.push_message_to_transit_remote(
                    'receive_mail_remote', int(player_id), mail_data)

        #clear rankinfo
        self._rank_instance.clear_rank()
示例#8
0
文件: hjqy.py 项目: Cuick/traversing
def hjqy_battle_remote(player_info, boss_id, str_red_units, red_unpar_data, attack_type, seed1, seed2):
    """开始战斗
    """
    logger.debug("hjqy_battle_remote======")
    red_units = cPickle.loads(str_red_units)
    result = False
    boss = hjqy_manager.get_boss(boss_id)
    player_id = player_info.get("player_id")
    player_level = player_info.get("level")
    blue_units = boss.blue_units

    origin_hp = boss.hp
    result = hjqy_start(red_units,  blue_units, red_unpar_data, {}, attack_type, seed1, seed2, player_level)

    logger.debug("blue unit length %s" % len(blue_units))
    boss.blue_units = blue_units

    current_damage_hp = origin_hp - boss.hp
    logger.debug("origin_hp %s, current_hp %s, current_damage_hp %s" % (origin_hp, boss.hp, current_damage_hp))

    player_info["damage_hp"] = current_damage_hp
    hjqy_manager.add_rank_item(player_info) # 添加排行

    is_kill = 0
    if boss.get_state() == const.BOSS_DEAD: # 击杀boss
        is_kill = 1
        # send last kill reward mail
        hjqyKillBossReward = game_configs.base_config.get("hjqyKillBossRewardID")
        mail_data, _ = deal_mail(conf_id=hjqyKillBossReward, receive_id=int(player_id))
        remote_gate = GlobalObject().child('gate')
        remote_gate.push_message_to_transit_remote('receive_mail_remote',
                                                   int(player_id), mail_data)
        result = True
    #return dict(result=result, state=boss.get_state())
    logger.debug("hjqy_battle_remote over===================")
    boss.save_data()
    return result, boss.get_state(), current_damage_hp, is_kill
示例#9
0
def send_mail(conf_id, receive_id, prize):
        mail_data, _ = deal_mail(conf_id=conf_id, receive_id=int(receive_id), prize=prize)
        get_remote_gate().push_message_to_transit_remote('receive_mail_remote',
                                                   int(receive_id), mail_data)
示例#10
0
def send_mail(conf_id, receive_id, rank=0, damage=0):
        mail_data, _ = deal_mail(conf_id=conf_id, receive_id=int(receive_id), rank=rank, integral=damage)
        get_remote_gate().push_message_to_transit_remote('receive_mail_remote',
                                                   int(receive_id), mail_data)
示例#11
0
def send_mail(**args):
    mail_data, receive_id = deal_mail(**args)
    if not netforwarding.push_message('receive_mail_remote',
                                      receive_id, mail_data):
        logger.error('mail push message fail')
        traceback.print_stack()
示例#12
0
def send_mail(**args):
    mail_data, receive_id = deal_mail(**args)
    if not netforwarding.push_message('receive_mail_remote', receive_id,
                                      mail_data):
        logger.error('mail push message fail')
        traceback.print_stack()