Esempio n. 1
0
def do_tick_rank():
    if flag_doublu_day():
        level_rank_name = 'LevelRank2'
        power_rank_name = 'PowerRank2'
        star_rank_name = 'StarRank2'
    else:
        level_rank_name = 'LevelRank1'
        power_rank_name = 'PowerRank1'
        star_rank_name = 'StarRank1'

    users = tb_character_info.smem('all')

    instance = Ranking.instance(level_rank_name)
    add_level_rank_info(instance, users)

    instance = Ranking.instance(power_rank_name)
    add_power_rank_info(instance, users)

    instance = Ranking.instance(star_rank_name)
    add_star_rank_info(instance, users)

    for uid in users:
        char_obj = tb_character_info.getObj(uid)
        pvp_unit = char_obj.hget('copy_units')
        char_obj.hset('copy_units2', pvp_unit)
Esempio n. 2
0
def do_tick_rank():
    if flag_doublu_day():
        level_rank_name = 'LevelRank2'
        power_rank_name = 'PowerRank2'
        star_rank_name = 'StarRank2'
    else:
        level_rank_name = 'LevelRank1'
        power_rank_name = 'PowerRank1'
        star_rank_name = 'StarRank1'

    users = tb_character_info.smem('all')

    instance = Ranking.instance(level_rank_name)
    add_level_rank_info(instance, users)

    instance = Ranking.instance(power_rank_name)
    add_power_rank_info(instance, users)

    instance = Ranking.instance(star_rank_name)
    add_star_rank_info(instance, users)

    for uid in users:
        char_obj = tb_character_info.getObj(uid)
        pvp_unit = char_obj.hget('copy_units')
        char_obj.hset('copy_units2', pvp_unit)
Esempio n. 3
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
Esempio n. 4
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
Esempio n. 5
0
 def init(self):
     """docstring for init"""
     boss_data = self._tb_hjqyboss.hgetall()
     logger.debug("init hjqy data")
     logger.debug(boss_data)
     for boss_id, data in boss_data.items():
         boss_id = int(boss_id)
         boss = HjqyBoss(boss_id)
         boss.init_data(data)
         self._bosses[boss_id] = boss
     self._rank_instance = Ranking.instance("HjqyBossDamage")
Esempio n. 6
0
 def init(self):
     """docstring for init"""
     boss_data = self._tb_hjqyboss.hgetall()
     logger.debug("init hjqy data")
     logger.debug(boss_data)
     for boss_id, data in boss_data.items():
         boss_id = int(boss_id)
         boss = HjqyBoss(boss_id)
         boss.init_data(data)
         self._bosses[boss_id] = boss
     self._rank_instance = Ranking.instance("HjqyBossDamage")
Esempio n. 7
0
 def add(self):
     """docstring for add"""
     boss_name, boss_demage_name = self.get_boss_name()
     Ranking.init(boss_demage_name, 10)
     boss = MineBoss(boss_name, Ranking.instance(boss_demage_name),
                     "mine_boss_stages")
     self._boss = boss
     current_time = time.time()
     self._last_time = current_time
     self._boss_num += 1
     self.save_data()
     return "boss_id", boss
Esempio n. 8
0
    def add_rank_item(self, player_info):
        """
        每次战斗结束, 添加排名
        """
        player_id = player_info.get("player_id")

        instance = Ranking.instance("WorldBossDemage")
        instance.incr_value(player_id, player_info.get("demage_hp"))

        # 如果玩家信息在前十名,保存玩家信息到redis
        rank_no = instance.get_rank_no(player_id)
        if rank_no > 10: return
        str_player_info = cPickle.dumps(player_info)
        redis_client.set(player_id, str_player_info)
Esempio n. 9
0
def clear_rank():
    instance = Ranking.instance('LimitHeroRank')
    instance.clear_rank()
Esempio n. 10
0
def get_rank(rank_name, first_no, last_no):
    instance = Ranking.instance(rank_name)
    return instance.get(first_no, last_no)  # 获取排行最高的列表(9999条)
Esempio n. 11
0
def add_rank_info(rank_name, key, value):
    instance = Ranking.instance(rank_name)
    instance.add(key, value)  # 添加rank数据
Esempio n. 12
0
def clear_rank():
    instance = Ranking.instance('LimitHeroRank')
    instance.clear_rank()
Esempio n. 13
0
def add_guild_to_rank_remote(g_id, dengji):
    level_instance = Ranking.instance('GuildLevel')
    level_instance.add(g_id, dengji)  # 添加rank数据
Esempio n. 14
0
def get_guild_rank_remote():
    level_instance = Ranking.instance('GuildLevel')
    data = level_instance.get(1, 9999)  # 获取排行最高的公会列表(999条)
    return data
Esempio n. 15
0
def remove_rank(rank_name, key):
    instance = Ranking.instance(rank_name)
    instance.remove(key)  # 删除rank数据
Esempio n. 16
0
def get_rank_by_key(rank_name, key):
    instance = Ranking.instance(rank_name)
    return instance.get_rank_no(key)  # 添加rank数据
Esempio n. 17
0
 def get_rank_instance(self):
     return Ranking.instance("WorldBossDemage")
Esempio n. 18
0
        if kill_or_not:  # 如果boss被击杀,则升级boss
            logger.debug("kill boss =============")
            if current_stage_id == self._stage_id_am: # am
                self._stage_id_am = current_stage_id + 100
            else:  # pm
                self._stage_id_pm = current_stage_id + 100

        if current_stage_id == origin_stage_id_am:
            self._stage_id = self._stage_id_pm
        else:
            self._stage_id = self._stage_id_am

        logger.debug("current_stage_id3%s" % self._stage_id)
        logger.debug("current_stage_id_am%s" % self._stage_id_am)
        logger.debug("current_stage_id_pm%s" % self._stage_id_pm)

    def get_stage_period(self, stage_id):
        """docstring for get_am_period"""
        stage_info = self.get_stage_info(stage_id)
        time_start, time_end = str_time_period_to_timestamp(stage_info.timeControl)
        return time_start, time_end

    @property
    def open_or_not(self):
        return self.in_the_time_period()


world_boss = WorldBoss("world_boss",
                       Ranking.instance("WorldBossDemage"),
                       "world_boss_stages")
Esempio n. 19
0
def get_value(rank_name, key):
    instance = Ranking.instance(rank_name)
    return instance.get_value(key)  # 获取排行最高的列表(9999条)