| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Player.PlayerActHorsePetFeast  | 
| #  | 
| # @todo:Æï³èÊ¢Ñç  | 
| # @author hxp  | 
| # @date 2021-05-08  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: Æï³èÊ¢Ñç  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2021-05-08 17:00"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import ChConfig  | 
| import PlayerTJG  | 
| import ShareDefine  | 
| import IpyGameDataPY  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import PyGameData  | 
| import GameWorld  | 
| import NPCCommon  | 
|   | 
| def OnLogin(curPlayer):  | 
|       | 
|     for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_HorsePetFeast, {}).values():  | 
|         actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)  | 
|         if actInfo.get(ShareDefine.ActKey_CfgID):  | 
|             SyncHorsePetFeastInfo(curPlayer, actNum)  | 
|               | 
|     return  | 
|   | 
| def RefreshOperationAction_HorsePetFeast(actNum):  | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_HorsePetFeast, actNum)  | 
|     if not actInfo.get(ShareDefine.ActKey_CfgID):  | 
|         return  | 
|       | 
|     playerManager = GameWorld.GetPlayerManager()  | 
|     for i in xrange(playerManager.GetPlayerCount()):  | 
|         curPlayer = playerManager.GetPlayerByIndex(i)  | 
|         if curPlayer == None or not curPlayer.GetInitOK():  | 
|             continue  | 
|         SyncHorsePetFeastInfo(curPlayer, actNum)  | 
|           | 
|     return  | 
|   | 
| def SyncHorsePetFeastInfo(curPlayer, actNum):  | 
|     actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_HorsePetFeast, actNum)  | 
|     #state = actInfo.get(ShareDefine.ActKey_State)  | 
|     cfgID = actInfo.get(ShareDefine.ActKey_CfgID)  | 
|     if not cfgID:  | 
|         return  | 
|       | 
|     actIpyData = IpyGameDataPY.GetIpyGameData("ActHorsePetFeast", cfgID)  | 
|     if not actIpyData:  | 
|         return  | 
|       | 
|     startTimeList = actIpyData.GetStartTimeList()  | 
|     endTimeList = actIpyData.GetEndTimeList()  | 
|     if len(startTimeList) != len(endTimeList):  | 
|         return  | 
|       | 
|     startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(actIpyData)  | 
|     actInfo = ChPyNetSendPack.tagMCActHorsePetFeastInfo()  | 
|     actInfo.Clear()  | 
|     actInfo.StartDate = startDateStr  | 
|     actInfo.EndtDate = endDateStr  | 
|     actInfo.ActTimeList = []  | 
|     for i, startTime in enumerate(startTimeList):  | 
|         timeObj = ChPyNetSendPack.tagMCActHorsePetFeastTime()  | 
|         timeObj.StartTime = startTime  | 
|         timeObj.EndtTime = endTimeList[i]  | 
|         actInfo.ActTimeList.append(timeObj)   | 
|     actInfo.TimeCount = len(actInfo.ActTimeList)  | 
|     actInfo.LimitLV = actIpyData.GetLVLimit()  | 
|     NetPackCommon.SendFakePack(curPlayer, actInfo)  | 
|     return  | 
|   | 
|   | 
| def DoActBossOnKilledLogic(npcRankHurtMgr):  | 
|     ## »î¶¯boss±»»÷ɱ  | 
|     #  @param rankHurtList: NPCHurtMgr.PlayerRankHurtList  | 
|       | 
|     npcID = npcRankHurtMgr.npcID  | 
|       | 
|     # Êܽ±Àø´ÎÊýÓ°ÏìµÄÎïÆ·µôÂä¸ÅÂÊ {NPCID:[[ÎïÆ·ID,¸öÊý, ÊÇ·ñÅÄÆ·, µôÂäÍò·ÖÂÊ], ...], ...}£¬¸ù¾Ý½±Àø´ÎÊýËæ»ú¶à´Î£¬×¢Òâ¸ÃÅäÖ÷DZýͼ£¬Ã¿ÖÖÎïÆ·¶¼»á¶ÀÁ¢ÅÐ¶Ï  | 
|     dropByPlayerCountInfo = IpyGameDataPY.GetFuncEvalCfg("HorsePetFeast", 2, {})  | 
|     if npcID not in dropByPlayerCountInfo:  | 
|         return  | 
|     # ²»Êܽ±Àø´ÎÊýÓ°ÏìµÄÎïÆ·µôÂä¸ÅÂÊ {NPCID:[[ÎïÆ·ID,¸öÊý, ÊÇ·ñÅÄÆ·, µôÂäÍò·ÖÂÊ], ...], ...}£¬½öËæ»úÒ»´Î£¬×¢Òâ¸ÃÅäÖ÷DZýͼ£¬Ã¿ÖÖÎïÆ·¶¼»á¶ÀÁ¢ÅÐ¶Ï  | 
|     dropOneChanceInfo = IpyGameDataPY.GetFuncEvalCfg("HorsePetFeast", 3, {})  | 
|       | 
|     GameWorld.Log("Æï³èÊ¢Ñç»î¶¯boss±»»÷ɱ: npcID=%s" % (npcID))  | 
|       | 
|     curNPC = npcRankHurtMgr.curNPC  | 
|       | 
|     awardPlayerDict = {}  | 
|     copyPlayerManager = GameWorld.GetMapCopyPlayerManager()  | 
|     for index in xrange(npcRankHurtMgr.GetHurtCount()):  | 
|         hurtObj = npcRankHurtMgr.GetHurtAt(index)  | 
|         if hurtObj.GetValueType() != ChConfig.Def_NPCHurtTypePlayer:  | 
|             continue  | 
|         playerID = hurtObj.GetValueID()  | 
|         hurtPlayer = copyPlayerManager.FindPlayerByID(playerID)  | 
|         if not hurtPlayer or PlayerTJG.GetIsTJG(hurtPlayer):  | 
|             continue  | 
|         if curNPC and not hurtPlayer.CanSeeOther(curNPC):  | 
|             GameWorld.Log("    ÉËÑªÍæ¼Ò²»ÔÚbossÊÓÒ°ÄÚ£¬ÎÞ·¨»ñµÃ½±Àø!playerPos(%s,%s), npcPos(%s,%s)"   | 
|                           % (hurtPlayer.GetPosX(), hurtPlayer.GetPosY(), curNPC.GetPosX(), curNPC.GetPosY()))  | 
|             continue  | 
|         awardPlayerDict[playerID] = hurtPlayer  | 
|           | 
|     awardPlayerIDList = awardPlayerDict.keys()  | 
|     GameWorld.Log("    ½±ÀøÍæ¼ÒÈËÊý=%s, awardPlayerIDList=%s" % (len(awardPlayerIDList), awardPlayerIDList))  | 
|     if not awardPlayerDict:  | 
|         return  | 
|     awardRandCount = len(awardPlayerIDList)  | 
|       | 
|     awardRandCountMin, awardRandCountMax = IpyGameDataPY.GetFuncEvalCfg("HorsePetFeast", 1, [])  | 
|     awardRandCount = max(awardRandCountMin, min(awardRandCountMax, awardRandCount))  | 
|     GameWorld.Log("    ½±ÀøËæ»ú´ÎÊý: %s" % awardRandCount)  | 
|       | 
|     dropPosX, dropPosY = curNPC.GetPosX(), curNPC.GetPosY()  | 
|     awardByPlayerCountList = dropByPlayerCountInfo[npcID]  | 
|     awardOneChanceList = dropOneChanceInfo.get(npcID, [])  | 
|     for playerID, hurtPlayer in awardPlayerDict.items():  | 
|         awardItemList = []  | 
|         for itemID, itemCount, isAuctionItem, dropRate in awardByPlayerCountList:  | 
|             dropCountTotal = 0  | 
|             for _ in xrange(awardRandCount):  | 
|                 if dropRate < ShareDefine.Def_MaxRateValue and not GameWorld.CanHappen(dropRate):  | 
|                     continue  | 
|                 dropCountTotal += itemCount  | 
|             if not dropCountTotal:  | 
|                 continue  | 
|             awardItemList.append([itemID, dropCountTotal, isAuctionItem])  | 
|               | 
|         for itemID, itemCount, isAuctionItem, dropRate in awardOneChanceList:  | 
|             if not GameWorld.CanHappen(dropRate):  | 
|                 continue  | 
|             awardItemList.append([itemID, itemCount, isAuctionItem])  | 
|               | 
|         GameWorld.Log("        Íæ¼ÒµôÂä: %s" % awardItemList, playerID)  | 
|         if not awardItemList:  | 
|             continue  | 
|           | 
|         # Ö±½Ó¸øÎïÆ·²¢Õ¹Ê¾ÐéÄâµôÂä  | 
|         NPCCommon.DoGiveItemByVirtualDrop(hurtPlayer, awardItemList, npcID, dropPosX, dropPosY)  | 
|           | 
|     return  | 
|   |