#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package PlayerStore # # @todo:ÉÌ³Ç # @author xdh # @date 2018-10-09 # @version 1.0 # # # ÏêϸÃèÊö: É̳ÇÈ«·þÏÞ¹º´¦Àí # #--------------------------------------------------------------------- """Version = 2018-10-09 17:00""" import GameWorld import ShareDefine import PlayerControl import IpyGameDataPY import ChPyNetSendPack import NetPackCommon RecType = ShareDefine.Def_UniversalGameRecType_StoreServerCntRecord ## Íæ¼ÒµÇ¼ # @param None # @return None def OnPlayerLogin(curPlayer): SyncStoreServerBuyInfo(curPlayer) return ## É̳ÇÈ«·þÏÞ¹º²éѯ½á¹û # @param curPlayer Íæ¼ÒʵÀý # @param msgList ÐÅÏ¢Áбí # @return awardID def DoStoreServerBuyQueryResult(curPlayer, msgList): goodsID = msgList[0] serverLimitCnt = msgList[1] buyCount = msgList[2] curGotCnt = 0 universalRecMgr = GameWorld.GetUniversalRecMgr() recTypeListData = universalRecMgr.GetTypeList(RecType) findRecData = None for index in range(recTypeListData.Count()): recData = recTypeListData.At(index) curGoodsID = recData.GetValue1() if goodsID == curGoodsID: findRecData = recData curGotCnt = recData.GetValue2() break if curGotCnt + buyCount > serverLimitCnt: GameWorld.Log(' ¹ºÂòÉÌÆ· È«·þ¹ºÂò´ÎÊý²»¹» goodsID=%s,curGotCnt=%s,buyCount=%s,serverLimitCnt=%s'%(goodsID, curGotCnt, buyCount, serverLimitCnt)) return if not findRecData: findRecData = recTypeListData.AddRec() findRecData.SetValue1(goodsID) newBuyCnt = curGotCnt+buyCount findRecData.SetValue2(newBuyCnt) #֪ͨ SyncStoreServerBuyInfo(None, {goodsID:newBuyCnt}) return msgList def DoResetStoreServerBuyCnt(shopTypeList): '''¸ù¾ÝÉ̵êÀàÐÍÖØÖÃÈ«·þ¹ºÂò´ÎÊý''' universalRecMgr = GameWorld.GetUniversalRecMgr() recTypeListData = universalRecMgr.GetTypeList(RecType) delCnt = 0 syncDict = {} for index in xrange(recTypeListData.Count()): dataIndex = index - delCnt recData = recTypeListData.At(dataIndex) curGoodsID = recData.GetValue1() ipyData = IpyGameDataPY.GetIpyGameData("Store", curGoodsID) if not ipyData: continue if ipyData.GetShopType() not in shopTypeList: continue syncDict[curGoodsID] = 0 recTypeListData.Delete(dataIndex) delCnt +=1 GameWorld.DebugLog(' ¸ù¾ÝÉ̵êÀàÐÍÖØÖÃÈ«·þ¹ºÂò´ÎÊý shopTypeList=%s'%shopTypeList) if delCnt: SyncStoreServerBuyInfo(None, syncDict) return def ResetFlashSaleBuyCnt(ipyData): #ÖØÖÃÏÞʱÇÀ¹ºÉ̵êÈ«·þ¹ºÂò´ÎÊý dayShopRangeDict = ipyData.GetShopTypeList() resetTypeList = [] for shopTypeList in dayShopRangeDict.values(): for dayShopList in shopTypeList: for shopType in dayShopList: if shopType not in resetTypeList: resetTypeList.append(shopType) if resetTypeList: DoResetStoreServerBuyCnt(resetTypeList) return def SyncStoreServerBuyInfo(curPlayer, syncCntDict={}): #֪ͨÉÌÆ·È«·þ¹ºÂò´ÎÊý sendPack = ChPyNetSendPack.tagGCStoreServerBuyCntInfo() sendPack.Clear() sendPack.InfoList = [] if syncCntDict: for goodsID, buyCnt in syncCntDict.items(): buyInfo = ChPyNetSendPack.tagGCStoreServerBuyCnt() buyInfo.GoodsID = goodsID buyInfo.BuyCnt = buyCnt sendPack.InfoList.append(buyInfo) else: universalRecMgr = GameWorld.GetUniversalRecMgr() recTypeListData = universalRecMgr.GetTypeList(RecType) for index in xrange(recTypeListData.Count()): recData = recTypeListData.At(index) buyInfo = ChPyNetSendPack.tagGCStoreServerBuyCnt() buyInfo.GoodsID = recData.GetValue1() buyInfo.BuyCnt = recData.GetValue2() sendPack.InfoList.append(buyInfo) sendPack.Count = len(sendPack.InfoList) if not curPlayer: playerManager = GameWorld.GetPlayerManager() for i in xrange(playerManager.GetActivePlayerCount()): curPlayer = playerManager.GetActivePlayerAt(i) if curPlayer == None or not curPlayer.GetInitOK(): continue if PlayerControl.GetIsTJG(curPlayer): continue NetPackCommon.SendFakePack(curPlayer, sendPack) else: if PlayerControl.GetIsTJG(curPlayer): return NetPackCommon.SendFakePack(curPlayer, sendPack) return