| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package PlayerFairyDomain  | 
| #  | 
| # @todo:çÎç¿ÏÉÓò  | 
| # @author xdh  | 
| # @date 2019-04-23  | 
| # @version 1.0  | 
| #  | 
| #  | 
| # ÏêϸÃèÊö: çÎç¿ÏÉÓò  | 
| #  | 
| #---------------------------------------------------------------------  | 
| """Version = 2019-04-23 17:00"""  | 
|   | 
| import GameWorld  | 
| import ShareDefine  | 
| import IpyGameDataPY  | 
| '''  | 
| Value1:ʼþID  | 
| Value2:Сʱ¶Î³öÏÖ´ÎÊý  | 
| Value3:½ñÈÕ³öÏÖ´ÎÊý  | 
| '''  | 
| RecType = ShareDefine.Def_UniversalGameRecType_FairyDomain  | 
|   | 
|   | 
| def AddFairyDomainEvent(fdEventIDList):  | 
|     fdEventLimitDict = {}  | 
|     for fdEventID in fdEventIDList:  | 
|         ipyData = IpyGameDataPY.GetIpyGameDataNotLog('FairyDomain', fdEventID)  | 
|         if not ipyData:  | 
|             continue  | 
|         hourCntLimit, dayCntLimit = ipyData.GetHourCntPubLimit(), ipyData.GetDayCntPubLimit()  | 
|         if not hourCntLimit and not dayCntLimit:  | 
|             continue  | 
|         fdEventLimitDict[fdEventID] = [hourCntLimit, dayCntLimit]  | 
|     if not fdEventLimitDict:  | 
|         return  | 
|     addfdRecList = fdEventLimitDict.keys()  | 
|     universalRecMgr = GameWorld.GetUniversalRecMgr()  | 
|     recTypeListData = universalRecMgr.GetTypeList(RecType)  | 
|   | 
|     addFDEventList = []  | 
|     for index in xrange(recTypeListData.Count()):  | 
|         recData = recTypeListData.At(index)  | 
|         curID = recData.GetValue1()  | 
|         if curID in fdEventLimitDict:  | 
|             addfdRecList.remove(curID)  | 
|             curHourAppearCnt = recData.GetValue2()  | 
|             curDayAppearCnt = recData.GetValue3()  | 
|             hourCntLimit, dayCntLimit = fdEventLimitDict[curID]  | 
|             if curHourAppearCnt >= hourCntLimit or curDayAppearCnt >= dayCntLimit:  | 
|                 continue  | 
|             recData.SetValue2(curHourAppearCnt +1)  | 
|             recData.SetValue3(curDayAppearCnt + 1)  | 
|             if curHourAppearCnt +1 >= hourCntLimit or curDayAppearCnt + 1 >= dayCntLimit:  | 
|                 addFDEventList.append(curID)  | 
|     for fdid in addfdRecList:  | 
|         recData = recTypeListData.AddRec()  | 
|         recData.SetValue1(fdid)  | 
|         recData.SetValue2(1)  | 
|         recData.SetValue3(1)  | 
|         hourCntLimit, dayCntLimit = fdEventLimitDict[fdid]  | 
|         if 1 >= hourCntLimit or 1 >= dayCntLimit:  | 
|             addFDEventList.append(fdid)  | 
|     if addFDEventList:  | 
|         #ͬ²½µØÍ¼  | 
|         GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FairyDomainLimit, [1, addFDEventList])  | 
|         | 
|     return  | 
|   | 
| def OnHour():  | 
|     __ResetFairyDomainCnt(1)  | 
|     return  | 
|   | 
| def OnDayEx():  | 
|     __ResetFairyDomainCnt(2)  | 
|     return  | 
|   | 
| def OnMapServerInitOK():  | 
|     __ResetFairyDomainCnt(0)  | 
|     return  | 
|   | 
| def __ResetFairyDomainCnt(resetType):  | 
|     curLimitEventIDList = []  | 
|     delCnt = 0  | 
|     universalRecMgr = GameWorld.GetUniversalRecMgr()  | 
|     recTypeListData = universalRecMgr.GetTypeList(RecType)  | 
|     for index in xrange(recTypeListData.Count()):  | 
|         dataIndex = index - delCnt  | 
|         recData = recTypeListData.At(dataIndex)  | 
|         if resetType == 1:  | 
|             recData.SetValue2(0)  | 
|         elif resetType == 2:  | 
|             recData.SetValue3(0)  | 
|         curID = recData.GetValue1()  | 
|         hourAppearCnt = recData.GetValue2()  | 
|         dayAppearCnt = recData.GetValue3()  | 
|         ipyData = IpyGameDataPY.GetIpyGameDataNotLog('FairyDomain', curID)  | 
|         if not ipyData:  | 
|             continue  | 
|         hourCntLimit, dayCntLimit = ipyData.GetHourCntPubLimit(), ipyData.GetDayCntPubLimit()  | 
|         if not hourCntLimit and not dayCntLimit:  | 
|             recTypeListData.Delete(dataIndex)  | 
|             delCnt +=1  | 
|             continue  | 
|         if hourAppearCnt >= hourCntLimit or dayAppearCnt >= dayCntLimit:  | 
|             curLimitEventIDList.append(curID)  | 
|     #ͬ²½µØÍ¼  | 
|     GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FairyDomainLimit, [0, curLimitEventIDList])  | 
|     return |