def GetMyClub(self, p={}): '''获取我的军团信息 ''' optId = 15062 clubId = self.mod.getUserClubId() clubInfo = { 'BaseInfo': 0, 'MemberNum': 0, 'DevoteValue': 0, 'LeaderInfo': 0, 'HasClub': 0, 'MyInfo': 0 } if not clubId: return Gcore.out(optId, clubInfo) #没有军团 ClubInfo = self.mod.getClubInfo(clubId) #军团基础信息 #by Lizr 前台没有这些值,,抽取 del ClubInfo['ClubTotalExp'] del ClubInfo['ClubLevelTotalExp'] del ClubInfo['CreatDate'] clubInfo['BaseInfo'] = ClubInfo clubInfo['MemberNum'] = self.mod.getClubMemberNum(clubId) #军团成员数量 clubInfo['DevoteValue'] = self.mod.getTodayDevote(clubId, 2) #当天贡献值 clubInfo['LeaderInfo'] = self.mod.getClubLeader(clubId) #团长信息 clubInfo['MyInfo'] = self.mod.getMemberInfo( clubId, self.uid, ['DevoteCurrent', 'DevoteTotal']) clubInfo['HasClub'] = 1 clubInfo['DevoteLogs'] = com.list2dict(self.mod.getDevoteLogs(clubId), 1) clubInfo['DevoteBase'] = Gcore.loadCfg( defined.CFG_BUILDING_CLUB).get('ClubGiveBase') return Gcore.out(optId, clubInfo)
def GetMyClub(self,p={}): '''获取我的军团信息 ''' optId = 15062 clubId = self.mod.getUserClubId() clubInfo = {'BaseInfo':0,'MemberNum':0, 'DevoteValue':0,'LeaderInfo':0, 'HasClub':0,'MyInfo':0} if not clubId: return Gcore.out(optId,clubInfo)#没有军团 ClubInfo = self.mod.getClubInfo(clubId)#军团基础信息 #by Lizr 前台没有这些值,,抽取 del ClubInfo['ClubTotalExp'] del ClubInfo['ClubLevelTotalExp'] del ClubInfo['CreatDate'] clubInfo['BaseInfo'] = ClubInfo clubInfo['MemberNum'] = self.mod.getClubMemberNum(clubId)#军团成员数量 clubInfo['DevoteValue'] = self.mod.getTodayDevote(clubId,2)#当天贡献值 clubInfo['LeaderInfo'] = self.mod.getClubLeader(clubId)#团长信息 clubInfo['MyInfo'] = self.mod.getMemberInfo(clubId,self.uid,['DevoteCurrent','DevoteTotal']) clubInfo['HasClub'] = 1 clubInfo['DevoteLogs'] = com.list2dict(self.mod.getDevoteLogs(clubId), 1) clubInfo['DevoteBase'] = Gcore.loadCfg(defined.CFG_BUILDING_CLUB).get('ClubGiveBase') return Gcore.out(optId,clubInfo)
def GetMissionList(self,p={}): ''' 查询任务列表 ''' optId=22001 re=self.mod.getMyMissions() re = com.list2dict(re,0) return Gcore.out(optId,{'MLS':re})
def GetShopEquips(self,p={}): '''查询商店中玩家可回购装备以及背包信息''' optId = 16005 building = self.mod.getSmithyInfo() if building is None: return Gcore.error(optId,-16005901)#建筑不存在 result = self.mod.getSaleGoods() result['Sale'] = com.list2dict(result['Sale'],offset=0) if not result['Sale']: del result['Sale'] bagMod = Gcore.getMod('Bag',self.uid) bagGoods = bagMod.getGoods(0) bag = {} bag['GS'] = com.list2dict(bagGoods, offset=0) bag['Size'] = bagMod.getBagSize() result['Bag'] = bag return Gcore.out(optId,result)
def GetMissionList(self, p={}): ''' 查询任务列表 ''' optId = 22001 re = self.mod.getMyMissions() re = com.list2dict(re, 0) return Gcore.out(optId, {'MLS': re})
def ApplyList(self, param={}): """获得好友申请列表""" optId = 19002 lists = self.mod.getApplyList() applyList = common.list2dict(lists) data = {"ApplyList": applyList} data["FriendNum"] = self.mod.countFriend(2) data["FriendOnlineNum"] = self.mod.countFriend(2, True) return Gcore.out(optId, data)
def ApplyList(self, param={}): '''获得好友申请列表''' optId = 19002 lists = self.mod.getApplyList() applyList = common.list2dict(lists) data = {'ApplyList': applyList} data['FriendNum'] = self.mod.countFriend(2) data['FriendOnlineNum'] = self.mod.countFriend(2, True) return Gcore.out(optId, data)
def GetDevoteLogs(self,p={}): '''获取捐赠记录(已合并到军团信息,将弃用)''' optId = 15084 clubId = self.mod.getUserClubId() if clubId: result = self.mod.getDevoteLogs(clubId) else: result = [] result = com.list2dict(result, 1) return Gcore.out(optId,{'Logs':result})
def GetDevoteLogs(self, p={}): '''获取捐赠记录(已合并到军团信息,将弃用)''' optId = 15084 clubId = self.mod.getUserClubId() if clubId: result = self.mod.getDevoteLogs(clubId) else: result = [] result = com.list2dict(result, 1) return Gcore.out(optId, {'Logs': result})
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)
def FriendList(self, param={}): """获得好友列表""" optId = 19001 lists = self.mod.getFriendList() friendList = common.list2dict(lists) data = {"FriendList": friendList} data["FriendNum"] = self.mod.countFriend(2) uLimitNum = Gcore.getCfg("tb_cfg_friend_limit", self.mod.getUserLevel(), "FriendNumLimit") # data['FriendOnlineNum']=self.mod.countFriend(2,True) data["FriendMaxNum"] = uLimitNum return Gcore.out(optId, data)
def FriendList(self, param={}): '''获得好友列表''' optId = 19001 lists = self.mod.getFriendList() friendList = common.list2dict(lists) data = {'FriendList': friendList} data['FriendNum'] = self.mod.countFriend(2) uLimitNum = Gcore.getCfg('tb_cfg_friend_limit', self.mod.getUserLevel(), 'FriendNumLimit') #data['FriendOnlineNum']=self.mod.countFriend(2,True) data['FriendMaxNum'] = uLimitNum return Gcore.out(optId, data)
def GetGeInteractLog(self,param={}): '''获取武将交流记录(受访者用)''' optId=21005 generalId=param['GeneralId'] re=self.mod.getGeInteractLog(generalId) getMcoin=0 for award in re: getMcoin+=award['McoinNum'] if getMcoin==0: gainMcoin=getMcoin else: modCoin=Gcore.getMod('Coin',self.uid) classMethod = '%s,%s'%(self.__class__.__name__,sys._getframe().f_code.co_name) gainMcoin=modCoin.GainCoin(optId,4,getMcoin,classMethod,param) self.mod.setGeInteractGet(generalId) interactLog=common.list2dict(re) return Gcore.out(optId,{'InteractLog':interactLog,'GainMcoin':gainMcoin})
def GiftList(self, param={}): '''获取通用礼包记录 by zhanggh 6.9 @param GT:2签到3成长4活跃 不传:所有 ''' optId = 23002 TimeStamp = param.get('ClientTime') gt = param.get('GT') fields = ['GiftId', 'ActivityId', 'AwardId', 'CreateTime', 'LimiteTime', 'Perm'] if gt: gtList = [gt] giftList = self.mod.giftList(gtList, fields, 0, TimeStamp) else:#通用礼包列表 gtList = [act['ActivityId'] for act in Gcore.getCfg('tb_cfg_act').values() if act['Status']==1 and act['GeneralShow']==1] giftList = self.mod.giftList(gtList, fields, 1, TimeStamp) giftList = common.list2dict(giftList) return Gcore.out(optId, {'GL': giftList})
def GetGeInteractLog(self, param={}): """获取武将交流记录(受访者用)""" optId = 21005 generalId = param["GeneralId"] re = self.mod.getGeInteractLog(generalId) getMcoin = 0 for award in re: getMcoin += award["McoinNum"] if getMcoin == 0: gainMcoin = getMcoin else: modCoin = Gcore.getMod("Coin", self.uid) classMethod = "%s,%s" % (self.__class__.__name__, sys._getframe().f_code.co_name) gainMcoin = modCoin.GainCoin(optId, 4, getMcoin, classMethod, param) self.mod.setGeInteractGet(generalId) interactLog = common.list2dict(re) return Gcore.out(optId, {"InteractLog": interactLog, "GainMcoin": gainMcoin})
def GetActiveLog(self, param={}): '''显示活跃度UI''' optId = 23012 data = {} activeLog = self.mod.getActiveLog(['DayTimes', 'ActionId']) activeLog = list(activeLog) actions = Gcore.getCfg('tb_cfg_act_active_action').keys() aa = [ac['ActionId'] for ac in activeLog] for ak in actions: if ak in aa: continue else: activeLog.append({'ActionId': ak, 'DayTimes': 0}) score = self.mod.getActiveScore() activeLog.sort(cmp=lambda x,y:cmp(x['ActionId'],y['ActionId'])) data['ActiveLog'] = common.list2dict(activeLog) if not score: data['Score'] = 0 else: data['Score'] = score return Gcore.out(optId, data)
def GetGoods(self,p={}): '''分类查看物品 GoodsType:1:装备,2:道具,3,不分种类''' optId = 13061 goodsType = p.get('GoodsType') bagSize = self.mod.getBagSize()#背包容量 maxSize = Gcore.loadCfg(Gcore.defined.CFG_PLAYER_BAG).get('MaxNum') full = 1 if bagSize==maxSize else 0 if goodsType in (1,2): goods = self.mod.getGoods(goodsType)#背包物品 else: goods = self.mod.sortBag()#排序背包物品并返回有序的物品 goods = com.list2dict(goods, offset=0) recordData = {'uid':self.uid,'ValType':0,'Val':1}#成就、任务记录 #兵书,宝物 equipMod = Gcore.getMod('Equip',self.uid) warbooks = equipMod.getEquipByIds(4) treasures = equipMod.getEquipByIds(5) return Gcore.out(optId,{'GS':goods,'Size':bagSize,'Full':full,'WBS':warbooks,'TRS':treasures},mission=recordData)
def GetHonRanking(self,p={}): '''荣誉值排名''' optId = 13002 pageSize = Gcore.loadCfg(Gcore.defined.CFG_PLAYER).get('HonourRankPS') pageNum = p.get('PageNum',0) count = self.mod.getUserNum() maxPage = int(math.ceil(float(count)/pageSize)) if pageNum<1: pageNum=1 elif 0<maxPage<pageNum: pageNum = maxPage offset = (pageNum-1)*pageSize us = self.mod.getHonRanking(offset,pageSize) us = com.list2dict(us, offset+1) #我的名次 if pageNum==1: myRank = self.mod.getHonRankNum() else: myRank = 0 return Gcore.out(optId,{'HRank':us,'PageNum':pageNum,'MaxPage':maxPage,'MyRank':myRank})
def GetActiveLog(self, param={}): '''显示活跃度UI''' optId = 23012 data = {} activeLog = self.mod.getActiveLog(['DayTimes', 'ActionId']) activeLog = list(activeLog) actions = Gcore.getCfg('tb_cfg_act_active_action').keys() aa = [ac['ActionId'] for ac in activeLog] for ak in actions: if ak in aa: continue else: activeLog.append({'ActionId': ak, 'DayTimes': 0}) score = self.mod.getActiveScore() activeLog.sort(cmp=lambda x, y: cmp(x['ActionId'], y['ActionId'])) data['ActiveLog'] = common.list2dict(activeLog) if not score: data['Score'] = 0 else: data['Score'] = score return Gcore.out(optId, data)
def GiftList(self, param={}): '''获取通用礼包记录 by zhanggh 6.9 @param GT:2签到3成长4活跃 不传:所有 ''' optId = 23002 TimeStamp = param.get('ClientTime') gt = param.get('GT') fields = [ 'GiftId', 'ActivityId', 'AwardId', 'CreateTime', 'LimiteTime', 'Perm' ] if gt: gtList = [gt] giftList = self.mod.giftList(gtList, fields, 0, TimeStamp) else: #通用礼包列表 gtList = [ act['ActivityId'] for act in Gcore.getCfg('tb_cfg_act').values() if act['Status'] == 1 and act['GeneralShow'] == 1 ] giftList = self.mod.giftList(gtList, fields, 1, TimeStamp) giftList = common.list2dict(giftList) return Gcore.out(optId, {'GL': giftList})
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)