| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Player.PlayerActGodGift  | 
| #  | 
| # @todo:ÌìµÛÀñ°ü»î¶¯  | 
| # @author hxp  | 
| # @date 2022-01-14  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: ÌìµÛÀñ°ü»î¶¯  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2022-01-14 15:00"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import PyGameData  | 
| import ShareDefine  | 
| import PlayerControl  | 
| import IpyGameDataPY  | 
| import ItemControler  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import IPY_GameWorld  | 
| import ItemCommon  | 
| import GameWorld  | 
| import ChConfig  | 
|   | 
| def OnPlayerLogin(curPlayer):  | 
|       | 
|     for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_GodGift, {}).values():  | 
|         actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)  | 
|         __CheckPlayerGodGiftAction(curPlayer, actNum)  | 
|           | 
|     return  | 
|   | 
| def RefreshGodGiftActionInfo(actNum):  | 
|     ## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢  | 
|     playerManager = GameWorld.GetPlayerManager()  | 
|     for index in xrange(playerManager.GetPlayerCount()):  | 
|         curPlayer = playerManager.GetPlayerByIndex(index)  | 
|         if curPlayer.GetID() == 0:  | 
|             continue  | 
|         __CheckPlayerGodGiftAction(curPlayer, actNum)  | 
|     return  | 
|   | 
| def __CheckPlayerGodGiftAction(curPlayer, actNum):  | 
|     ## ¼ì²éÍæ¼Ò»î¶¯Êý¾ÝÐÅÏ¢  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_GodGift, actNum)  | 
|     actID = actInfo.get(ShareDefine.ActKey_ID, 0)  | 
|     state = actInfo.get(ShareDefine.ActKey_State, 0)  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)  | 
|       | 
|     playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodGiftID % actNum) # Íæ¼ÒÉíÉϵĻID  | 
|       | 
|     # »î¶¯ID ÏàͬµÄ»°²»´¦Àí  | 
|     if actID == playerActID:  | 
|         GameWorld.DebugLog("ÌìµÛÀñ°ü»î¶¯ID²»±ä£¬²»´¦Àí£¡actNum=%s,actID=%s" % (actNum, actID), playerID)  | 
|     else:  | 
|         actWorldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)  | 
|         templateID = __GetActTemplateID(actInfo)  | 
|         GameWorld.DebugLog("ÌìµÛÀñ°üÖØÖÃ! actNum=%s,actID=%s,playerActID=%s,state=%s,cfgID=%s,actWorldLV=%s,templateID=%s"   | 
|                            % (actNum, actID, playerActID, state, cfgID, actWorldLV, templateID), playerID)  | 
|           | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodGiftID % actNum, actID)  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodGiftWorldLV % actNum, actWorldLV)  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodGiftResetCount % actNum, 0)  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodGiftAwardPool % actNum, 0)  | 
|           | 
|         awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActGodGiftAward", templateID) if templateID else []  | 
|         if awardIpyDataList:  | 
|             for awardIpyData in awardIpyDataList:  | 
|                 libType = awardIpyData.GetAwardLibType()  | 
|                 libItemInfoDict = awardIpyData.GetLibItemInfo()  | 
|                 for num in libItemInfoDict.keys():  | 
|                     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodGiftItemState % (actNum, libType, num), 0)  | 
|                   | 
|     if state:  | 
|         Sync_GodGifActionInfo(curPlayer, actNum)  | 
|         Sync_GodGiftPlayerInfo(curPlayer, actNum)  | 
|           | 
|     return True  | 
|   | 
| def __GetActTemplateID(actInfo):  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)  | 
|     dayIndex = actInfo.get(ShareDefine.ActKey_DayIndex, 0)  | 
|     worldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)  | 
|     if cfgID == None or dayIndex == None:  | 
|         return 0  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ActGodGift", cfgID)  | 
|     if not ipyData:  | 
|         return 0  | 
|     templateIDInfo = ipyData.GetTemplateIDInfo()  | 
|     templateIDList = GameWorld.GetDictValueByRangeKey(templateIDInfo, worldLV)  | 
|     if not templateIDList:  | 
|         return 0  | 
|     templateID = templateIDList[-1] if dayIndex >= len(templateIDList) else templateIDList[dayIndex]  | 
|     return templateID  | 
|   | 
| def GetGodGiftItemState(curPlayer, actNum, libType, num):  | 
|     itemState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodGiftItemState % (actNum, libType, num))  | 
|     chooseTimes = itemState / 100  | 
|     isChoose = (itemState - chooseTimes * 100) / 10  | 
|     isGot = itemState % 10  | 
|     return chooseTimes, isChoose, isGot  | 
|   | 
| def SetGodGiftItemState(curPlayer, actNum, libType, num, chooseTimes, isChoose, isGot):  | 
|     updItemState = chooseTimes * 100 + isChoose * 10 + isGot  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodGiftItemState % (actNum, libType, num), updItemState)  | 
|     return updItemState  | 
|   | 
|   | 
| #// AA 20 ÌìµÛÀñ°üÑ¡ÔñÎïÆ· #tagCMActGodGiftChooseItem  | 
| #  | 
| #struct    tagCMActGodGiftChooseItemInfo  | 
| #{  | 
| #    BYTE        ItemLibType;    //ÎïÆ·¿âÀàÐÍ  | 
| #    BYTE        Count;        //Ñ¡Ôñ¸öÊý  | 
| #    BYTE        ItemNumList[Count];    //Ñ¡ÔñÎïÆ·±àºÅÁÐ±í  | 
| #};  | 
| #  | 
| #struct    tagCMActGodGiftChooseItem  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        ActNum;        //»î¶¯±àºÅ  | 
| #    BYTE        ChooseLibCount;    //Ñ¡Ôñ¿â¸öÊý      | 
| #    tagCMActGodGiftChooseItemInfo    ChooseItemList[ChooseLibCount];    //Ñ¡Ôñ¿âÎïÆ·ÐÅÏ¢ÁÐ±í  | 
| #};  | 
| def OnActGodGiftChooseItem(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     actNum = clientData.ActNum  | 
|     chooseItemNumDict = {info.ItemLibType:info.ItemNumList for info in clientData.ChooseItemList}  | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_GodGift, actNum)  | 
|     state = actInfo.get(ShareDefine.ActKey_State, 0)  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)  | 
|     templateID = __GetActTemplateID(actInfo)  | 
|     GameWorld.DebugLog("ÌìµÛÀñ°üÑ¡ÔñÎïÆ·: actNum=%s,state=%s,cfgID=%s,templateID=%s,chooseItemNumDict=%s"   | 
|                        % (actNum, state, cfgID, templateID, chooseItemNumDict), playerID)  | 
|     if not state or not cfgID or not templateID:  | 
|         GameWorld.DebugLog("ÌìµÛÀñ°ü»î¶¯×´Ì¬Òì³£!", playerID)  | 
|         return  | 
|       | 
|     if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodGiftAwardPool % actNum):  | 
|         GameWorld.DebugLog("ÌìµÛÀñ°ü½±³ØÒѾѡÔñÍê±Ï£¬ÎÞ·¨Öظ´Ñ¡Ôñ!", playerID)  | 
|         return  | 
|       | 
|     awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActGodGiftAward", templateID) if templateID else []  | 
|     if not awardIpyDataList:  | 
|         return  | 
|       | 
|     chooseOKLibList = []  | 
|     for awardIpyData in awardIpyDataList:  | 
|         libType = awardIpyData.GetAwardLibType()  | 
|         chooseItemNumList = chooseItemNumDict.get(libType, [])  | 
|           | 
|         libItemInfoDict = awardIpyData.GetLibItemInfo()  | 
|         needChooseCount = awardIpyData.GetChooseItemCount()  | 
|         hadChooseNumList, canChooseNumList = [], []  | 
|         for num, itemInfo in libItemInfoDict.items():  | 
|             canChooseTimes = itemInfo[4]  | 
|             chooseTimes, isChoose, _ = GetGodGiftItemState(curPlayer, actNum, libType, num)  | 
|             if isChoose:  | 
|                 hadChooseNumList.append(num)  | 
|             elif not canChooseTimes or chooseTimes < canChooseTimes:  | 
|                 canChooseNumList.append(num)  | 
|                   | 
|         GameWorld.DebugLog("ÌìµÛÀñ°üÑ¡Ôñ¿â½±Æ·! libType=%s,chooseItemNumList=%s" % (libType, chooseItemNumList), playerID)  | 
|         GameWorld.DebugLog("    needChooseCount=%s,hadChooseNumList=%s,canChooseNumList=%s" % (needChooseCount, hadChooseNumList, str(canChooseNumList)), playerID)  | 
|         hadChooseCount = len(hadChooseNumList)  | 
|         if hadChooseCount >= needChooseCount:  | 
|             GameWorld.DebugLog("    ¸Ã¿âÒѳ¬¹ýÑ¡ÔñÍê±Ï! libType=%s" % libType, playerID)  | 
|             chooseOKLibList.append(libType)  | 
|             continue  | 
|           | 
|         for num in chooseItemNumList:  | 
|             if num in hadChooseNumList:  | 
|                 GameWorld.DebugLog("    Òѱ»Ñ¡Ôñ! libType=%s,num=%s" % (libType, num), playerID)  | 
|                 continue  | 
|             if num not in canChooseNumList:  | 
|                 GameWorld.DebugLog("    ²»¿ÉÑ¡Ôñ! libType=%s,num=%s not in %s" % (libType, num, canChooseNumList), playerID)  | 
|                 continue  | 
|               | 
|             chooseTimes, isChoose, isGot = GetGodGiftItemState(curPlayer, actNum, libType, num)  | 
|             chooseTimes += 1  | 
|             isChoose = 1  | 
|             updItemState = SetGodGiftItemState(curPlayer, actNum, libType, num, chooseTimes, isChoose, isGot)  | 
|             GameWorld.DebugLog("    Ñ¡Ôñ½±Æ·! libType=%s,num=%s,chooseTimes=%s,isChoose=%s,isGot=%s,updItemState=%s"   | 
|                                % (libType, num, chooseTimes, isChoose, isGot, updItemState), playerID)  | 
|               | 
|             canChooseNumList.remove(num)  | 
|             hadChooseCount += 1  | 
|             if hadChooseCount >= needChooseCount or not canChooseNumList:  | 
|                 chooseOKLibList.append(libType)  | 
|                 break  | 
|                   | 
|     if chooseOKLibList and len(chooseOKLibList) == len(awardIpyDataList):  | 
|         GameWorld.DebugLog("ÌìµÛÀñ°üÉú³É½±³ØOK!", playerID)  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodGiftAwardPool % actNum, 1)  | 
|     else:          | 
|         GameWorld.DebugLog("ÌìµÛÀñ°ü½±³ØÎ´Ñ¡ÔñÍê±Ï! chooseOKLibList=%s" % chooseOKLibList, playerID)  | 
|           | 
|     Sync_GodGifActionInfo(curPlayer, actNum)  | 
|     return  | 
|   | 
| #// AA 21 ÌìµÛÀñ°ü³é½± #tagCMActGodGiftlottery  | 
| #  | 
| #struct    tagCMActGodGiftlottery  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        ActNum;        //»î¶¯±àºÅ  | 
| #};  | 
| def OnActGodGiftlottery(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     actNum = clientData.ActNum  | 
|           | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_GodGift, actNum)  | 
|     state = actInfo.get(ShareDefine.ActKey_State, 0)  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)  | 
|     templateID = __GetActTemplateID(actInfo)  | 
|     GameWorld.DebugLog("ÌìµÛÀñ°ü»î¶¯³é½±: actNum=%s,state=%s,cfgID=%s,templateID=%s" % (actNum, state, cfgID, templateID), playerID)  | 
|     if not state or not cfgID or not templateID:  | 
|         GameWorld.DebugLog("ÌìµÛÀñ°ü»î¶¯×´Ì¬Òì³£!", playerID)  | 
|         return  | 
|       | 
|     if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodGiftAwardPool % actNum):  | 
|         GameWorld.DebugLog("ÌìµÛÀñ°ü½±³ØÎ´Ñ¡ÔñÍê±Ï£¬ÎÞ·¨³é½±!", playerID)  | 
|         return  | 
|       | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ActGodGift", cfgID)  | 
|     if not ipyData:  | 
|         return  | 
|     CostMoneyType = ipyData.GetUseMoneyType()  | 
|     costMoneyValueList = ipyData.GetUseGoldList()  | 
|     PrizeMoneyType = ipyData.GetPrizeMoneyType()  | 
|     prizeMoneyValueList = ipyData.GetPrizeMoneyList()  | 
|       | 
|     awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActGodGiftAward", templateID) if templateID else []  | 
|     if not awardIpyDataList:  | 
|         return  | 
|       | 
|     gotAwardList = [] # Òѳ齱Ʒ´ÎÊý  | 
|     randItemWeightList = []  | 
|     for awardIpyData in awardIpyDataList:  | 
|         libType = awardIpyData.GetAwardLibType()  | 
|         libItemInfoDict = awardIpyData.GetLibItemInfo()  | 
|         notifyItemNumList = awardIpyData.GetNotifyItemNumList()  | 
|           | 
|         for num, itemInfo in libItemInfoDict.items():  | 
|             weight, itemID, itemCount, isBind = itemInfo[:4]  | 
|             chooseTimes, isChoose, isGot = GetGodGiftItemState(curPlayer, actNum, libType, num)  | 
|             if isGot:  | 
|                 gotAwardList.append([libType, num])  | 
|                 continue  | 
|             if not isChoose:  | 
|                 continue  | 
|             isNotify = num in notifyItemNumList  | 
|             randItemWeightList.append([weight, libType, num, itemID, itemCount, isBind, chooseTimes, isChoose, isGot, isNotify])  | 
|               | 
|     if not randItemWeightList:  | 
|         GameWorld.DebugLog("±¾´Î½±³ØÒѳéÍê!", playerID)  | 
|         return  | 
|       | 
|     awardCount = len(gotAwardList) # Òѳ齱´ÎÊý  | 
|       | 
|     costMoneyValue = costMoneyValueList[awardCount] if awardCount < len(costMoneyValueList) else costMoneyValueList[-1]  | 
|     prizeMoneyValue = prizeMoneyValueList[awardCount] if awardCount < len(prizeMoneyValueList) else prizeMoneyValueList[-1]  | 
|       | 
|     if not PlayerControl.HaveMoney(curPlayer, CostMoneyType, costMoneyValue):  | 
|         return  | 
|       | 
|     if not ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem, True):  | 
|         return  | 
|       | 
|     GameWorld.DebugLog("    Òѳé¿â,±àºÅÁбí: awardCount=%s, %s" % (awardCount, gotAwardList), playerID)  | 
|     GameWorld.DebugLog("    costMoneyValue=%s,prizeMoneyValue=%s" % (costMoneyValue, prizeMoneyValue), playerID)  | 
|     GameWorld.DebugLog("    randItemWeightList=%s" % randItemWeightList, playerID)  | 
|     randItemInfo = GameWorld.GetResultByWeightList(randItemWeightList)  | 
|     if not randItemInfo:  | 
|         return  | 
|     libType, num, itemID, itemCount, isBind, chooseTimes, isChoose, isGot, isNotify = randItemInfo  | 
|     GameWorld.DebugLog("    ³éÖÐ: libType=%s,num=%s,itemID=%s,itemCount=%s,isBind=%s,chooseTimes=%s,isChoose=%s,isGot=%s"   | 
|                        % (libType, num, itemID, itemCount, isBind, chooseTimes, isChoose, isGot), playerID)  | 
|       | 
|     infoDict = {"actNum":actNum, "awardCount":awardCount}  | 
|     if not PlayerControl.PayMoney(curPlayer, CostMoneyType, costMoneyValue, ChConfig.Def_Cost_ActGodGift, infoDict):  | 
|         return  | 
|       | 
|     isGot = 1  | 
|     updItemState = SetGodGiftItemState(curPlayer, actNum, libType, num, chooseTimes, isChoose, isGot)  | 
|     GameWorld.DebugLog("    ¸üпâ±àºÅÎïÆ·×´Ì¬: libType=%s,num=%s,updItemState=%s" % (libType, num, updItemState), playerID)  | 
|     Sync_GodGiftPlayerInfo(curPlayer, actNum)  | 
|       | 
|     addDataDict = {"actNum":actNum, "awardCount":awardCount}  | 
|     PlayerControl.GiveMoney(curPlayer, PrizeMoneyType, prizeMoneyValue, ChConfig.Def_GiveMoney_ActGodGift, addDataDict)  | 
|       | 
|     if ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isBind, [IPY_GameWorld.rptItem], event=["ActGodGift", False, {}]):  | 
|         if isNotify:  | 
|             PlayerControl.WorldNotify(0, "ActGodGiftNotify", [curPlayer.GetPlayerName(), itemID, itemCount])  | 
|               | 
|     if len(randItemWeightList) == 1:  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodGiftAwardPool % actNum, 2)  | 
|         GameWorld.DebugLog("    ½±³ØÒѱ»³éÍê!", playerID)  | 
|           | 
|     return  | 
|   | 
| #// AA 22 ÌìµÛÀñ°üÖØÖà#tagCMActGodGiftReset  | 
| #  | 
| #struct    tagCMActGodGiftReset  | 
| #{  | 
| #    tagHead        Head;  | 
| #    BYTE        ActNum;        //»î¶¯±àºÅ  | 
| #};  | 
| def OnActGodGiftReset(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     actNum = clientData.ActNum  | 
|           | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_GodGift, actNum)  | 
|     state = actInfo.get(ShareDefine.ActKey_State, 0)  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)  | 
|     templateID = __GetActTemplateID(actInfo)  | 
|     GameWorld.DebugLog("ÌìµÛÀñ°üÖØÖý±³Ø: actNum=%s,state=%s,cfgID=%s,templateID=%s" % (actNum, state, cfgID, templateID), playerID)  | 
|     if not state or not cfgID or not templateID:  | 
|         GameWorld.DebugLog("ÌìµÛÀñ°ü»î¶¯×´Ì¬Òì³£!", playerID)  | 
|         return  | 
|       | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ActGodGift", cfgID)  | 
|     if not ipyData:  | 
|         return  | 
|     resetLimitTimes = ipyData.GetResetLimitTimes()  | 
|     resetCountMax = ipyData.GetResetCountMax()  | 
|       | 
|     resetCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodGiftResetCount % actNum)  | 
|     if resetCount >= resetCountMax:  | 
|         GameWorld.DebugLog("ÌìµÛÀñ°üÒѳ¬¹ý×î´óÖØÖý±³Ø´ÎÊý! cfgID=%s,resetCount=%s >= %s" % (cfgID, resetCount, resetCountMax), playerID)  | 
|         return  | 
|       | 
|     awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActGodGiftAward", templateID) if templateID else []  | 
|     if not awardIpyDataList:  | 
|         return  | 
|       | 
|     if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodGiftAwardPool % actNum) != 2:  | 
|         awardCount = 0  | 
|         for awardIpyData in awardIpyDataList:  | 
|             libType = awardIpyData.GetAwardLibType()  | 
|             libItemInfoDict = awardIpyData.GetLibItemInfo()  | 
|             for num in libItemInfoDict.keys():  | 
|                 _, _, isGot = GetGodGiftItemState(curPlayer, actNum, libType, num)  | 
|                 if isGot:  | 
|                     awardCount += 1  | 
|                       | 
|         if awardCount < resetLimitTimes:  | 
|             GameWorld.DebugLog("ÌìµÛÀñ°üÒѳ齱´ÎÊý²»×㣬ÎÞ·¨ÖØÖý±³Ø! cfgID=%s,awardCount=%s < %s" % (cfgID, awardCount, resetLimitTimes), playerID)  | 
|             return  | 
|     else:  | 
|         GameWorld.DebugLog("½±³ØÒѳéÍê£¬ÖØÖÃʱ²»ÐèÒªÅжϴÎÊý!", playerID)  | 
|           | 
|     # ÖØÖý±³Ø  | 
|     for awardIpyData in awardIpyDataList:  | 
|         libType = awardIpyData.GetAwardLibType()  | 
|         libItemInfoDict = awardIpyData.GetLibItemInfo()  | 
|         for num in libItemInfoDict.keys():  | 
|             chooseTimes, isChoose, isGot = GetGodGiftItemState(curPlayer, actNum, libType, num)  | 
|             if not isChoose and not isGot:  | 
|                 continue  | 
|             isChoose, isGot = 0, 0  | 
|             updItemState = SetGodGiftItemState(curPlayer, actNum, libType, num, chooseTimes, isChoose, isGot)  | 
|             GameWorld.DebugLog("    ÖØÖÿ⽱Ʒ״̬: libType=%s,num=%s,chooseTimes=%s,updItemState=%s"   | 
|                                % (libType, num, chooseTimes, updItemState), playerID)  | 
|               | 
|     updResetCount = resetCount + 1  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodGiftResetCount % actNum, updResetCount)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodGiftAwardPool % actNum, 0)  | 
|     GameWorld.DebugLog("    ÖØÖý±³Ø³É¹¦: updResetCount=%s" % updResetCount, playerID)  | 
|       | 
|     Sync_GodGifActionInfo(curPlayer, actNum)  | 
|     Sync_GodGiftPlayerInfo(curPlayer, actNum)  | 
|     return  | 
|   | 
| def Sync_GodGifActionInfo(curPlayer, actNum):  | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_GodGift, actNum)  | 
|     state = actInfo.get(ShareDefine.ActKey_State, 0)  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)  | 
|     if not state or not cfgID:  | 
|         return  | 
|       | 
|     templateID = __GetActTemplateID(actInfo)  | 
|     if not templateID:  | 
|         return  | 
|       | 
|     ipyData = IpyGameDataPY.GetIpyGameData("ActGodGift", cfgID)  | 
|     if not ipyData:  | 
|         return 0  | 
|       | 
|     startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData)  | 
|     clientPack = ChPyNetSendPack.tagMCActGodGiftInfo()  | 
|     clientPack.ActNum = actNum  | 
|     clientPack.StartDate = startDateStr  | 
|     clientPack.EndtDate = endDateStr  | 
|     clientPack.IsDayReset = ipyData.GetIsDayReset()  | 
|     clientPack.LimitLV = ipyData.GetLVLimit()  | 
|     clientPack.CostMoneyType = ipyData.GetUseMoneyType()  | 
|     clientPack.CostMoneyValueList = ipyData.GetUseGoldList()  | 
|     clientPack.CostMoneyValueCount = len(clientPack.CostMoneyValueList)  | 
|     clientPack.PrizeMoneyType = ipyData.GetPrizeMoneyType()  | 
|     clientPack.PrizeMoneyValueList = ipyData.GetPrizeMoneyList()  | 
|     clientPack.PrizeMoneyValueCount = len(clientPack.PrizeMoneyValueList)  | 
|     clientPack.ResetLimitTimes = ipyData.GetResetLimitTimes()  | 
|     clientPack.ResetCountMax = ipyData.GetResetCountMax()  | 
|     clientPack.ItemLibList = []  | 
|     awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActGodGiftAward", templateID) if templateID else []  | 
|     if awardIpyDataList:  | 
|         for awardIpyData in awardIpyDataList:  | 
|             libType = awardIpyData.GetAwardLibType()  | 
|             libItemInfoDict = awardIpyData.GetLibItemInfo()  | 
|             needChooseCount = awardIpyData.GetChooseItemCount()  | 
|               | 
|             itemLib = ChPyNetSendPack.tagMCActGodGiftItemLib()  | 
|             itemLib.ItemLibType = libType  | 
|             itemLib.NeedChooseCount = needChooseCount  | 
|             itemLib.GodGiftItemList = []  | 
|             for num, itemInfo in libItemInfoDict.items():  | 
|                 _, itemID, itemCount, isBind, canChooseTimes = itemInfo  | 
|                 chooseTimes, isChoose, _ = GetGodGiftItemState(curPlayer, actNum, libType, num)  | 
|                 item = ChPyNetSendPack.tagMCActGodGiftItem()  | 
|                 item.ItemNum = num  | 
|                 item.ItemID = itemID  | 
|                 item.ItemCount = itemCount  | 
|                 item.IsBind = isBind  | 
|                 item.CanChooseTimes = canChooseTimes  | 
|                 item.ChooseTimes = chooseTimes  | 
|                 item.IsChoose = isChoose  | 
|                 itemLib.GodGiftItemList.append(item)  | 
|                   | 
|             itemLib.GodGiftItemCount = len(itemLib.GodGiftItemList)  | 
|             clientPack.ItemLibList.append(itemLib)  | 
|               | 
|     clientPack.ItemLibCount = len(clientPack.ItemLibList)  | 
|     clientPack.IsAwardPoolOK = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodGiftAwardPool % actNum)  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  | 
|   | 
| def Sync_GodGiftPlayerInfo(curPlayer, actNum):  | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_GodGift, actNum)  | 
|     state = actInfo.get(ShareDefine.ActKey_State, 0)  | 
|     if not state:  | 
|         return  | 
|       | 
|     templateID = __GetActTemplateID(actInfo)  | 
|     if not templateID:  | 
|         return  | 
|       | 
|     clientPack = ChPyNetSendPack.tagMCActGodGiftPlayerInfo()  | 
|     clientPack.ActNum = actNum  | 
|     clientPack.ResetCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodGiftResetCount % actNum)  | 
|     clientPack.AwardItemList = []  | 
|       | 
|     awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActGodGiftAward", templateID) if templateID else []  | 
|     if awardIpyDataList:  | 
|         for awardIpyData in awardIpyDataList:  | 
|             libType = awardIpyData.GetAwardLibType()  | 
|             libItemInfoDict = awardIpyData.GetLibItemInfo()  | 
|             for num in libItemInfoDict.keys():  | 
|                 _, _, isGot = GetGodGiftItemState(curPlayer, actNum, libType, num)  | 
|                 if not isGot:  | 
|                     continue  | 
|                 awardItem = ChPyNetSendPack.tagMCActGodGiftAwardItem()  | 
|                 awardItem.ItemLibType = libType  | 
|                 awardItem.ItemNum = num  | 
|                 clientPack.AwardItemList.append(awardItem)  | 
|                   | 
|     clientPack.AwardItemCount = len(clientPack.AwardItemList)  | 
|     NetPackCommon.SendFakePack(curPlayer, clientPack)  | 
|     return  |