本文整理汇总了Python中sgLib.core.Gcore.error方法的典型用法代码示例。如果您正苦于以下问题:Python Gcore.error方法的具体用法?Python Gcore.error怎么用?Python Gcore.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sgLib.core.Gcore
的用法示例。
在下文中一共展示了Gcore.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ApplyClub
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def ApplyClub(self,p={}):
'''
:申请加入
'''
optId = 15064
clubId = p['ClubId']
building = self.mod.getClubBuildingInfo()
if building is None:
return Gcore.error(optId,-15064901)#外史院建筑不存在
clubInfo = self.mod.getClubInfo(clubId)
if not clubInfo:
return Gcore.error(optId,-15064920)#军团不存在
if self.mod.getUserClubId():
return Gcore.error(optId,-15064001)#只能加入一个军团
if not self.mod.validApplyInterval():
return Gcore.error(optId,-15064004)#离上次退出军团时间间隔不合法
memberNum = self.mod.getClubMemberNum(clubId)
if memberNum.get('CurNum')>=memberNum.get('MaxNum'):
return Gcore.error(optId,-15064002)#军团成员已满
allowState = clubInfo.get('AllowState')
if allowState == 1:#需要审核
self.mod.applyClub(clubId)
return Gcore.out(optId,{'Passed':0,'ClubId':clubId})#申请成功,审核中
elif allowState ==2:#不需审核
self.mod.applyClub(clubId)
self.mod.agreeApply(optId, clubId, self.uid)
Gcore.setUserData(self.uid, {'ClubId':clubId})#更新用户缓存
recordData = {'uid':self.uid,'ValType':0,'Val':1}#任务
return Gcore.out(optId,{'Passed':1,'ClubId':clubId},mission=recordData)#成功加入军团
else:
return Gcore.out(optId,{'Passed':2})#不允许加入
示例2: checkOpt
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def checkOpt(self,ckey,optId,optKey,para):
if optId == 888888:
result = Gcore.reload()
print 'Gcore.reload()'
msg = '<font color=green>Reload Success!</font>' if result is True else "<font color=red>"+str(result)+"</font>"
response = Gcore.out(optId,{'Result':msg})
self.Send(ckey,response)
elif 10001<=optId<=10005: #帐户相关: 10001登录,10002创建帐号,10003随机姓名,10004推荐阵营,10005检查帐户名是否合法
self.checkLogin(ckey,optId,optKey,para)
else:
if optId == 8888: #测试
#print 'Gcore.getDB(uid)>',Gcore.getDB(uid)
self.mqPush(ckey,optId,optKey,para)
else:
uid = self.Clients[ckey]['uid']
if uid==0:
response = Gcore.error(optId,-88888888)
self.Send(ckey,response)
print 'Please login first'
return
response = proManager.checkOpt(uid, optId, para)
if type(response) is not dict:
#print 'type(response)',type(response),response
response = Gcore.error(optId,-33333333) #协议号未定义 或返回出错
response['opt_key'] = optKey
self.Send(ckey,response)
示例3: CancelBuilding
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def CancelBuilding(self, param={}):
'''通用:取消建筑建造或升级'''
optId = 15003
BuildingId = param["BuildingId"]
TimeStamp = param['ClientTime']
BuildingInfo = self.mod.getBuildingById(BuildingId,
['BuildingPrice',
'BuildingType',
'CoinType',
'LastOptType'],
TimeStamp=TimeStamp)
if not BuildingInfo:
return Gcore.error(optId, -15003003) #用户没有该建筑
#BuildingType < 100 是建筑;大于100是装饰;
if BuildingInfo['BuildingType'] < 100 and \
BuildingInfo['BuildingState'] == 0:
return Gcore.error(optId, -15003004) #建筑已建造或升级完成,不能取消。
BuildingType = BuildingInfo['BuildingType']
CostValue = BuildingInfo["BuildingPrice"]
CostType = BuildingInfo["CoinType"]
#返钱
CancelReturn = Gcore.loadCfg(
Gcore.defined.CFG_BUILDING)["CancelReturn"] #返还比例
modCoin = Gcore.getMod('Coin', self.uid)
classMethod = '%s.%s' % (self.__class__.__name__,
sys._getframe().f_code.co_name)
gain = modCoin.GainCoin(optId, CostType,
int(CostValue * CancelReturn),
classMethod, param)
if gain < 0:
return Gcore.error(optId, -15003005) #增加货币失败
#建筑正在建造 :如果是装饰,删掉。
if BuildingInfo['BuildingType'] > 100 or \
BuildingInfo['BuildingState'] == 1:
self.mod.deleteBuildingById(BuildingId)
else:
#更新建筑表
UpInfo = {}
UpInfo['CompleteTime'] = TimeStamp
UpInfo['BuildingLevel'] = BuildingInfo['BuildingRealLevel']
UpInfo['LastOptType'] = 2
self.mod.updateBuildingById(UpInfo, BuildingId)
#不同类型的建筑进行不同的操作
# + todo
if BuildingType in (6, 7, 8): #校场 兵营 工坊:计算士兵
modCamp = Gcore.getMod('Building_camp', self.uid)
modCamp.TouchAllSoldiers(TimeStamp=TimeStamp)
if BuildingType in (6, 8): #兵营 工坊 回复生产
update_dic = {'LastChangedTime':TimeStamp,
'BuildingLevel':BuildingInfo['BuildingRealLevel']}
modCamp.updateProcessById(update_dic, BuildingId)
return Gcore.out(optId,
{'Coin%s'%CostType:modCoin.getCoinNum(CostType),
"RetValue":int(CostValue * CancelReturn)})
示例4: Exchange
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def Exchange(self, para={}):
'''货币兑换 by Lizr'''
optId = 20001
CoinType = para['CoinType']
CoinValue = para['CoinValue']
if CoinType not in (2, 3):
return Gcore.error(optId, -20001998) #非法操作
if type(CoinValue) not in (int, long) or CoinValue <= 0:
return Gcore.error(optId, -20001998) #非法操作
storageSpace = Gcore.getMod('Building', self.uid).cacStorageSpace(CoinType)
addPercent = CoinValue / storageSpace
rateInfos = Gcore.getCfg('tb_cfg_shop_res_sale')
rateInfoList = filter(lambda dic:dic['AddPercent'] <= addPercent and dic['CoinType'] == CoinType, rateInfos.values())
rateInfo = max(rateInfoList, key=lambda sale:sale['AddPercent'])
rate = rateInfo['kPrice1'] * (storageSpace ** rateInfo['kPrice2'])
GoldValue = int(math.ceil(CoinValue * rate))
# rate = Gcore.loadCfg(2001).get('exchange').get(str(CoinType))
# GoldValue = math.ceil(CoinValue/rate)
modCoin = Gcore.getMod('Coin', self.uid)
classMethod = '%s.%s' % (self.__class__.__name__, sys._getframe().f_code.co_name)
pay = modCoin.PayCoin(optId, 1, GoldValue, classMethod, para)
if pay < 0:
return Gcore.error(optId, -20001995) #支付失败
else:
#GainValue = GoldValue*rate
#GainValue = int(math.ceil(GoldValue / rate))
#result = modCoin.GainCoin(optId, CoinType, GainValue, classMethod, para)
result = modCoin.GainCoin(optId, CoinType, CoinValue, classMethod, para)
body = {"CoinType": CoinType, "CoinValue": CoinValue, "GoldUsed": pay}
return Gcore.out(optId, body)
示例5: BuyItemEquip
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def BuyItemEquip(self, param={}):
'''商城购买装备或道具'''
optId = 20006
ieSaleId = param['IeSaleId']
ieSaleCfg = Gcore.getCfg('tb_cfg_shop_ie_sale', ieSaleId)
if ieSaleCfg is None:
return Gcore.error(optId, -20006001)#商品不存在
modCoin = Gcore.getMod('Coin', self.uid)
modBag = Gcore.getMod('Bag', self.uid)
if not modBag.inclueOrNot(ieSaleCfg['SaleType'], ieSaleCfg['GoodsId'], ieSaleCfg['OnceNum']):
return Gcore.error(optId, -20006002)#背包空间不足
classMethod = '%s,%s'%(self.__class__.__name__,sys._getframe().f_code.co_name)
res = modCoin.PayCoin(optId, 1, ieSaleCfg['Price'], classMethod, param)
if res == -2:
return Gcore.error(optId, -20006994)#货币不足
if res < 0:
return Gcore.error(optId, -20006995)#支付失败或者非法操作
modBag = Gcore.getMod('Bag', self.uid)
buyId = modBag.addGoods(ieSaleCfg['SaleType'], ieSaleCfg['GoodsId'], ieSaleCfg['OnceNum'], addLog=optId)
recordData = {'uid': self.uid, 'ValType': ieSaleCfg['GoodsId'], 'Val': ieSaleCfg['OnceNum'], 'GoodsType': ieSaleCfg['SaleType']}#成就、任务记录
return Gcore.out(optId, {'Result': buyId}, mission = recordData)
示例6: CollectCoin
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def CollectCoin(self, param = {}):
'''磨坊2,铸币厂5:收集资源'''
#By Zhanggh 2013-3-20
optId = 15005
BuildingId = param.get('BuildingId')
CollectTimeStamp = param.get('ClientTime')
StorageReq = param.get('StorageReq')
#验证客户端与服务器的时差
BuildingInfo = self.buildingMod.getBuildingById(BuildingId)
if not BuildingInfo:
return Gcore.error(optId, -15005901) #用户没有该建筑
BuildingType = BuildingInfo['BuildingType']
if BuildingType !=2 and BuildingType!=5:
return Gcore.error(optId, -15005998) #建筑非军需所或铸币厂
if BuildingInfo.get('BuildingState')==2:
return Gcore.error(optId, -15005905)#建筑升级中
#收集资源,返回收集资源后剩余的部分与误差
returnInfo = self.mod.collectCoin(optId,BuildingType,BuildingId,CollectTimeStamp,StorageReq,param)
if returnInfo==0:
return Gcore.error(optId, -15005001) #没有可收集资源
elif returnInfo==-1:
return Gcore.error(optId, -15005002) #建筑修复中
CoinType = 2 if BuildingType == 2 else 3
CollectNum = returnInfo.pop('CNum')
recordData = {'uid':self.uid,'ValType':CoinType,'Val':CollectNum}#成就记录
return Gcore.out(optId,returnInfo,achieve=recordData,mission=recordData)
示例7: SaveTrain
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
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, {})
示例8: StripEquip
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def StripEquip(self, param={}):
'''点将台:将武将某个部位的装备脱下来'''
optId = 15016
GeneralId = param['GeneralId']
EquipPart = param['EquipPart']
Flag = param.get('Flag') #False脱装备;1脱宝物;其他脱兵书
modGeneral = Gcore.getMod('General', self.uid)
General = modGeneral.getGeneralInfo(GeneralId)
if not General:
return Gcore.error(optId, -15016001) #玩家无此武将
if not Flag:
stat = modGeneral.stripEquip(General, EquipPart)
if stat == -1:
return Gcore.error(optId, -15016002) #装备部位不正确或该武将在该部位上没有装备
if stat == -2:
return Gcore.error(optId, -15016003) #向背包中增加装备失败
else:
stat = modGeneral.stripEquip_EX(GeneralId, Flag)
if stat == -1:
return Gcore.error(optId, -15016004) #没穿兵书或宝物
if stat == -2:
return Gcore.error(optId, -15016005) #背包已满
#返回
return Gcore.out(optId, body={})
示例9: BuyActPoint
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def BuyActPoint(self,para={}):
'''购买行动点数'''
optId = 91004
MaxBuyActTimes = Gcore.loadCfg(9101).get('MaxBuyActTimes')
TodayBuyTimes = self.mod.getTodayBuyTimes()
print 'TodayBuyTimes',TodayBuyTimes
if MaxBuyActTimes <= TodayBuyTimes:
Gcore.out(optId, -91004001) #已达可购买上限
else:
TodayBuyTimes += 1
CostValue = Gcore.loadCfg(9101).get('BuyTimesPrice').get( str(TodayBuyTimes) )
if CostValue is None:
CostValue = max( Gcore.loadCfg(9101).get('BuyTimesPrice').values() )
#开始支付
modCoin = Gcore.getMod('Coin', self.uid)
pay = modCoin.PayCoin(optId, 1, CostValue, 'WarUI.BuyActTimes', para)
if pay < 0:
return Gcore.error(optId, -91004995) #支付失败
else:
result = self.mod.buyActPoint()
if not result:
return Gcore.error(optId, -91004002) #系统错误
body = {}
body['CanBuy'] = 1 if TodayBuyTimes < MaxBuyActTimes else 0
RestPoint,MaxPoint = self.mod.getActPoint()
body['RestPoint'] = RestPoint
body['MaxPoint'] = MaxPoint
return Gcore.out(optId, body)
示例10: GetSpawnNum
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def GetSpawnNum(self, param={}):
'''获取当前时刻,兵营或工坊的新兵数量'''
optId = 15030
BuildingId = param['BuildingId']
TimeStamp = param['ClientTime']
modBuilding = Gcore.getMod('Building', self.uid)
BuildingInfo = modBuilding.getBuildingById(BuildingId, TimeStamp=TimeStamp)
if not BuildingInfo:
return Gcore.error(optId, -15030001) #玩家没有该建筑
if BuildingInfo['BuildingState'] == 1:
return Gcore.error(optId, -15030002) #建筑正在建造
if BuildingInfo['BuildingType'] not in (6, 8):
return Gcore.error(optId, -15030003) #建筑不是兵营或工坊
print '建筑ID', BuildingId
print '建筑类型', BuildingInfo['BuildingType']
print '建筑等级', BuildingInfo['BuildingLevel']
modCamp = Gcore.getMod('Building_camp', self.uid)
spawn_detail= modCamp.getSoldierStorage(BuildingInfo, TimeStamp)
body = {}
body['StorageNum'] = spawn_detail['StorageNum']
body['LastChangedTime'] = spawn_detail['LastChangedTime']
return Gcore.out(optId, body=body)
示例11: UpgradeClubTech
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def UpgradeClubTech(self,p={}):
'''
:升级军团科技
#todo加一个升级完返回升级后的等级
'''
optId = 15076
techType = p.get('ClubTechType')
if techType not in range(1,11):
return Gcore.error(optId,-15076999)#参数错误
building = self.mod.getClubBuildingInfo()
if building is None:
return Gcore.error(optId,-15076901)#外史院建筑不存在
clubId = self.mod.getUserClubId()
if not clubId:
return Gcore.error(optId,-15076920)#军团不存在
clubInfo = self.mod.getClubInfo(clubId)
clubLevel = clubInfo.get('ClubLevel')
techLevel = self.mod.getClubTechLevel(techType)
openLevel = Gcore.getCfg('tb_cfg_club_up',clubLevel,'OpenLevelTech'+str(techType))
if techLevel >= openLevel:
return Gcore.error(optId,-15076001)#已达最大等级
cost = Gcore.getCfg('tb_cfg_club_tech',(techType,techLevel+1),'LearnCost')
# print '科技类型',techType
# print '科技等级',techLevel
# print '学习费用',cost
flag = self.mod.payDevote(clubId,cost)#成功返回余额
if flag<0:
return Gcore.error(optId,-15076995)#支付失败
newLevel = self.mod.upgradeClubTech(techType)
recordData = {'uid':self.uid,'ValType':0,'Val':1,'TechType':techType,'TechLevel':newLevel}#成就记录
return Gcore.out(optId,{'Left':flag,'ClubTechType':techType,'Level':newLevel},achieve=recordData,mission=recordData)
示例12: SlaveOperand
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def SlaveOperand(self, param={}):
'''对藩国的操作 纳贡 或 释放'''
optId = 15121
typ = param['typ'] #操作类型:1,纳贡。2,释放。
uid = param['uid'] #藩国UserId
sid = param['sid'] #藩国ServerId
ts = param['ClientTime'] #客户端时间戳
recordData = {}#成就记录
stat = self.mod.isMyHold(uid, sid)
if not stat: #不是玩家的藩国
return Gcore.error(optId, -15121001)
Jcoin, Gcoin = stat[0], stat[1]
modCoin = Gcore.getMod('Coin', self.uid)
classMethod = '%s.%s' % (self.__class__.__name__, sys._getframe().f_code.co_name)
if typ == 1: #1,纳贡
if Jcoin == 0 and Gcoin == 0:
return Gcore.error(optId, -15121002) #不可收集
j = modCoin.GainCoin(optId, 2, Jcoin, classMethod, param)
g = modCoin.GainCoin(optId, 3, Gcoin, classMethod, param)
if j < -1 or g < -1:
return Gcore.error(optId, -15121003) #增加货币操作失败
j = 0 if Jcoin==0 else j
g = 0 if Gcoin==0 else g
self.mod.collect(uid, sid, j, g, ts)
recordData = {'uid':self.uid,'ValType':0,'Val':1}#成就记录
elif typ == 2: #2,释放。
j = modCoin.GainCoin(optId, 2, Jcoin, classMethod, param)
g = modCoin.GainCoin(optId, 3, Gcoin, classMethod, param)
self.mod.free(uid, sid, ts)
else:
return Gcore.error(optId, -15121005) #操作类型错误
return Gcore.out(optId, body = {"Jcoin":j, "Gcoin":g},mission=recordData)
示例13: SpeedRapidPractise
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def SpeedRapidPractise(self, param={}):
'''加速突飞训练的冷却时间'''
optId = 15094
IsSpeed = param.get('IsSpeed')
TimeStamp = param['ClientTime']
TodayDate = time.strftime('%Y-%m-%d', time.localtime(TimeStamp))
modGround = Gcore.getMod('Building_ground', self.uid)
RapidRecord = modGround.getRapidRecord(TodayDate)
if not RapidRecord:
RapidCount = 0
IsOverFlow = 0
CDValue = 0
else:
RapidCount = RapidRecord['PractiseCount']
IsOverFlow = RapidRecord['IsOverFlow']
TotalCD = RapidRecord['CDValue']
SecondsPast = TimeStamp - RapidRecord['LastRapidTime']
CDValue = max(TotalCD - SecondsPast, 0)
if CDValue <= 0:
IsOverFlow = 0
if not IsSpeed: #不是加速
body = {}
body['TimeStamp'] = TimeStamp
body['IsOverFlow'] = IsOverFlow
body['CDValue'] = CDValue
body['RapidCout'] = RapidCount
return Gcore.out(optId, body=body)
#加速冷却时间
if CDValue <= 0:
return Gcore.error(optId, -15094001) #冷却时间为0
CoinType = 1
CoinValue = calSpeedCost(4, CDValue)
#扣钱
modCoin = Gcore.getMod('Coin', self.uid)
classMethod = '%s.%s' % (self.__class__.__name__, sys._getframe().f_code.co_name)
pay = modCoin.PayCoin(optId, CoinType, CoinValue, classMethod, param)
if pay < 0:
return Gcore.error(optId, -15094002) #扣钱失败
#更新突飞记录表
modGround.speedCD()
body = {}
body['GoldenCost'] = pay
body['CDValue'] = 0
body['SpeedTime'] = CDValue
body['IsOverFlow'] = 0
body['TimeStamp'] = TimeStamp
return Gcore.out(optId, body=body)
示例14: HandleApply
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def HandleApply(self, param={}):
"""处理好友申请"""
optId = 19003
timeStamp = param["ClientTime"]
friendUserIds = param["FriendUserIds"]
handleType = param["HandleType"]
recordData = {} # 任务记录
if not friendUserIds:
return Gcore.error(optId, -19003999) # 参数错误
if handleType == 0:
"""拒绝添加"""
# self.mod.updateFriendShip(friendUserIds, self.uid, 0, timeStamp)
self.mod.refuseApply(friendUserIds, self.uid, timeStamp)
mailMod = Gcore.getMod("Mail", self.uid)
nickName = self.mod.getUserInfo("NickName")
# mailMod.sendMail(friendUserIds, '拒绝好友申请', nickName+'拒绝了你的好友申请', 1)#拒绝好友,调用邮件发送信息给对方
for toUserId in friendUserIds:
mailMod.sendSystemMail(toUserId, [], optId, other=[nickName])
elif handleType == 1:
"""确认添加"""
# 判断玩家自己的好友数是否已达上限
uLimitNum = Gcore.getCfg("tb_cfg_friend_limit", self.mod.getUserLevel(), "FriendNumLimit")
uNowNum = self.mod.countFriend(2)
if uNowNum >= uLimitNum:
return Gcore.error(optId, -19003001) # 好友超过上限
# 如果对方好友已达上限,则拒绝本次添加请求
validId = []
for fid in friendUserIds:
tmpMod = Gcore.getMod("Friend", fid)
limitNum = Gcore.getCfg("tb_cfg_friend_limit", tmpMod.getUserLevel(), "FriendNumLimit")
nowNum = tmpMod.countFriend(2)
if nowNum >= limitNum:
# self.mod.updateFriendShip(fid, self.uid, 0, timeStamp)
self.mod.refuseApply(fid, self.uid, timeStamp)
else:
validId.append(fid)
if len(validId) == 0:
return Gcore.error(optId, -19003002)
# 如果玩家添加的好友数多于所能添加的个数,则失败
if uNowNum + len(validId) > uLimitNum:
return Gcore.error(optId, -19003001)
for friendUserId in validId:
self.mod.insFriendShip(self.uid, friendUserId, 2)
self.mod.updateFriendShip(friendUserId, self.uid, 2, timeStamp)
recordData = {"uid": self.uid, "ValType": 0, "Val": 1}
Gcore.getMod("Mission", friendUserId).missionTrigger(optId) # 触发被同意好友更新
else:
return Gcore.error(optId, -19003999) # 参数错误
return Gcore.out(optId, {}, mission=recordData)
示例15: GetReward
# 需要导入模块: from sgLib.core import Gcore [as 别名]
# 或者: from sgLib.core.Gcore import error [as 别名]
def GetReward(self,p={}):
'''
领取任务奖励
'''
optId=22003
mId=p['MID']
mCfg = Gcore.getCfg('tb_cfg_mission',mId)
if mCfg is None:
return Gcore.error(optId,-22003001)#任务不存在
# mInfo = self.mod.getMissionInfo(mId)
# if mInfo is None:
# return Gcore.error(optId,-22003001)#任务不存在
# #1: 新接,2:进行中,3:已完成,4:已领取奖励
# elif mInfo.get('Status')!=3:
# return Gcore.error(optId,-22003002)#任务未完成
whereClause = 'UserId=%s AND MissionId=%s AND Status=3'%(self.uid,mId)
updateFlag = self.mod.updateMissionByWhere({'Status':4},whereClause)#先更新任务状态,防止并发
if not updateFlag:
return Gcore.error(optId,-22003002)#任务未完成
#领取奖励
coinMod = Gcore.getMod('Coin',self.uid)
playerMod = Gcore.getMod('Player',self.uid)
rewardMod = Gcore.getMod('Reward',self.uid)
classMethod = '%s.%s' % (self.__class__.__name__, sys._getframe().f_code.co_name)
expReward = mCfg.get('RewardExp',0)
JCReward = mCfg.get('RewardJCoin',0)
GCReward = mCfg.get('RewardGCoin',0)
GReward = mCfg.get('RewardGold',0)
#发放奖励
playerMod.addUserExp(0,expReward,optId)
coinMod.GainCoin(optId,1,GReward,classMethod,p)
coinMod.GainCoin(optId,2,JCReward,classMethod,p)
coinMod.GainCoin(optId,3,GCReward,classMethod,p)
rt1 = mCfg.get('RewardType1',0)
rt2 = mCfg.get('RewardType2',0)
equipIds = []
if rt1!=0:
f = rewardMod.reward(optId,p,rt1,mCfg['GoodsId1'],mCfg['GoodsNum1'])
if rt1==1 and isinstance(f,list):
equipIds = equipIds+f
if rt2!=0:
f = rewardMod.reward(optId,p,rt2,mCfg['GoodsId2'],mCfg['GoodsNum2'])
if rt2==1 and isinstance(f,list):
equipIds = equipIds+f
# self.mod.updateMissions({mId:{'Status':4}})
self.mod.getNewMission(mId)
myMissions =self.mod.getMyMissions()
myMissions = com.list2dict(myMissions,0)
re={'EIds':equipIds,'MLS':myMissions}
return Gcore.out(optId,re)