Exemplo n.º 1
0
# coding:utf8
"""
created by sphinx on
"""
from gfirefly.dbentrust.redis_mode import RedisObject
from gfirefly.server.logobj import logger
import cPickle
import uuid

# REDIS_HOST = '127.0.0.1'
# REDIS_POST = 6379
# DB = 1
MAINTAIN_TIME = 60 * 60 * 24 * 60

_messages = RedisObject('messages')


class MessageCache:
    """
    """
    def __init__(self):
        pass

    def cache(self, key, character_id, *args, **kw):
        unique_id = uuid.uuid4()
        message_obj = _messages.getObj(character_id)
        message = cPickle.dumps(
            dict(topic_id=key,
                 character_id=character_id,
                 args=args,
                 kw=kw,
Exemplo n.º 2
0
# -*- coding:utf-8 -*-
"""
created by sphinx on
"""

from gtwisted.core import reactor
from gfirefly.server.logobj import logger
from gfirefly.server.globalobject import GlobalObject
from app.transit.root.messagecache import message_cache
from shared.db_opear.configs_data import game_configs
from gfirefly.dbentrust.redis_mode import RedisObject

tb_pvp_rank = RedisObject('tb_pvp_rank')
#from app.game.redis_mode import tb_pvp_rank
import time
import traceback
from shared.utils.mail_helper import deal_mail
from gfirefly.dbentrust.redis_mode import RedisObject
from shared.tlog import tlog_action

tb_pvp_rank = RedisObject('tb_pvp_rank')

groot = GlobalObject().root

PVP_TABLE_NAME = 'tb_pvp_rank'


def pvp_award_tick():
    tick_time = game_configs.base_config.get('arena_shorttime_points_time')
    reactor.callLater(tick_time, pvp_award_tick)
    try:
Exemplo n.º 3
0
from app.proto_file.player_response_pb2 import NewbeeGuideStepResponse, \
    ChangeHeadResponse, UpdateHightPowerResponse
from gfirefly.server.globalobject import remoteserviceHandle
from gfirefly.server.globalobject import GlobalObject
from app.game.core.item_group_helper import gain, get_return
from app.game.core.item_group_helper import consume
from app.game.core.item_group_helper import is_afford
from app.game.core.item_group_helper import get_consume_gold_num
from shared.utils.const import const
from app.game.component.character_stamina import max_of_stamina
from shared.tlog import tlog_action
from app.proto_file.game_pb2 import HeartBeatResponse, StaminaOperRequest, StaminaOperResponse
from gfirefly.dbentrust.redis_mode import RedisObject

remote_gate = GlobalObject().remote.get('gate')
tb_base_info_chat_record = RedisObject('tb_base_info:chat_record')


@remoteserviceHandle('gate')
def nickname_create_5(request_proto, player):
    argument = CreatePlayerRequest()
    argument.ParseFromString(request_proto)
    nickname = argument.nickname
    response = CommonResponse()

    # match = re.search(u'[\uD800-\uDBFF][\uDC00-\uDFFF]', nickname)
    match = re.search(u'^[a-zA-Z0-9\u4e00-\u9fa5]+$', nickname)
    if not match:
        response.result = False
        response.result_no = 868
        logger.info('not support emoji')
Exemplo n.º 4
0
# -*- coding:utf-8 -*-
"""
created by server on 14-7-31下午3:04.
"""
from gfirefly.dbentrust.redis_mode import RedisObject

# 调试开关
_DEBUG = False

# 删除缓冲
BUF_SIZE = 128
tb_rank = RedisObject('tb_rank')


class Ranking:
    _instances = {}

    def __init__(self, label, rank_len):
        self.label = label
        self.rank_len = rank_len

    @classmethod
    def instance(cls, label):
        return cls._instances[label]

    @classmethod
    def init(cls, label, rank_len):
        instance = None
        if label in cls._instances:
            instance = cls._instances[label]
Exemplo n.º 5
0
from shared.utils.mail_helper import deal_mail
from shared.utils.date_util import str_time_to_timestamp
from app.world.action.gateforwarding import push_all_object_message
from app.proto_file.notice_pb2 import NoticeResponse
from shared.utils.random_pick import random_pick_with_weight
from shared.utils.date_util import string_to_timestamp
#from shared.utils.const import const
from shared.common_logic.lucky_hero import update_lucky_hero
#from app.game.core.mail_helper import send_mail
from shared.tlog import tlog_action

def get_remote_gate():
    """docstring for get_remote_gate"""
    return GlobalObject().child('gate')

tb_boss = RedisObject('tb_worldboss')

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)

class WorldBoss(BaseBoss):
    """docstring for WorldBoss"""
    def __init__(self, boss_name, rank_instance, config_name):
        super(WorldBoss, self).__init__(boss_name, rank_instance, config_name, tb_boss)
        self._stage_id_am = 0         # 关卡id am
        self._stage_id_pm = 0         # 关卡id pm
        self._lucky_hero_start = 0         # 当前幸运武将时间
        self._lucky_hero_end = 0         # 当前幸运武将时间
        self._state = 0               # boss状态:用于boss到期, 重置状态
Exemplo n.º 6
0
# -*- coding: utf-8 -*-
"""
created by wzp.
"""
from shared.db_opear.configs_data import game_configs
from shared.utils.date_util import get_current_timestamp
from shared.utils.date_util import str_time_period_to_timestamp, is_expired
from gfirefly.server.logobj import logger
from gfirefly.dbentrust.redis_mode import RedisObject
from shared.utils.ranking import Ranking
from shared.utils.const import const
from gtwisted.core import reactor
from shared.utils.mail_helper import deal_mail
from gfirefly.server.globalobject import GlobalObject

tb_hjqyboss = RedisObject('tb_hjqyboss')
tb_hjqyboss_player = RedisObject('tb_hjqyboss_player')


class HjqyBossManager(object):
    """
    黄巾起义boss Manager
    """
    def __init__(self, _tb_hjqyboss, _tb_hjqyboss_player):
        self._bosses = {}
        self._tb_hjqyboss = _tb_hjqyboss
        self._tb_hjqyboss_player = _tb_hjqyboss_player
        self.init()

    def init(self):
        """docstring for init"""
Exemplo n.º 7
0
# -*- coding:utf-8 -*-
"""
created by server on 14-6-6上午11:12.
"""

from gfirefly.dbentrust.redis_mode import RedisObject

tb_account = RedisObject('tb_account')  # 帐号表

tb_character_info = RedisObject('tb_character_info')

# 公会信息表
tb_guild_info = RedisObject('tb_guild_info')
Exemplo n.º 8
0
# -*- coding:utf-8 -*-
"""
"""
from gfirefly.dbentrust.redis_mode import RedisObject

# 用户信息表
tb_character_info = RedisObject('tb_character_info')

tb_character_level = RedisObject('tb_character_level_match')

tb_character_ap = RedisObject('tb_character_ap')
# 公会信息表
tb_guild_info = RedisObject('tb_guild_info')
# 公会名表
tb_pvp_rank = RedisObject('tb_pvp_rank')
# mine data
tb_mine = RedisObject('tb_mine')
# 全局基础信息,目前只有世界聊天记录
tb_base_info = RedisObject('tb_base_info')

if __name__ == '__main__':
    from gfirefly.dbentrust.redis_manager import redis_manager
    import json

    mconfig = json.load(open('config.json', 'r'))
    redis_config = mconfig.get('redis').get('urls')
    redis_manager.connection_setup(redis_config)
    print 'fdsfs'
    tb_character_level.zadd(41, 1)
    tb_character_level.zadd(42, 2)
    tb_character_level.zadd(43, 3)
Exemplo n.º 9
0
#coding:utf8

import action
from gfirefly.server.logobj import logger
from app.gate.core.users_manager import UsersManager
from gtwisted.core import reactor
from gfirefly.server.globalobject import GlobalObject
from shared.utils.ranking import Ranking
from shared.tlog import tlog_action
from app.gate.redis_mode import tb_character_info
from shared.utils.const import const
import time
from gfirefly.dbentrust.redis_mode import RedisObject
tb_guild_info = RedisObject('tb_guild_info')
#from app.game.redis_mode import tb_guild_info


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

guild_incr = tb_guild_info.getObj('incr')
if not guild_incr.exists():
    guild_incr.incr(amount=10000)


def tick():
    result = GlobalObject().remote['login'].server_sync_remote(name, front_ip,
                                                               front_port,
                                                               '1',
Exemplo n.º 10
0
#coding:utf8

import action
from gfirefly.server.logobj import logger
from app.gate.core.users_manager import UsersManager
from gtwisted.core import reactor
from gfirefly.server.globalobject import GlobalObject
from shared.utils.ranking import Ranking
from shared.tlog import tlog_action
from app.gate.redis_mode import tb_character_info
from shared.utils.const import const
import time
from gfirefly.dbentrust.redis_mode import RedisObject
tb_guild_info = RedisObject('tb_guild_info')
#from app.game.redis_mode import tb_guild_info

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

guild_incr = tb_guild_info.getObj('incr')
if not guild_incr.exists():
    guild_incr.incr(amount=10000)


def tick():
    result = GlobalObject().remote['login'].server_sync_remote(
        name, front_ip, front_port, '1', server_no)
    if result is False:
        reactor.callLater(1, tick)
Exemplo n.º 11
0
# -*- coding:utf-8 -*-
"""
created by spinx on 15-11-2
"""
from gfirefly.server.globalobject import rootserviceHandle
from gfirefly.dbentrust.redis_mode import RedisObject
from gfirefly.server.logobj import logger
from shared.common_logic.mine import get_cur_data
import cPickle
import time

tb_mine = RedisObject('tb_mine')

seq_index = 1

user_mine = {}
rdobj = tb_mine.hgetall()
for k, v in rdobj.items():
    seq = int(k)
    seq_index = max(seq, seq_index)
    user_mine[seq] = v

print seq_index
print 'load mine', user_mine


@rootserviceHandle
def mine_add_field_remote(uid, data):
    """
    玩家攻占野怪矿
    @param nickname: 昵称
Exemplo n.º 12
0
"""
created by wzp.
"""
from shared.utils.ranking import Ranking
from gfirefly.dbentrust.redis_mode import RedisObject
from gfirefly.server.logobj import logger
from app.world.core.base_boss import BaseBoss
from shared.db_opear.configs_data import game_configs
from shared.utils.date_util import is_next_day
from gfirefly.server.globalobject import GlobalObject
from app.proto_file.db_pb2 import Mail_PB
import cPickle
import time


tb_boss = RedisObject('tb_mineboss')
tb_boss_manager = RedisObject('tb_minebossmanager')


class MineBossManager(object):
    """docstring for MineBoss"""
    def __init__(self):
        super(MineBossManager, self).__init__()
        # self._bosses = {}  # 所有boss
        self._boss = None  # current boss
        self._base_data_name = "mine_boss"
        self._base_demage_name = "MineBossDemage"
        self._last_time = 0
        self._boss_num = 0

        str_data = tb_boss_manager.get("")
Exemplo n.º 13
0
# -*- coding:utf-8 -*-
"""
created by server on 14-5-20下午8:33.
"""
import time
from app.chat.core.chater_manager import ChaterManager
from app.chat.service.node.chatgateservice import nodeservice_handle
from app.proto_file import chat_pb2
from app.chat.service.node.chatgateservice import noderemote
from shared.utils import trie_tree
from shared.db_opear.configs_data import game_configs
from gfirefly.dbentrust.redis_mode import RedisObject
from shared.utils.const import const
#from shared.common_logic.feature_open import is_open, CHAT

tb_character_info = RedisObject('tb_character_info')
tb_base_info = RedisObject('tb_base_info:chat_record')


@nodeservice_handle
def send_message_1002(character_id, dynamic_id, room_id, content,
                      character_nickname, to_character_id,
                      to_character_nickname, guild_id, vip_level,
                      guild_position, head):
    """发送信息
    @param character_nickname: 角色昵称
    @param to_character_id: 私聊对象角色id
    @param to_character_nickname: 私聊对象角色昵称
    @param dynamic_id: int 客户端的id
    @param character_id: int角色的id
    @param room_id: int 聊天频道
Exemplo n.º 14
0
#-*- coding:utf-8 -*-
"""
created by server on 14-5-27下午1:51.
"""
import cPickle
from gfirefly.dbentrust.redis_manager import redis_manager
from gfirefly.dbentrust.redis_mode import RedisObject

if __name__ == '__main__':
    hostname = "127.0.0.1"  #  要连接的数据库主机名
    port = 8066  #  3306 是MySQL服务使用的TCP端口号,一般默认是3306
    dbname = "db_traversing"  #  要使用的数据库库名
    charset = "utf8"  #  要使用的数据库的编码
    connection_setting = ["127.0.0.1:6379"]

    redis_manager.connection_setup(connection_setting)
    tb_base_info_db = RedisObject("tb_base_info")
    tb_base_info_db.set(1, dict(chater=1000, msg="hehe"))
    tb_base_info_db.rpush(2, dict(chater=1000, msg="hehe"))
    tb_base_info_db.rpush(2, dict(chater=1001, msg="hehe"))
    tb_base_info_db.rpush(2, dict(chater=1002, msg="hehe"))
    tb_base_info_db.lpop(2)
    tb_base_info_db.lrange(2, 0, -1)

    # tower_info = MAdmin("tb_account_mapping", "account_token")
    # print '#1:', tower_info.__dict__
    # tower_info.insert()
    # # tower_info.load()
    # MAdminManager().registe(tower_info)
    # MAdminManager().checkAdmins()
Exemplo n.º 15
0
# -*- coding: utf-8 -*-
"""
Created on 2014-11-28

@author: hack
"""
from gfirefly.dbentrust.redis_mode import RedisObject

tb_rank = RedisObject('mineopt')


class MineOpt(object):
    def __init__(self):
        pass

    @classmethod
    def add_mine(cls, uid, mid, data):
        label = 'mine.%s' % uid
        rdobj = tb_rank.getObj(label)
        rdobj.hset(mid, 1)

        label = 'mine'
        rdobj = tb_rank.getObj(label)
        rdobj.hset(mid, data)

    @classmethod
    def rem_mine(cls, mid):
        label = 'mine'
        rdobj = tb_rank.getObj(label)
        result = rdobj.hdel(mid)
        if not result:
Exemplo n.º 16
0
# -*- coding:utf-8 -*-
"""
created by server on 14-5-19上午10:31.
"""
import time
from gfirefly.dbentrust.redis_mode import RedisObject

tb_character_info = RedisObject('tb_character_info')


class Chater(object):
    """聊天成员类
    """
    def __init__(self, character_id, dynamic_id=-1, guild_id=0, name=u''):
        """初始化
        @param character_id: int 角色的id
        @param name: str 角色的名称
        @param dynamic_id: int 聊天客户端的ID
        """
        self._character_id = character_id
        self._name = name
        self._dynamic_id = dynamic_id
        self._room_id = 1  # 房间号ID
        self._island = True  # 是否在线  False表示离线,True表示在线
        self._guild_id = guild_id
        self._last_time = 1
        char_obj = tb_character_info.getObj(self._character_id)
        self._bad_words_times = char_obj.hget('say_bad_words_times', [])

    def say_bad_words_once(self):
        now_time = time.time()
Exemplo n.º 17
0
import time
from shared.utils import xtime
from gfirefly.server.logobj import logger
from shared.db_opear.configs_data import game_configs
from gfirefly.dbentrust.redis_mode import RedisObject
from gfirefly.server.globalobject import GlobalObject

PUSH_CHANNEL = GlobalObject().allconfig['push']['channel']
if PUSH_CHANNEL == 'xinge':
    logger.debug(' import xinge')
    from push_xinge import push_by_token
elif PUSH_CHANNEL == 'apns':
    logger.debug(' import apns')
    from push_apns import push_by_token

push_reg = RedisObject('pushobj.reg')
push_task = RedisObject('pushobj.push')
push_offline = RedisObject('pushobj.offline')
push_day = RedisObject('pushobj.day')


class PushMessage(object):
    def __init__(self):
        self.send_time = None
        self.message = None
        self.uid = None
        self.msg_type = None

    def can_send(self):
        now = int(time.time())
        if now > self.send_time:
Exemplo n.º 18
0
"""
from gfirefly.server.globalobject import rootserviceHandle
from gfirefly.dbentrust.redis_mode import RedisObject
from gfirefly.server.logobj import logger
import time
import cPickle
from app.world.core.guild_manager import guild_manager_obj
from shared.db_opear.configs_data import game_configs
import random
from app.world.action import mine
from shared.common_logic.shop import do_shop_buy
from shared.utils import trie_tree
from app.proto_file import guild_pb2
from shared.utils.const import const

tb_guild_info = RedisObject('tb_guild_info')
tb_character_info = RedisObject('tb_character_info')


@rootserviceHandle
def create_guild_remote(p_id, g_name, icon_id, apply_guilds):
    """
    """
    res = {}
    # 判断有没有重名
    guild_name_data = tb_guild_info.getObj('names')
    _result = guild_name_data.hget(g_name)
    if _result:
        return {'res': False}

    guild_obj = guild_manager_obj.create_guild(p_id, g_name, icon_id)
Exemplo n.º 19
0
# -*- coding:utf-8 -*-
"""
@author: cui
"""
from shared.db_opear.configs_data import game_configs
from gfirefly.server.logobj import logger
import time
from gfirefly.dbentrust.redis_mode import RedisObject

tb_guild_info = RedisObject('tb_guild_info')
from app.world.core.escort_task import EscortTask
from app.world.core.guild_boss import GuildBoss
from shared.utils.date_util import str_time_to_timestamp, get_current_timestamp
from shared.common_logic.shop import guild_shops, check_time, get_new_shop_info, \
    refresh_shop_info
from shared.utils.pyuuid import get_uuid
from shared.utils.const import const


class Guild(object):
    """公会
    """
    def __init__(self):
        """
        """
        self._name = 0                         # 名
        self._g_id = 0                         # id
        self._contribution = 0                 # 当前建设值
        self._all_contribution = 0             # 总建设值
        self._call = ''                        # 公告
        self._p_list = {}                      # 成员信息
Exemplo n.º 20
0
# -*- coding:utf-8 -*-
"""
created by spinx on 15-11-2
"""
from gfirefly.server.globalobject import rootserviceHandle
from gfirefly.dbentrust.redis_mode import RedisObject
from gfirefly.server.logobj import logger
from shared.common_logic.mine import get_cur_data
import cPickle
import time

tb_mine = RedisObject('tb_mine')

seq_index = 1

user_mine = {}
rdobj = tb_mine.hgetall()
for k, v in rdobj.items():
    seq = int(k)
    seq_index = max(seq, seq_index)
    user_mine[seq] = v

print seq_index
print 'load mine', user_mine


@rootserviceHandle
def mine_add_field_remote(uid, data):
    """
    玩家攻占野怪矿
    @param nickname: 昵称
Exemplo n.º 21
0
# -*- coding:utf-8 -*-
"""
author: cui.
"""
from gfirefly.dbentrust.redis_mode import RedisObject

# 用户信息表
# tb_character_info = RedisObject('tb_character_info')
# 公会信息表
tb_guild_info = RedisObject('tb_guild_info')
# 公会名表
tb_pvp_rank = RedisObject('tb_pvp_rank')
# mine data
# tb_mine = RedisObject('tb_mine')