本文整理汇总了Python中sgLib.core.Gcore类的典型用法代码示例。如果您正苦于以下问题:Python Gcore类的具体用法?Python Gcore怎么用?Python Gcore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gcore类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: startSiege
def startSiege(self, para):
'''开始城战'''
optId = 93002
body = self.mod.startSiege() #开始攻城战斗
if not isinstance(body, dict):
return Gcore.error(optId,body) #body 是错误编号
return Gcore.out(optId,body)
开发者ID:fycheung,项目名称:misc,代码行数:7,代码来源:CBattle.py
示例2: getLatestGeneralInfo
def getLatestGeneralInfo(self, Generals=None, TimeStamp=None, UserLevel=None,
GeneralIds=None, fields='*', IsClubTech=True):
'''获取玩家武将的最新信息'''
# 参数:
# + Generals - 武将表中所有武将的信息
# + fields - 已取消,兼容以前的程序,现返回所有的字段
# + GeneralIds - 要查询的武将
# + + int, long, str - 查询单个武将的信息
# + + list, tuple - 查询多个武将的信息
# + + None - 查询玩家所有武将的信息
# + IsClubTech - 是否加上军团科技和宝物对武将四维属性的加成
# 返回值:
# + 单个武将:dict or None
# + 多个武将:list
# + 都不是:False
if not TimeStamp:TimeStamp = time.time()
if not Generals:Generals = self.getMyGenerals()
if not UserLevel:UserLevel = self.getUserLevel()
#加上武馆训练的经验
modGround = Gcore.getMod('Building_ground', self.uid)
_, Generals = modGround.touchPractise(Generals, TimeStamp, UserLevel)
if IsClubTech: #四维属性加上各种加成
# + 军团科技影响
modClub = Gcore.getMod('Building_club', self.uid)
club_tech_effects = modClub.getClubTechAdd()
# + 宝物影响
treasure_effects = self.getEquipExEffect([General['GeneralId'] for General in Generals])
# + 四维加上各种加成
for General in Generals:
General["ForceValue"] += int(club_tech_effects[1])
General["WitValue"] += int(club_tech_effects[2])
General["LeaderValue"] += int(club_tech_effects[3])
General["SpeedValue"] += int(club_tech_effects[4])
treasure_effect = treasure_effects[General['GeneralId']]
General["ForceValue"] += int(General["ForceValue"] * treasure_effect['force'])
General["WitValue"] += int(General["WitValue"] * treasure_effect['wit'])
General["SpeedValue"] += int(General["SpeedValue"] * treasure_effect['speed'])
General["LeaderValue"] += int(General["LeaderValue"] * treasure_effect['leader'])
if not GeneralIds: #返回所有武将的信息
return Generals
elif isinstance(GeneralIds, (int, long, str)): #返回单个武将的信息
for General in Generals:
if General["GeneralId"] == int(GeneralIds):
return General
return None
elif isinstance(GeneralIds, (list, tuple)): #返回多个武将的信息
ret = []
for General in Generals:
if General["GeneralId"] in map(int, GeneralIds):
ret.append(General)
return ret
return False
开发者ID:fycheung,项目名称:misc,代码行数:60,代码来源:GeneralMod.py
示例3: SaveTrain
def SaveTrain(self, param = {}):
'''点将台:保留培养的属性'''
optId = 15011
GeneralId = param["GeneralId"]
modTrain = Gcore.getMod('Building_train', self.uid)
TrainInfo = modTrain.getTrainRandoms(GeneralId)
if not TrainInfo:
return Gcore.error(optId, -15011001) #没有该武将的培养信息
#培养所得的属性值
TrainForce = TrainInfo["RandomForce"]
TrainWit = TrainInfo["RandomWit"]
TrainSpeed = TrainInfo["RandomSpeed"]
TrainLeader = TrainInfo["RandomLeader"]
modTrain.cancTrainRandoms() #先将培养信息置为无效
#更新武将表
if TrainForce or TrainWit or TrainSpeed or TrainLeader:
#如果全是0,直接返回。
stat = modTrain.saveTrainGeneral(GeneralId, TrainForce, TrainWit,
TrainSpeed, TrainLeader)
if not stat:
return Gcore.error(optId, -15011002) #用户没有该武将
return Gcore.out(optId, {})
开发者ID:fycheung,项目名称:misc,代码行数:28,代码来源:Building_trainUI.py
示例4: __init__
def __init__(self):
#self.validate = Validate()
self.Clients = {} #所有用户信息库
Gcore.objCfg.loadAllCfg() #读取所有配置
Gcore.IsServer = True #定义为服务器核心
Gcore.startNotice() #开启公告自动发布协程
开发者ID:fycheung,项目名称:misc,代码行数:7,代码来源:gateway.bak0801.py
示例5: getActPoint
def getActPoint(self):
'''获得 剩余行动点数/最大行动点数'''
BuyActPoint = self.getUserInfo('BuyActPoint')
row = self._lastActRecord()
MaxPoint = Gcore.getCfg('tb_cfg_action_point',self.getUserLevel(),'ActPoint')
if not row:
RestPoint = MaxPoint + BuyActPoint
else:
nowtime = Gcore.common.nowtime()
PerIncrTime = Gcore.loadCfg(9101).get('ActPointRecoverTime',1200)
if Gcore.TEST and self.uid in [1001,43953]:
PerIncrTime = testPerIncrTime
if row['ActPoint']>=MaxPoint: #已满,不恢复
RestPoint = row['ActPoint']
else:
AccuTime = row['AccuTime'] + ( nowtime - row['LastWarTime'] )
incrTimes = AccuTime//PerIncrTime #回复一点需要多长时间 20分钟
#print 'incrTimes',incrTimes
print 'getActPoint.上次剩余',row['ActPoint']
print 'getActPoint.至已经恢复了',incrTimes
ActPoint = row['ActPoint'] + incrTimes
if ActPoint > MaxPoint:
ActPoint = MaxPoint
print 'getActPoint.剩余+累计越出上限,设为上限',ActPoint
#查看的时候 不更新累计时间 tb_war_action.AccuTime
RestPoint = ActPoint
#print '剩余次数 最大次数',RestPoint,MaxPoint, 前台显示的是: 剩余次数/最大次数
return (RestPoint,MaxPoint)
开发者ID:fycheung,项目名称:misc,代码行数:30,代码来源:WarMod.py
示例6: randomName
def randomName(self, icon):
'''随机名称 '''
SelectNum = 30
if icon > 2:
sex = 2
else:
sex = 1
pMod = Gcore.getMod('Player', 1001)
lastnameList = Gcore.getCfg('tb_cfg_nickname').get(0)
firstnameList = Gcore.getCfg('tb_cfg_nickname').get(sex)
lastnameList = random.sample(lastnameList,SelectNum)
firstnameList = random.sample(firstnameList,SelectNum)
nicknames=[]
for i in xrange(SelectNum):
nickname = lastnameList[i]+firstnameList[i]
nicknames.append(nickname)
where = pMod.db.inWhere('NickName',nicknames)
rows = pMod.db.out_rows('tb_user','NickName',where)
existNickNames = [r['NickName'] for r in rows]
notExistNickNames = list(set(nicknames)-set(existNickNames))
NickNames = []
for NickName in notExistNickNames:
if Gcore.common.filterInput(NickName,2,16)<0:
pass #过滤敏感词的名称
else:
NickNames.append(NickName)
return NickNames[0]
开发者ID:fycheung,项目名称:misc,代码行数:33,代码来源:TestUI.py
示例7: sendMail
def sendMail(self, toUserIds, subject, content, mailUserType=2):
'''
发送邮件
@param toUserIds:发送对象Id,列表类型
@param subject:标题
@param content:内容
@param mailUserType:邮件类型1为系统邮件,2为私人邮件
@return 返回成功发送个数
'''
if mailUserType == 1:
fromUserId = 0
else:
fromUserId = self.uid
timeStamp = int(time.time())
mailConId = self.insMailCon(content)
result = 0
if len(toUserIds) and mailConId:
vals = []
for toId in toUserIds:
v = {}
v['FromUserId'] = fromUserId
v['ToUserId'] = toId
v['Subject'] = subject
v['MailConId'] = mailConId
v['CreateTime'] = timeStamp
v['MailUserType'] = mailUserType
vals.append(v)
result = self.db.insertmany('tb_mail', vals)
Gcore.push(101, toUserIds)
return result
开发者ID:fycheung,项目名称:misc,代码行数:31,代码来源:MailMod.py
示例8: mqPush
def mqPush(self, ckey, optId, optKey, para):
"""来自mqReceiver的消息,告诉玩家正在被打"""
# print ' in mqPush',para
Users = para.get("UserId")
Type = para.get("Type")
Data = para.get("Data", {})
Gcore.push(105, Users, Data, Type)
开发者ID:fycheung,项目名称:misc,代码行数:7,代码来源:gateway_8099.py
示例9: login
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
开发者ID:fycheung,项目名称:misc,代码行数:28,代码来源:LoginMod.py
示例10: findOutFighter
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,代码行数:27,代码来源:RequestMod.py
示例11: CheckFriend
def CheckFriend(self, param={}):
"""查看好友"""
optId = 19007
friendUserId = param["FriendUserId"]
if not self.mod.validateUser(friendUserId):
return Gcore.error(optId, -19007001) # 用户不存在
player = Gcore.getMod("Player", friendUserId)
fileds = ["UserId", "NickName", "UserLevel", "VipLevel", "UserIcon", "UserHonour", "UserCamp"]
result = player.getUserBaseInfo(fileds) # 获得基本信息
result["Rank"] = player.getHonRankNum(result)
buildingClub = Gcore.getMod("Building_club", friendUserId)
cId = buildingClub.getUserClubId()
clubInfo = buildingClub.getClubInfo(cId, "ClubName")
if clubInfo:
result["ClubName"] = clubInfo["ClubName"] # 获得军团名字
else:
result["ClubName"] = ""
general = Gcore.getMod("General", friendUserId)
generalNum = general.getMyGenerals("count(1) as gNum")
result["GeneralNum"] = generalNum[0]["gNum"] # 获得武将个数
buildingNum = self.mod.getBuildingCount(friendUserId)
result["BuildingNum"] = buildingNum # 获得建筑数量
return Gcore.out(optId, result)
开发者ID:fycheung,项目名称:misc,代码行数:27,代码来源:FriendUI.py
示例12: checkAndUpdate
def checkAndUpdate(self, table):
'''查找并更新数据库中建筑费用为NULL的数据'''
fields = ['BuildingId', 'UserId', 'BuildingType', 'BuildingLevel', 'CoinType', 'BuildingPrice', 'LastChangedTime', 'CompleteTime']
where = ' CoinType is NULL or BuildingPrice is NULL or LastChangedTime is NULL OR CoinType = 0 OR BuildingPrice = 0 '
tmpRows = self.db.out_rows(table, fields, where)
if tmpRows:
for row in tmpRows:
#print '==PrimaryData:',row
tmpData = json.dumps(row) + '\n'
self.fd.write(tmpData)
if not row['CoinType']:
row['CoinType'] = Gcore.getCfg('tb_cfg_building', row['BuildingType'], 'CoinType')
if not row['BuildingPrice']:
row['BuildingPrice'] = Gcore.getCfg('tb_cfg_building_up', (row['BuildingType'], row['BuildingLevel']), 'CostValue')
if not row['LastChangedTime'] and row['LastChangedTime'] != 0:
if row['CompleteTime']:
row['LastChangedTime'] = row['CompleteTime'] - Gcore.getCfg('tb_cfg_building_up', (row['BuildingType'], row['BuildingLevel']), 'CDValue')
else:
row['LastChangedTime'] = 0
if row['LastChangedTime'] < 0:
row['LastChangedTime'] = 0
where = 'BuildingId=%s'%row['BuildingId']
data = {'CoinType': row['CoinType'], 'BuildingPrice': row['BuildingPrice'], 'LastChangedTime': row['LastChangedTime']}
self.db.update(table, data, where)
#print '==ModifiedData:',data
tmpData = json.dumps(data) + '\n'
self.fd.write(tmpData)
开发者ID:fycheung,项目名称:misc,代码行数:27,代码来源:updateBuildingPrice.py
示例13: MailList
def MailList(self,param={}):
'''
收件箱/发件箱列表
@param param['MailType']=1 表示收件箱
param['MailType']=2 表示发件箱
'''
optId = 18003
mailType = int(param['MailType'])
page = int(param['Page']) #页码
if not page: #默认为第一页
page = 1
if mailType not in (1,2):
return Gcore.error(optId,-18003999) #MailType值不对
mailCfg = Gcore.loadCfg(Gcore.defined.CFG_MAIL)
pagePerNum = int(mailCfg['MailShowPerPageMax']) #每页的邮件数
mailCount = int(self.mod.mailCountByType(mailType)) #收件箱/发件箱中邮件总数
mailDatas = self.mod.getMailList(mailType,page,pagePerNum) #每页显示的邮件数据
subjShowMax = mailCfg['SubjectShowMax'] #邮件主题显示最大长度
self.mod.finMailDatas(mailDatas,subjShowMax)
totalPage = int(math.ceil(1.0*mailCount/pagePerNum))
body = {'mailDatas':mailDatas,'page':page,'mailCount':mailCount,'totalpage':totalPage}
return Gcore.out(optId, body = body)
开发者ID:fycheung,项目名称:misc,代码行数:25,代码来源:MailUI_bak.py
示例14: setReventProcess
def setReventProcess(self, process, flag=0, TimeStamp=None):
'''设置反抗进度:process-攻城进度;flag-0失败,1成功'''
#返回值:-2 反抗次数已达到最大 -1 参数错误 0 没达到成功条件 1达到成功条件
if not 0 <= process <=1:
return -1 #攻城进度取值范围不对
TimeStamp = TimeStamp if TimeStamp else time.time()
cnt, pro = self.calcRevent(TimeStamp)
ratio = 0.5 #读配置
maxnum = 5 #读配置
cnt_new = cnt + 1
pro_new = pro + float(ratio * process) #取攻城进度的50%。
if cnt_new > maxnum:
return -2
elif pro_new >= 1.0 or flag == 1: #累积进度达到100% ## 读配置
self.db.execute('DELETE FROM `tb_hold_revenge` WHERE UserId="%s"'%self.uid)
hsid,huid = self.getMyHolder()
if huid:
self.freed(huid, hsid) #让自己被释放
pMod = Gcore.getMod('Player', self.uid)
protectTime = Gcore.loadCfg(CFG_BUILDING_HOLD)['RvProtectHoldSecond']
pMod.addProtectHoldTime(protectTime)
return 1
else: #增加累计进度
arr = {}
arr['ProcessTotal'] = pro_new
arr['RevengeCount'] = cnt_new
arr['LastRevengeDate'] = datetime.date.strftime(
datetime.date.fromtimestamp(TimeStamp), '%Y-%m-%d')
self.db.update('tb_hold_revenge', arr, 'UserId="%s"'%self.uid)
开发者ID:fycheung,项目名称:misc,代码行数:30,代码来源:Building_holdMod.py
示例15: GetHold
def GetHold(self, param={}):
'''
@旧:我的藩国(如果我有主人就显示主人信息): 获取主人和奴隶的信息
@新:显示我的藩国列表
'''
optId = 15123
#holder = self.mod.getHolder()
#if not holder:
if True:
holder = {"hServerId":0, "hUserId":0}
Slaves = self.mod.getHold()
for Slave in Slaves:
suid, ssid = Slave['UserId'], Slave.get('ServerId', Gcore.getServerId())
stat = self.mod.isMyHold(suid, ssid)
if not stat:
Slave['Jcoin'], Slave['Gcoin'] = 0, 0
else:
Slave['Jcoin'], Slave['Gcoin'] = stat
Slave.setdefault('ServerId', Gcore.getServerId())
else:
Slaves = []
return Gcore.out(optId, {'Holder':holder, 'Holds':Slaves})
开发者ID:fycheung,项目名称:misc,代码行数:25,代码来源:Building_holdUI.py
示例16: CleanWallDefense
def CleanWallDefense(self,p={}):
'''回收损毁的防御工事'''
optId = 92012
CoinValue = self.mod.clearWallDefense()
if CoinValue:
Gcore.getMod('Coin',self.uid).GainCoin(optId,2,CoinValue,'WallUI.CleanWallDefense',p)#返回军资
reward = self.mod.getWallBoxReward() #获取遗落宝箱的奖励
if reward:#有奖励
rewardType = reward['RewardType']
goodsId = reward['GoodsId']
goodsNum = reward['GoodsNum']
ids = Gcore.getMod('Reward',self.uid).reward(optId,p,rewardType,goodsId,goodsNum)
#reward['WillGet'] = 1
if rewardType==1:
if isinstance(ids,list):
reward['EquipIds'] = ids
else:
reward['EquipIds'] = []
else:#无奖励
#reward = {'WillGet':0}
reward = {}
recordData = {'uid':self.uid,'ValType':0,'Val':1,'WillGet':reward.get('WillGet')}
body = {"CoinType":2,"CoinValue":CoinValue,"Reward":reward}
return Gcore.out(optId,body,mission=recordData)
else:
return Gcore.error(optId,-92012001) #没有可回收的防御工事
开发者ID:fycheung,项目名称:misc,代码行数:28,代码来源:WallUI.py
示例17: test
def test(self,p={}):
'''测试获取当前缓存的用户信息'''
optId = 99001
Gcore.getUserData(1001, 'UserLevel')
body = { 'Gcore.StorageUser': str(Gcore.StorageUser) }
print 'body',body
return Gcore.out(optId,body)
开发者ID:fycheung,项目名称:misc,代码行数:7,代码来源:TestUI.py
示例18: MoveElement
def MoveElement(self,p={}):
'''批量移动布防内的元素'''
optId = 92002
''' 参数例子:
p = {}
p['DefenseInfo'] = [
{'WallDefenseId':4,'x':1,'y':1,'xSize':1,'ySize':3},
{'WallDefenseId':5,'x':11,'y':13,'xSize':2,'ySize':2},
]
p['GeneralInfo'] = [
{'GeneralId':1,'x':8,'y':14},
{'GeneralId':2,'x':4,'y':43},
]
'''
# if 'DefenseInfo' in p:
# WallDefenseIds = [ r['WallDefenseId'] for r in p['DefenseInfo'] ]
#
# rows = self.mod.getDefenseInfo(WallDefenseIds)
# for row in rows:
# SoldierType = row['SoldierType']
# xSize = row['xSize']
# ySize = row['ySize']
# Size = Gcore.getCfg('tb_cfg_soldier',SoldierType,'Size')
#
# if str(xSize)+'*'+str(ySize)!=Size and str(ySize)+'*'+str(xSize)!=Size:
# return Gcore.error(optId,-92002998) #非法操作
# #@todo 坐标验证
result = self.mod.moveElement(p)
if not result:
return Gcore.error(optId,-92002997) #系统错误
else:
return Gcore.out(optId)
开发者ID:fycheung,项目名称:misc,代码行数:33,代码来源:WallUI.py
示例19: CheckMissionStatus
def CheckMissionStatus(self ,p={}):
'''检查任务状态'''
optId = 22005
self.mod.updateAllMissions()
Gcore.getMod('Building_home',self.uid).updateAllAchieves()
return Gcore.out(optId)
开发者ID:fycheung,项目名称:misc,代码行数:7,代码来源:MissionUI.py
示例20: getWallGeneralList
def getWallGeneralList(self):
'''获取布防武将列表 参考getWallGeneralList()
@call: WallUI
@author: by Lizr
'''
kLeader = Gcore.loadCfg(Gcore.defined.CFG_BATTLE)["kLeaderAddNum"]
SoldierTechs = Gcore.getMod('Book',self.uid).getTechsLevel(1)
InListGeneral = self.db.out_list('tb_wall_general','GeneralId',"UserId=%s"%self.uid) #已布防
fields = ['GeneralId','GeneralType','GeneralLevel','ForceValue',
'WitValue','SpeedValue','LeaderValue','TakeType','TakeTypeDefense']
rows = Gcore.getMod('General',self.uid).getMyGenerals(fields)
#Gcore.printd( rows )
GeneralList = []
for row in rows:
if not row['TakeTypeDefense']:
row['TakeTypeDefense'] = row['TakeType']
row['Skill'] = Gcore.getCfg('tb_cfg_general',row['GeneralType'],'SkillId')
SoldierType = row['TakeTypeDefense']
SoldierLevel = SoldierTechs.get( SoldierType )
row['SoldierType'] = SoldierType
row['SoldierLevel'] = SoldierLevel
key = (SoldierType,SoldierLevel)
SoldierNum = row['LeaderValue']*kLeader
cfg_soldier = Gcore.getCfg('tb_cfg_soldier_up',key)
if cfg_soldier:
#row['Life'] = cfg_soldier['Life']* row['LeaderValue']*kLeader
#row['Attack'] = cfg_soldier['Attack']*row['LeaderValue']*kLeader
#row['Denfense'] = cfg_soldier['Defense']
row['Life'] = F.getArmyLife(cfg_soldier['Life'], SoldierNum)
row['Attack'] = F.getArmyAttack(
generalType = row['GeneralType'],
soldierType = row['SoldierType'],
landForm = 4,
soldierAttack = cfg_soldier['Attack'],
soldierNum = SoldierNum,
forceValue = row['ForceValue'],
)
row['Denfense'] = F.defenseAdd( cfg_soldier['Defense'],row['SpeedValue'],row['GeneralType'])
else:
row['Life'] = 0
row['Attack'] = 0
row['Denfense'] = 0
row['InWall'] = row['GeneralId'] in InListGeneral #是否在布防中
# del row['ForceValue']
# del row['WitValue']
# del row['SpeedValue']
# del row['LeaderValue']
del row['TakeType']
del row['TakeTypeDefense']
GeneralList.append(row)
return GeneralList
开发者ID:fycheung,项目名称:misc,代码行数:60,代码来源:WallMod.py
注:本文中的sgLib.core.Gcore类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论