本文整理汇总了Python中sgLib.core.Gcore.getUserData方法的典型用法代码示例。如果您正苦于以下问题:Python Gcore.getUserData方法的具体用法?Python Gcore.getUserData怎么用?Python Gcore.getUserData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sgLib.core.Gcore
的用法示例。
在下文中一共展示了Gcore.getUserData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def test(self,p={}):
'''测试获取当前缓存的用户信息'''
optId = 99001
Gcore.getUserData(1001, 'UserLevel')
body = { 'Gcore.StorageUser': str(Gcore.StorageUser) }
print 'body',body
return Gcore.out(optId,body)
示例2: gainDeveote
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def gainDeveote(self,clubId,gainWay,**p):
'''
:获得贡献
@param clubId:
@param gainWay:获得方式 1贡献 3抽奖
@param p:if gainWay==1: p{coinValue,coinType}
elif gainWay==3: p{devoteNum}
'''
if not clubId:
return 0
devoteNum = p.get('devoteNum',0)
record = {'ClubId':clubId,'UserId':self.uid,
'UserType':Gcore.getUserData(self.uid,'UserType'),
'ActionType':gainWay,'DevoteNum':devoteNum,
'CreateTime':time.time()}
if gainWay==1:#贡献获得
coinType = p['coinType']
coinValue = p['coinValue']
devoteBase = Gcore.loadCfg(defined.CFG_BUILDING_CLUB).get('ClubGiveBase').get( str(coinType))
devoteNum = coinValue/devoteBase
record['DevoteNum'] = devoteNum
record['DevoteCoinType'] = coinType
record['DevoteCoinValue'] = coinValue
sql = 'UPDATE tb_club_member \
SET DevoteCurrent=DevoteCurrent+%s,\
DevoteTotal=DevoteTotal+%s \
WHERE UserId=%s AND ClubId=%s'%(devoteNum,devoteNum,self.uid,clubId)
if self.db.execute(sql):
self.db.insert('tb_log_club_devote',record)
return devoteNum
else:
0
示例3: login
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def login(self,loginIp=None,loginMode=None):
'''登入时调用的方法'''
now = time.time()
sql = "UPDATE tb_user SET LastLoginTime=UNIX_TIMESTAMP(),Online=1,LoginTimes=LoginTimes+1 WHERE UserId=%s"%self.uid
self.db.execute(sql)
#if not self.uid in Gcore.StorageUser: #缓存基础用户信息
if 1: # fixed by zhoujingjiang
self.cacheUserData(self.uid)
UserType = Gcore.getUserData(self.uid,'UserType')
#添加登录日志
# loginLogTB = 'tb_log_login201306'
loginLogTB = self.tb_log_login()
data = {'UserId':self.uid,'LoginTime':now,'UserType':UserType,
'LoginModel':loginMode,'LoginIP':loginIp}
self.logId = self.db.insert(loginLogTB,data)
print self.uid,'login get logId:%s at %s'%(self.logId,now)
key = Gcore.redisKey(self.uid)
Gcore.redisM.hset('sgLogin',key,'1')
UserLevel = self.getUserLevel()
modActivity=Gcore.getMod('Activity',self.uid)
modActivity.signin(0,'')
if UserLevel>=Gcore.loadCfg(9301).get('FightLevel'):
row = {}
row['Online']=1
row['UserId']=self.uid
示例4: addUserExp
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def addUserExp(self,getWay,amount=0,optId=0):
'''
:增加主角经验(动作触发)
@param getWay: 用户获得经验方式0:直接加经验,1-99:消耗加经验 101-199: 事件加经验
@param amount: if getWay==0:amount='增加的经验值';elif 1<1getWay<99:amount='消耗货币量';
@return: 返回主角经验等级,当前经验
'''
expCfg = Gcore.getCfg('tb_cfg_exp_get',getWay)
fields = ['UserLevel','UserExp']
userInfo = self.db.out_fields('tb_user',fields,'UserId=%s'%self.uid)
userLevel = userInfo['UserLevel']
userExp = userInfo['UserExp']
getExp = 0
if expCfg:#动作增加经验方式
segment = getWay/100#判断是消耗还是事件
if segment==0:#消耗
factor1 = expCfg.get('Factor1',0)
factor2 = expCfg.get('Factor2',0)
getExp = int(factor1*amount+factor2*userLevel)
elif segment==1 and self._getLimitOfEvent(getWay):#事件
baseExp = expCfg.get('BaseExp',0)
getExp = int(baseExp*(userLevel+1)*(1+userLevel/200.0)+1)
elif getWay==0:#直接加经验
getExp=amount
#增加经验,同时更新等级
if getExp>0:
updateExp = self._calUserLevel(userLevel, userExp+getExp)
self.db.update('tb_user',updateExp,'UserId=%s'%self.uid)
newLevel = updateExp.get('UserLevel')
#获得经验记录
logData = {'UserId':self.uid,'GetWay':getWay,'OptId':optId,
'UserType':Gcore.getUserData(self.uid,'UserType'),
'UserLevel':newLevel,'ExpValue':getExp,'CreateTime':time.time()}
self.db.insert('tb_log_exp',logData,isdelay=True)
#主角升级
if newLevel>userLevel:
#升级推送
Gcore.push(108,self.uid,{'UserLevel':newLevel})
mMod = Gcore.getMod('Mission',self.uid)
mMod.getNewMission(userLevel=newLevel)#用户升级查看有没有新任务
Gcore.setUserData(self.uid, {'UserLevel':newLevel}) #更新缓存中的用户等级 Lizr
Gcore.getMod('General',self.uid).touchGeneralLv(newLevel)
Gcore.getMod('War',self.uid).touchActPoint(userLevel,newLevel) #更新行动力
modActivity=Gcore.getMod('Activity',self.uid)#报错
modActivity.growUpAward(newLevel, userLevel)#成长奖励活动Yew
if newLevel >= Gcore.loadCfg(Gcore.defined.CFG_RANK_FIGHT).get('RankFightOpenLevel',20):
Gcore.getMod('RankFight',self.uid).joinRankFight() #每次升级都尝试加入排行榜 防止有漏
return updateExp
else:
return userInfo
示例5: RankFightInfo
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def RankFightInfo(self,para={}):
'''比武主界面 和 排名奖励界面 所需数据'''
optId = 24001
UserLevel = Gcore.getUserData(self.uid,'UserLevel')
OpenLevel = Gcore.loadCfg(2401).get('RankFightOpenLevel')
if UserLevel<OpenLevel:
return Gcore.error(optId,-24001001)
RankFightInfo = self.mod.getRankFightInfo()
RankReward = self.mod.getRankReward()
return Gcore.out(optId,{'RankFightInfo':RankFightInfo,'RankReward':RankReward})
示例6: insertBoxLog
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def insertBoxLog(self,clubId,boxType,data):
'''
:插入宝箱开奖记录
@param data:宝箱数据
'''
logData = {'ClubId':clubId,'UserId':self.uid,
'UserType':Gcore.getUserData(self.uid,'UserType'),
'BoxType':boxType,'RewardType':data['RewardType'],
'GoodsId':data['GoodsId'],'GoodsNum':data['GoodsNum'],
'CreateTime':time.time()}
return self.db.insert('tb_log_club_box',logData)
示例7: addTrainRecord
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def addTrainRecord(self,gt,tt):
'''
:武将训练记录
@param gt:武将类型
@param tt:训练类型
#By Zhanggh 2013-5-29
'''
data = {'UserId':self.uid,'GeneralType':gt,
'UserType':Gcore.getUserData(self.uid,'UserType'),
'TrainType':tt,'CreateTime':time.time()}
self.db.insert('tb_log_general_train',data,isdelay=True)
示例8: _getAchieveCache
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def _getAchieveCache(self,action=''):
'''获取成就缓存'''
activeAchieve = Gcore.getUserData(self.uid, 'ActiveAchieve')#缓存活跃成就
if (activeAchieve is None) or (not isinstance(activeAchieve,list or tuple)):
myLog = Gcore.getLogger('zhanggh','achieve')
myLog.error("成就缓存有异常,UserId:%s,动作:%s,用户缓存内容:"%(self.uid,action))
myLog.error( Gcore.StorageUser.get(self.uid))
activeAchieve = self.getAchievements()
activeAchieve = [k for k in activeAchieve if activeAchieve[k]['Finished']==0]
Gcore.setUserData(self.uid,{'ActiveAchieve':activeAchieve})
return activeAchieve
示例9: _getMissionCache
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def _getMissionCache(self,action=''):
'''获取任务缓存'''
activeMission = Gcore.getUserData(self.uid,'ActiveMission')#缓存查询
if (activeMission is None) or (not isinstance(activeMission,dict)):
myLog = Gcore.getLogger('zhanggh','mission')
myLog.error("任务缓存有异常,UserId:%s,动作:%s,用户缓存内容:"%(self.uid,action))
myLog.error( Gcore.StorageUser.get(self.uid))
activeMission = self.db.out_rows('tb_mission',['MissionId','GetValue'],'UserId=%s AND Status in (1,2)'%self.uid)
activeMission = {k['MissionId']:k for k in activeMission}
Gcore.setUserData(self.uid,{'ActiveMission':activeMission})
return activeMission
示例10: makeRankLog
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def makeRankLog(self,OpUserId,FightResult,MyRankId):
'''制造日志
OpUserId: 对手用户ID
FightResult : 战斗结果
MyRankId: 我的排名
OpRankId: 对方的排名
'''
if FightResult:
ToRankId = self.db.out_field('tb_rank_fight','RankId','UserId=%s'%self.uid)
else:
ToRankId = MyRankId
d = {
'UserId':self.uid,
'NickName':Gcore.getUserData(self.uid,'NickName'),
'OpUserId':OpUserId,
'OpNickName':Gcore.getUserData(OpUserId,'NickName'),
'FightResult':FightResult,
'FromRankId':MyRankId,
'ToRankId':ToRankId,
'CreateTime':Gcore.common.nowtime(),
}
self.db.insert('tb_rank_fight_log',d)
示例11: insertItemLog
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def insertItemLog(self, optId, itemId, itemNum, action):
'''
@param optId:
@param itemId:
@param itemNum:
@param action:1为产出,2为消耗
'''
now = Gcore.common.nowtime()
row = {'UserId': self.uid,
'UserType': Gcore.getUserData(self.uid,'UserType'),
'Action': action,
'ItemId': itemId,
'Num': itemNum,
'OptId': optId,
'CreateTime': now
}
self.db.insert('tb_log_item', row, isdelay = False)
示例12: _GetNextPay
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def _GetNextPay(self,AltarType,TimeStamp):
AltarConfig = Gcore.loadCfg(CFG_BUILDING_ALTAR)
AlreadyLotteryCnt = self.GetLotteryCnt({'AltarType':AltarType, 'ClientTime':TimeStamp})
AlreadyLotteryCnt = AlreadyLotteryCnt.get('body', {}).get('LotteryCount', -1)
if AltarType==2:
NextCostType = AltarConfig['LandCoinType']
NextCost = AltarConfig['LandTimesCost']
else:
NextCostType = AltarConfig['SkyCoinType']
NextCost = min(AltarConfig['SkyTimesCost'] * (AlreadyLotteryCnt + 1),50)
#打折
vipLevel = Gcore.getUserData(self.uid, 'VipLevel')
discount = Gcore.getCfg('tb_cfg_vip_up',vipLevel,'Discount')
discount = discount if discount else 1
NextCost = math.ceil(NextCost*discount)
NextLoterryPay={'NextCostType':NextCostType,'NextCost':NextCost}
return NextLoterryPay
示例13: _getRank
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def _getRank(self,UserId=None):
'''获取我的排名记录相关信息,一条'''
if not UserId:
UserId = self.uid
row = self.db.out_fields('tb_rank_fight','*','UserId=%s'%UserId)
#-------------- 特殊情况处理:超过等级 但未入排名 -------------
if not row:
UserLevel = Gcore.getUserData(UserId,'UserLevel')
OpenLevel = Gcore.loadCfg(2401).get('RankFightOpenLevel')
if UserLevel >= OpenLevel:
self.db.insert('tb_rank_fight',{'UserId':UserId})
row = self.db.out_fields('tb_rank_fight','*','UserId=%s'%UserId)
#----------------------------------------------------------
if row['LastFightTime'] < common.today0time(): #上一次是昨天
row['TodayFightTimes'] = 0
return row
示例14: warSweepNew
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def warSweepNew(self,warId,SweepTimes):
'''扫荡'''
result = {}
UserData = self.getUserInfo(['ProcessWarId'])
ProcessWarId = UserData['ProcessWarId']
rowStar = self.db.out_fields('tb_war_star','*','UserId=%s'%self.uid)
RestPoint,MaxPoint = self.getActPoint()
if warId>ProcessWarId or not rowStar.get('War%s'%warId):
return False
if RestPoint< Gcore.getCfg('tb_cfg_pve',warId,'ActPointNeed')*SweepTimes:
return False
else:
Gcore.setUserData(self.uid, {'Sweeping':True} )
#@todo 自动补兵
for i in xrange(SweepTimes):
restTimes = SweepTimes-i-1
if not Gcore.getUserData(self.uid, 'Sweeping'): #用户落线也会停止
break
else:
gevent.sleep( Gcore.loadCfg(9101).get('SweepSleep') ) #每场间隔3秒 读配置
modBattle = Gcore.getMod('Battle',self.uid,True)
initWarResult = modBattle.initWar(warId,1) #定义为扫荡战役
if not initWarResult:
print '初始化战斗失败'
break
modBattle.getWarInfo()
re = modBattle.endBattle({"resultType":5})
#print '战斗结果',re
result[warId] = re #结构不能更改 需要和前台一样
self.warlog(WarId=warId,IsWarSweep=1,Result=re.get('Result',0)) #@todo 添加更完整战役结果
Gcore.push(111,self.uid,{'result':result,'restPoint':RestPoint,'restTimes':restTimes})
if not re.get('Result'):
break
else:
RestPoint-=1
return True
示例15: updateMissions
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import getUserData [as 别名]
def updateMissions(self,mData):
'''更新多个任务(更新相应的任务缓存数据)
@param mData: {MId:updateData} MId:任务ID,updateData:更新内容
@return: 更新数目
'''
tb_m = 'tb_mission'
mCfg = Gcore.getCfg('tb_cfg_mission')
activeMission = Gcore.getUserData(self.uid, 'ActiveMission')
# print '更新任务信息=>',mData
# print '任务缓存信息=>',activeMission
pusMId = []
updateNum = 0
for mId in mData:
data = mData[mId]
getVal = data.get('GetValue',0)
paramB = mCfg[mId]['ParamB']
#如果任务完成推送消息
if getVal>=paramB:
data['GetValue']=paramB
data['Status']=3
data['CompleteTime'] = time.time()
pusMId.append(mId)
activeMission.pop(mId,None)#任务完成删除缓存任务
elif getVal:
activeMission[mId]['GetValue'] = getVal#更新缓存任务信息
if self.db.update(tb_m,data,'UserId=%s AND MissionId=%s'%(self.uid,mId)):
updateNum +=1
#更新任务缓存
Gcore.setUserData(self.uid, {'ActiveMission':activeMission})
#推送通知任务完成
if pusMId:
print '任务完成',str(pusMId)
Gcore.push(102,self.uid,{'MT':2,'MIDS':pusMId})
return updateNum