当前位置: 首页>>代码示例>>Python>>正文


Python Gcore.loadCoreCfg方法代码示例

本文整理汇总了Python中sgLib.core.Gcore.loadCoreCfg方法的典型用法代码示例。如果您正苦于以下问题:Python Gcore.loadCoreCfg方法的具体用法?Python Gcore.loadCoreCfg怎么用?Python Gcore.loadCoreCfg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sgLib.core.Gcore的用法示例。


在下文中一共展示了Gcore.loadCoreCfg方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: findOutFighter

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import loadCoreCfg [as 别名]
 def findOutFighter(self,num=10,rowUser=None):
     '''跨服查找可攻城对象'''
     #print ' --- findOutFighter ---'
     try:
         if not rowUser:
             rowUser = self.getUserInfo(['UserCamp','UserLevel'])
         url =  Gcore.loadCoreCfg('PlatformUrl')
         Post = {}
         Post['ServerId'] = Gcore.getServerId()
         Post['LOCKKEY'] = TokenDecode().makeLockKey()
         Post['FUNC'] ="FindUI.FindFighter" 
         Post['PARAM'] ={
                         'FromServerId':Gcore.getServerId(),
                         'UserCamp':rowUser['UserCamp'],
                         'UserLevel':rowUser['UserLevel'],
                         'GetNum':num,
                         }
         
         url+='?MSG='+json.dumps(Post)
         #print 'findOutFighter>>',url
         req = urllib2.Request(url)
         f = urllib2.urlopen(req)
         response = f.read()
         lis = response.split('@[email protected]')
         return json.loads(lis[1])
     except:
         return []
开发者ID:fycheung,项目名称:misc,代码行数:29,代码来源:RequestMod.py

示例2: checkListenKey

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import loadCoreCfg [as 别名]
def checkListenKey(VK):
    from sgLib.core import Gcore
    SECRET_KEY = Gcore.loadCoreCfg('Encryption')
    
    mt=hashlib.md5()
    mt.update(SECRET_KEY)
    t = mt.hexdigest()
    
    mt=hashlib.md5()
    mt.update(t)
    t = mt.hexdigest()
    if VK!=t:
        print VK,t
    return VK == t
开发者ID:fycheung,项目名称:misc,代码行数:16,代码来源:pyMcrypt.py

示例3: getTokenMsg

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import loadCoreCfg [as 别名]
    def getTokenMsg(self,tokenStr=''):
        '''检查Token是否有效
        @param tokenStr: 客户端在总服登录成功的加密串
        @return: dict or False
        '''
        from sgLib.core import Gcore
        SECRET_KEY = Gcore.loadCoreCfg('Encryption')
        
        timeOut = 180 #密码有效时间
        try:
            #tokenStr='JV4vUlQXUyNsPQ5GCExEWENQISwvSQxNDkNOAEUKAh4GCWseUA5FD3YwAlUdVBt0OjtBQldPR01FNhpaAk0VejQ1T15TWz16Pj9FVVhQNn82fnUxaWFxdWkoWUlfRl4dVUE1cTIsY31gegtLDEIKHAQXbnk6Jm16cn0fcjx1NEYFS25tdm10ZHljGg8eDRRP'
            tokenStr = base64.b64decode(tokenStr) #base64从decode encode中抽离
            tokenStr = decode(tokenStr,SECRET_KEY)
            #print 'tokenStr',tokenStr
            tokenDic = json.loads(tokenStr)
            #print 'tokenDic',tokenDic
            
            #PHPcode: $s_LockKey = md5( substr( md5($i_LockTime.$Encryptionkey), 1, 18 ).$Encryptionkey );
            #tokenDic: {u'TotalServiceId': u'42', u'LoginMode': 2, u'PlayerId': 0, u'LoginVersion': 101, u'Lan': 1, u'LockTime': 1367994093, u'LockKey': u'6b11732eb74eb4e8791afdb02096b6a1'}
            LockTime = str(tokenDic['LockTime'])
            mt=hashlib.md5()
            mt.update(LockTime)
            mt.update(SECRET_KEY)
            OutKey=mt.hexdigest()
            mt=hashlib.md5()
            mt.update(OutKey[1:19]) #substr(1,18)
            mt.update(SECRET_KEY)
            OutKey=mt.hexdigest()
#            print 'OutKey',OutKey
#            print 'LockKey',tokenDic['LockKey']
            #if (int(time.time())-int(LockTime))>timeOut: #分服登录-过期后重启去总服登录#@todo
            #    return False
            
            if OutKey==tokenDic['LockKey']:
                tokenDic.pop('LockKey')
                return tokenDic
            else:
                return False
        except:
            return False
        
        print tokenDic
开发者ID:fycheung,项目名称:misc,代码行数:44,代码来源:pyMcrypt.py

示例4: CreatedPlayer

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import loadCoreCfg [as 别名]
 def CreatedPlayer(self,accountId):
     try:
         url =  Gcore.loadCoreCfg('PlatformUrl')
         Post = {}
         Post['ServerId'] = Gcore.getServerId()
         Post['LOCKKEY'] = TokenDecode().makeLockKey()
         Post['FUNC'] ="FindUI.CreatedPlayer" 
         Post['PARAM'] ={
                         'FromServerId':Gcore.getServerId(),
                         'AccountId':accountId,
                         }
         
         url+='?MSG='+json.dumps(Post)
         #print 'findOutFighter>>',url
         req = urllib2.Request(url)
         f = urllib2.urlopen(req)
         response = f.read()
         lis = response.split('@[email protected]')
         return json.loads(lis[1])
     except:
         pass
开发者ID:fycheung,项目名称:misc,代码行数:23,代码来源:RequestMod.py

示例5: makeLockKey

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import loadCoreCfg [as 别名]
 def makeLockKey(self):
     '''组成服务器通讯加密串'''
     
     from sgLib.core import Gcore
     SECRET_KEY = Gcore.loadCoreCfg('Encryption')
     
     import time
     LockTime = int(time.time())
     LockTime = str(LockTime)
     mt=hashlib.md5()
     mt.update(LockTime)
     mt.update(SECRET_KEY)
     OutKey=mt.hexdigest()
     mt=hashlib.md5()
     mt.update(OutKey) #substr(1,18)
     mt.update(SECRET_KEY)
     OutKey=mt.hexdigest()
         
     d =  {}
     d['TokenLockTime'] = LockTime
     d['Tokenkey'] = OutKey
     return d
开发者ID:fycheung,项目名称:misc,代码行数:24,代码来源:pyMcrypt.py

示例6: findPvcTarget

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import loadCoreCfg [as 别名]
    def findPvcTarget(self):
        '''查找攻城对象  @note:硬凑在这里'''
        CrossServer = int(Gcore.loadCoreCfg('CrossServer')) #是否跨服的配置
        print ' -- ps findPvcTarget CrossServer:%s'%CrossServer
        
        N=200 #匹配参考值
        Num = 20 #每次拿10个
        if Gcore.TEST:
            Num = 100
        rowUser = self.getUserInfo(['UserCamp','UserLevel'])
        UserLevel = rowUser['UserLevel']
        UserCamp = rowUser['UserCamp']
        UserLevelFrom = UserLevel-30;
        UserLevelTo = UserLevel+30;
        ServerId = Gcore.getServerId()
        homeList1 = []
        homeList2 = []
        if(UserCamp==1):
            query = " (UserCamp=2 OR UserCamp=3)"
        elif(UserCamp==2):
            query = " (UserCamp=1 OR UserCamp=3)"
        elif(UserCamp==3):
            query = " (UserCamp=1 OR UserCamp=2)"
        
        query+= " AND UserLevel>=%s"%Gcore.loadCfg(9301).get('FightLevel')
        query+= " AND UserId!=%s"%self.uid
        query+= " AND Online=0 AND ProtectEndTime <= UNIX_TIMESTAMP()";
        where = query+' AND UserLevel>=%s AND UserLevel<=%s'%(UserLevelFrom,UserLevelTo)
        M = self.db.count('tb_user',where)
        
        UserLevelFrom2 = UserLevel-5;
        UserLevelTo2 = UserLevel+5;
        where = query+' AND UserLevel>=%s AND UserLevel<=%s'%(UserLevelFrom2,UserLevelTo2)
        for unit in  self.db.out_rand('tb_user','UserId',where,Num):
            homeList1.append([ServerId,unit['UserId']])
            
        print 'findPvcTarget local +-5 > ',self.db.sql
        
        where = query+' AND (UserLevel>=%s AND UserLevel<%s) OR (UserLevel>%s AND UserLevel<=%s)'\
        %(UserLevelFrom,UserLevelFrom2,UserLevelTo2,UserLevelTo)
        for unit in  self.db.out_rand('tb_user','UserId',where,Num):
            homeList2.append([ServerId,unit['UserId']])
            
        print 'findPvcTarget local +-30 > ',self.db.sql
        #print 'homeList1',homeList1
        #print 'homeList2',homeList2
        random.shuffle(homeList1)
        random.shuffle(homeList2)
        
        if M>=N:#不跨服
            crossPercent = 0 #跨服比例
        elif M<=20:
            crossPercent = 100
        elif M>=0.75*N: 
            crossPercent = 25
        elif M>=0.5*N: 
            crossPercent = 50
        elif M>=0.25*N: 
            crossPercent = 75
        else:
            crossPercent = 100

        #print 'crossPercent',crossPercent
        targetList = []
        randPercent = random.randint(1,100)
        #print 'randPercent',randPercent
        
        if randPercent<=crossPercent and CrossServer: #中比例
            y=math.ceil(M/N*Num)
            getNum = Num-y
#            print 'M',M
#            print 'N',N
#            print 'getNum',getNum
            targetList =  Gcore.getMod('Request', self.uid).findOutFighter(getNum,rowUser)
            print 'Request targetList',targetList
        
        #print targetList
        for i in xrange(Num-len(targetList)):
            if len(homeList1)>i:
                targetList.append(homeList1[i])
                if len(targetList)>=Num:
                    break;
            if len(homeList2)>i:
                targetList.append(homeList2[i])
                if len(targetList)>=Num:
                    break;
        #print 'targetList',targetList
        return targetList
开发者ID:fycheung,项目名称:misc,代码行数:90,代码来源:WarMod.py

示例7: PlayerInfo

# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import loadCoreCfg [as 别名]
 def PlayerInfo(self):
     '''返回获取用户相关资料'''
     startTime = time.time()
         
     fields = ['UserHonour','UserCamp','NickName','VipLevel','BuyMapTimes', 'WorkerNumber',
               'UserIcon','UserExp','UserLevel','Fighter','FightEndTime','ProtectEndTime','BindAccount','LoginTimes',
               'HolderServerId','HolderId','HoldEndTime', #我是否有藩国,藩国结束时间
               ]
     
     userProfile = self.getUserProfile()
     
     data = self.getUserBaseInfo(fields)
     data['UserId'] = self.uid
     data['ServerId'] = Gcore.getServerId() #服务器ID
     data['SuserId']= '%s.%s'%(Gcore.getServerId(),self.uid) #服务器ID跟角色ID组成的标志串
     #data['Worker'] =  self.getUserWorker()
     #@todo 添加更多主角信息
     if Gcore.common.nowtime()>=data['FightEndTime']:
         FightRestTime = 0
     else:
         FightRestTime = data['FightEndTime'] - Gcore.common.nowtime()
     
     data['FightRestTime'] = FightRestTime #被攻打剩余时间   Fighter - 正在被谁攻打
     data.pop('FightEndTime')
     
     buildingCfg = Gcore.loadCfg(CFG_BUILDING)
     data['InitJcoin'] = buildingCfg['InitJcoin']
     data['InitGcoin'] =  buildingCfg['InitGcoin']
     
     data['Coin'] = self.getUserCoin()
     data['ServerTime'] = time.time() #round(time.time(),2)
     data['SoldierLevel'] = Gcore.getMod('Book',self.uid).getTechsLevel(1)
     data['SoldierInfo'] = Gcore.getMod('Building_camp', self.uid).TouchAllSoldiers()
     data['Equipments'] = Gcore.getMod('Equip', self.uid).getAllValidEquip()
     data['Factor'] = { #全部系数
                           'kLeader': Gcore.loadCfg(Gcore.defined.CFG_BATTLE)["kLeaderAddNum"] , #统帅系数 @todo 从配置中读取
                           }
     data['Exchange'] = Gcore.loadCfg( Gcore.defined.CFG_ITEM ).get('exchange') #货币兑换比例
     #data['Timezone'] = Gcore.config.CFG_TIMEZONE #时区
     #data['TimezoneDif'] = Gcore.config.CFG_TIMEZONEDIF #格林时间+CFG_TIMEDIF
     
     data['Timezone'] = Gcore.loadCoreCfg('Timezone') #时区
     data['TimezoneDif'] = int( Gcore.loadCoreCfg('TimezoneDif') ) #格林时间+CFG_TIMEDIF
     
     data['PVPstartTime'] = Gcore.loadCfg( Gcore.defined.CFG_PVP ).get('PVPstartTime') #将弃用
     data['PVPendTime'] = Gcore.loadCfg( Gcore.defined.CFG_PVP ).get('PVPendTime')     #将弃用
     data['PvpTime'] = Gcore.loadCfg( Gcore.defined.CFG_PVP ).get('PvpTime')
     
     #军团信息
     clubInfo = Gcore.getMod('Building_club', self.uid).getMemberInfoByUID(self.uid,['ClubId','DevoteCurrent'])#军团ID 
     data['ClubId'] = clubInfo.get('ClubId',0)
     data['ClubDvo'] = clubInfo.get('DevoteCurrent',0)
     data['ClubBox'] = Gcore.loadCfg(Gcore.defined.CFG_BUILDING_CLUB).get('BoxCost')
     
     #装备传承花费 
     data['DivertCost'] = Gcore.loadCfg(Gcore.defined.CFG_EQUIP).get('DivertCost')
     data['DivertCostType'] = Gcore.loadCfg(Gcore.defined.CFG_EQUIP).get('DivertCostType')
     
     data['Inters'] = Gcore.getMod('Building_home', self.uid).getInters() #内政
     
     #获取场景14001 MapUI.getScene()搬过来的
     BuildingInfo = Gcore.getMod('Building',self.uid).getAllBuildingCoord()
     interactGids=Gcore.getMod('Interact',self.uid).getHaveMcoinGeneralIds()#获取有交流记录的武将ID Add by Yew
     data['Scene'] = {'BuildingInfo':BuildingInfo,'BuyMapInfo':[],'InteractGids':interactGids}
     
     #获取武将信息15013 Building_trainUI.GetGenerals()搬过来
     Generals = Gcore.getMod('General', self.uid).getLatestGeneralInfo()
     data['Generals'] = Generals if Generals else []
     
     #VIP折扣
     data['VipDiscount'] = {r['VipLevel']:r['Discount'] for r in Gcore.getCfg('tb_cfg_vip_up').values()}
     data['MaxWorkerNum'] = Gcore.loadCfg(Gcore.defined.CFG_BUILDING).get('MaxWorkerNum',5)
     
     #攻城等级
     data['FightLevel'] = Gcore.loadCfg(9301).get('FightLevel')
     
     #是否首次登录
     data['FirstLogin'] = 0 if data.pop('LoginTimes') else 1
     
     #军师和指引进度
     data['ArmyAdviserId'] = userProfile.get('ArmyAdviserId',0)
     data['GuideProcessId'] = userProfile.get('GuideProcessId',0)
     
     #进贡百分比
     data['GiveRatio'] = Gcore.loadCfg(1506).get('GiveRatio',0.05)
     
     #完成任务数量
     data['MissionFinish'] = Gcore.getMod('Mission',self.uid).getMissionFinishNum()
     
     #官网
     data['Website'] = Gcore.loadCoreCfg('Website')
     
     #心跳时间
     data['HeartBeatInterval'] = Gcore.config.HEARTBEAT_TIME
     
     
     #结束-----------------------------------
     runtime = time.time() - startTime
     if Gcore.IsServer: #调试计时
         row = {
#.........这里部分代码省略.........
开发者ID:fycheung,项目名称:misc,代码行数:103,代码来源:PlayerMod.py


注:本文中的sgLib.core.Gcore.loadCoreCfg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。