Ejemplo 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)
Ejemplo 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)
Ejemplo n.º 3
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
Ejemplo 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
Ejemplo n.º 5
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
Ejemplo 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")
Ejemplo n.º 7
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")
Ejemplo 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)
Ejemplo n.º 9
0
from app.game.redis_mode import tb_character_info
from shared.utils.ranking import Ranking


def doWhenStop():
    """服务器关闭前的处理
    """
    print "##############################"
    print "##########checkAdmins#############"
    print "##############################"
    MAdminManager().checkAdmins()


GlobalObject().stophandler = doWhenStop

Ranking.init('GuildLevel', 9999)
Ranking.init('LevelRank1', 99999)
Ranking.init('LevelRank2', 99999)
Ranking.init('PowerRank1', 99999)
Ranking.init('PowerRank2', 99999)
Ranking.init('StarRank1', 99999)
Ranking.init('StarRank2', 99999)
Ranking.init('LimitHeroRank', 99999)

if game_configs.base_config.get('initial') and GlobalObject().json_config.get(
        "name") == u"game":
    character_obj = tb_character_info.getObj(999)
    if not character_obj.exists():
        character_obj = tb_character_info.getObj(9199)
        #print("999======", character_obj.exists())
        print(GlobalObject().json_config.get("name"),
Ejemplo n.º 10
0
def add_guild_to_rank_remote(g_id, dengji):
    level_instance = Ranking.instance('GuildLevel')
    level_instance.add(g_id, dengji)  # 添加rank数据
Ejemplo n.º 11
0
def get_guild_rank_remote():
    level_instance = Ranking.instance('GuildLevel')
    data = level_instance.get(1, 9999)  # 获取排行最高的公会列表(999条)
    return data
Ejemplo n.º 12
0
#coding:utf8

import action
from gfirefly.server.logobj import logger
from gtwisted.core import reactor
from gfirefly.server.globalobject import GlobalObject
from shared.utils.ranking import Ranking

front_ip = GlobalObject().json_config['front_ip']
front_port = GlobalObject().json_config['front_port']
name = GlobalObject().json_config['name']


def tick():
    result = GlobalObject().remote['login'].server_sync_remote(
        name, front_ip, front_port, 'recommend')
    if result is False:
        reactor.callLater(1, tick)
    else:
        reactor.callLater(60, tick)


reactor.callLater(1, tick)
# 初始化工会排行
Ranking.init('GuildLevel', 9999)
Ejemplo n.º 13
0
def add_rank_info(rank_name, key, value):
    instance = Ranking.instance(rank_name)
    instance.add(key, value)  # 添加rank数据
Ejemplo n.º 14
0
def clear_rank():
    instance = Ranking.instance('LimitHeroRank')
    instance.clear_rank()
Ejemplo n.º 15
0
# -*- coding:utf-8 -*-
"""
created by server on 14-11-9下午5:11.
"""
from shared.utils.ranking import Ranking

Ranking.init("WorldBossDemage", 10)
Ranking.init("HjqyBossDamage", 10)
Ejemplo n.º 16
0
# -*- coding:utf-8 -*-
"""
created by server on 14-11-9下午5:11.
"""
from shared.utils.ranking import Ranking

Ranking.init("WorldBossDemage", 10)
Ejemplo n.º 17
0
# -*- coding:utf-8 -*-
"""
created by server on 14-11-9下午5:11.
"""
import action
from shared.time_event_manager.te_manager import te_manager
from shared.utils.ranking import Ranking
import time
from gtwisted.core import reactor
from app.world.core.rank_helper import tick_rank, do_tick_rank
from app.world.core.limit_hero import tick_limit_hero
from app.world.core.hjqy_boss import hjqy_manager


# 初始化工会排行
Ranking.init('LevelRank1', 99999)
Ranking.init('LevelRank2', 99999)
Ranking.init('PowerRank1', 99999)
Ranking.init('PowerRank2', 99999)
Ranking.init('StarRank1', 99999)
Ranking.init('StarRank2', 99999)
Ranking.init('LimitHeroRank', 99999)


# do_tick_rank()
te_manager.add_event(24*60*60, 2, do_tick_rank)


te_manager.add_event(24*60*60, 2, hjqy_manager.send_rank_reward_mails)

tick_limit_hero()
Ejemplo n.º 18
0
def get_rank_by_key(rank_name, key):
    instance = Ranking.instance(rank_name)
    return instance.get_rank_no(key)  # 添加rank数据
Ejemplo n.º 19
0
def clear_rank():
    instance = Ranking.instance('LimitHeroRank')
    instance.clear_rank()
Ejemplo n.º 20
0
def get_rank(rank_name, first_no, last_no):
    instance = Ranking.instance(rank_name)
    return instance.get(first_no, last_no)  # 获取排行最高的列表(9999条)
Ejemplo n.º 21
0
 def get_rank_instance(self):
     return Ranking.instance("WorldBossDemage")
Ejemplo n.º 22
0
def get_value(rank_name, key):
    instance = Ranking.instance(rank_name)
    return instance.get_value(key)  # 获取排行最高的列表(9999条)
Ejemplo n.º 23
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")
Ejemplo n.º 24
0
def remove_rank(rank_name, key):
    instance = Ranking.instance(rank_name)
    instance.remove(key)  # 删除rank数据