| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package GameWorldLogic.FBProcess.GameLogic_GatherSoul  | 
| #  | 
| # @todo:¾Û»ê¸±±¾  | 
| # @author xdh  | 
| # @date 2018-12-12  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: ¾Û»ê¸±±¾  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2018-12-12 21:00"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import FBCommon  | 
| import GameWorld  | 
| import ItemCommon  | 
| import IPY_GameWorld  | 
| import GameWorldProcess  | 
| import PyGameData  | 
| import NPCCustomRefresh  | 
| import ChConfig  | 
| import ShareDefine  | 
| import EventReport  | 
| import PlayerControl  | 
| import ItemControler  | 
| import ChNPC  | 
|   | 
| #---¸±±¾ÅäÖöÔÓ¦keyÖµ---  | 
| (  | 
| Def_FightTime,  # ½øÐÐʱ¼ä(Ãë)  | 
| Def_LeaveTime,  # Í˳öʱ¼ä(Ãë)  | 
| Def_BuildNPCID,  # ½¨ÔìµãNPCID  | 
| Def_BuildCnt,  # ½¨ÔìµãÊýÁ¿  | 
| Def_BuildMark,  # ½¨Ôìµã±êʶµã  | 
| Def_BuildTime,  # ½¨Ôìʱ¼äºÁÃë  | 
| Def_GuardInfo,  #{ÊØÎÀnpcid:×î´óÊýÁ¿}  | 
| Def_BossID,  # »Æ½ðBOSSID  | 
| Def_BossCostMoney,  # ÕÙ»½»Æ½ðBOSSÐèÒª½ðÇ®  | 
| Def_NPCRefreshMark,  # ¹ÖÎïˢбêʶµã  | 
| Def_NPCRefreshCD,  # Ð¡¹Ö¼ä¸ôʱ¼äºÁÃë  | 
| Def_WheelRefreshCD,  # Ã¿²¨¼ä¸ôʱ¼äºÁÃë  | 
| ) = range(12)  | 
|   | 
| #µ±Ç°¸±±¾µØÍ¼µÄ״̬  | 
| (  | 
| FB_Step_Open,  # ¸±±¾¿ªÆô  | 
| FB_Step_Prepare,  # ½¨ÔìÊØÎÀ  | 
| FB_Step_Fighting,  # Ë¢¹ÖÖÐ  | 
| FB_Step_Over,  # ¸±±¾½áÊø  | 
| FB_Step_Close,  # ¸±±¾¹Ø±Õ  | 
| ) = range(5)  | 
|   | 
|   | 
| FBPlayerDict_GuardNPCID = 'FBPlayerDict_GuardNPCID'  # ÐèˢеÄÊØÎÀID  | 
| FBPlayerDict_GuardNPCCnt = 'FBPlayerDict_GuardNPCCnt%s'  # ÊØÎÀÒÑË¢ÐÂÊýÁ¿  | 
| FBPlayerDict_CurWheel = 'FBPlayerDict_CurWheel'  # µ±Ç°µÚ¼¸²¨¹Ö  | 
| FBPlayerDict_NPCIndex = 'FBPlayerDict_NPCIndex'  # ±¾²¨¹ÖµÚ¼¸Ö»  | 
| FBPlayerDict_LastWheelEndTime = 'FBPlayerDict_LastWheelEndTime'  # ÉÏÒ»²¨½áÊøÊ±¼ä  | 
| FBPlayerDict_LastNPCRTime = 'FBPlayerDict_LastNPCRTime'  # ÉÏÒ»Ö»¹ÖÎïË¢ÐÂʱ¼ä  | 
| FBPlayerDict_HasRefreshBoss = 'FBPlayerDict_HasRefreshBoss'  # ±¾²¨ÊÇ·ñÒÑË¢»Æ½ðBOSS  | 
| FBPlayerDict_AutoBoss = 'FBPlayerDict_AutoBoss'  # ÊÇ·ñ×Ô¶¯Ë¢»Æ½ðboss  | 
| FBPlayerDict_NPCRemainCnt = 'FBPlayerDict_NPCRemainCnt'  # NPCÊ£ÓàÊýÁ¿  | 
|   | 
|   | 
| ##---»ñµÃ¸±±¾ÅäÖÃ---  | 
| #  @param None  | 
| #  @return ÅäÖÃÐÅÏ¢  | 
| def GetGatherSoulFBCfg():  | 
|     return FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_GatherSoul, 0)  | 
|   | 
|   | 
| def GetGatherSoulNPCCfg():  | 
|     return FBCommon.GetFBLineRefreshNPC(ChConfig.Def_FBMapID_GatherSoul)  | 
|   | 
|   | 
| ## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë  | 
| #  @param curPlayer Íæ¼ÒʵÀý  | 
| #  @param mapID µØÍ¼ID  | 
| #  @param lineID Ïß·id  | 
| #  @param tick Ê±¼ä´Á  | 
| #  @return ²¼¶ûÖµ  | 
| def OnEnterFBEvent(curPlayer, mapID, lineID, tick):  | 
|     return True  | 
|   | 
|   | 
| ##¸±±¾Íæ¼Ò½øÈëµã  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param mapID µØÍ¼ID  | 
| # @param lineId ·ÖÏßID  | 
| # @param ipyEnterPosInfo ¹¦ÄÜÏß·IPYÅäÖÃ×ø±êÐÅÏ¢  | 
| # @param tick Ê±¼ä´Á  | 
| # @return posX, posY, Ëæ»ú°ë¾¶(¿ÉÑ¡)  | 
| def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):  | 
|     return ipyEnterPosInfo  | 
|   | 
|   | 
| ##²éѯÊÇ·ñ¿ÉÒÔ½øÈëµØÍ¼  | 
| # @param ask:ÇëÇó½á¹¹Ìå(IPY_BMChangeMapAsk)  | 
| # @param tick:ʱ¼ä´Á  | 
| # @return IPY_GameWorld.cme Ã¶¾Ù  | 
| def OnChangeMapAsk(ask, tick):  | 
|     return IPY_GameWorld.cmeAccept  | 
|   | 
|   | 
| ##¿ªÆô¸±±¾  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ¿ªÆô¸±±¾  | 
| def OnOpenFB(tick):  | 
|     #Ë¢½¨Ôìµã  | 
|     gatherSoulFBCfg = GetGatherSoulFBCfg()  | 
|     NPCCustomRefresh.SetNPCRefresh(gatherSoulFBCfg[Def_BuildMark], [(gatherSoulFBCfg[Def_BuildNPCID], 1)], 1, gatherSoulFBCfg[Def_BuildCnt])  | 
|     return  | 
|   | 
| ##¹Ø±Õ¸±±¾  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks   | 
| def OnCloseFB(tick):  | 
|     __DoGatherSoulOver()  | 
|     return  | 
|   | 
| ## ½ø¸±±¾  | 
| #  @param curPlayer  | 
| #  @param tick  | 
| #  @return None  | 
| def DoEnterFB(curPlayer, tick):  | 
|     PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default * 3)  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     playerLV = curPlayer.GetLV()  | 
|     mapID = GameWorld.GetMap().GetMapID()  | 
|     mapID = FBCommon.GetRecordMapID(mapID)  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     lineID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ReqFBFuncLine)  | 
|     GameWorld.DebugLog("DoEnterFB...lineID=%s,playerLV=%s" % (lineID, playerLV), playerID)  | 
|     hadDelTicket = FBCommon.GetHadDelTicket(curPlayer)  | 
|     if not hadDelTicket:  | 
|         FBCommon.SetHadDelTicket(curPlayer)  | 
|         FBCommon.SetFBPropertyMark(lineID)  | 
|         EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_GatherSoul, 0, ChConfig.CME_Log_Start)  | 
|       | 
|     fbStep = gameFB.GetFBStep()  | 
|     if fbStep < FB_Step_Prepare:  | 
|         FBCommon.SetFBStep(FB_Step_Prepare, tick)  | 
|           | 
|     if fbStep < FB_Step_Over:  | 
|         notify_tick = GetGatherSoulFBCfg()[Def_FightTime] * 1000 - (tick - GameWorld.GetGameWorld().GetOpenFBTick())  | 
|         curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, max(notify_tick, 0), True)  | 
|     else:  | 
|         return  | 
|     DoFBHelp(curPlayer, tick)  | 
|     curPlayer.SetFaction(ShareDefine.CampType_Justice)  | 
|     return  | 
|   | 
|   | 
| ##Íæ¼ÒÍ˳ö¸±±¾  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| def DoExitFB(curPlayer, tick):  | 
|     PlayerControl.SetSight(curPlayer, ChConfig.Def_PlayerSight_Default)  | 
|     fbStep = GameWorld.GetGameFB().GetFBStep()  | 
|     if fbStep >= FB_Step_Over:  | 
|         GameWorldProcess.CloseFB(tick)  | 
|     return  | 
|   | 
|   | 
| ##Íæ¼ÒÖ÷¶¯À뿪¸±±¾.  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| def DoPlayerLeaveFB(curPlayer, tick):  | 
|     __DoGatherSoulOver()  | 
|     GameWorldProcess.CloseFB(tick)  | 
|     return    | 
|   | 
|   | 
| ## »ñµÃ¸±±¾°ïÖúÐÅÏ¢  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò£¨±»Í¨Öª¶ÔÏó£©  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| def DoFBHelp(curPlayer, tick):  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     fbStep = gameFB.GetFBStep()  | 
|     if fbStep > FB_Step_Fighting:  | 
|         return  | 
|     curWheel = gameFB.GetGameFBDictByKey(FBPlayerDict_CurWheel)  | 
|     maxWheel = len(GetGatherSoulNPCCfg())  | 
|     curWheel = 0 if fbStep == FB_Step_Prepare else min(curWheel+1, maxWheel)  | 
|     gatherSoulFBCfg = GetGatherSoulFBCfg()  | 
|     guardDict = {}  | 
|     for npcid in gatherSoulFBCfg[Def_GuardInfo]:  | 
|         guardDict[npcid] = gameFB.GetGameFBDictByKey(FBPlayerDict_GuardNPCCnt%npcid)  | 
|     hasRefreshBoss = gameFB.GetGameFBDictByKey(FBPlayerDict_HasRefreshBoss)  | 
|     isAutoBoss = gameFB.GetGameFBDictByKey(FBPlayerDict_AutoBoss)  | 
|     lineID = GameWorld.GetGameWorld().GetLineID()  | 
|     itemDict = PyGameData.g_gathersoulfbAwardDict.get(lineID, {})  | 
|     helpItemInfo = {}  | 
|     for wheel, itemList in itemDict.items():  | 
|         helpItemInfo[str(wheel)] = FBCommon.GetJsonItemList(itemList)  | 
|     helpDict = {FBCommon.Help_wheel:curWheel,   | 
|                 FBCommon.Help_step:fbStep,   | 
|                 FBCommon.Help_npc:FBCommon.GetJsonNPCKillList(guardDict),  | 
|                 FBCommon.Help_isAuto:isAutoBoss,  | 
|                 FBCommon.Help_hasRefreshBoss:hasRefreshBoss,  | 
|                 FBCommon.Help_gsItemInfo:helpItemInfo,  | 
|                 }  | 
|     #¸±±¾°ïÖú  | 
|     GameWorld.DebugLog("DoFBHelp %s" % str(helpDict))  | 
|     FBCommon.Notify_FBHelp(curPlayer, helpDict)  | 
|     return  | 
|   | 
|   | 
| ##---¸±±¾×ÜÂß¼¼ÆÊ±Æ÷---  | 
| # @param tick:ʱ¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks ¸±±¾×ÜÂß¼¼ÆÊ±Æ÷  | 
| def OnProcess(tick):  | 
|     fbStep = GameWorld.GetGameFB().GetFBStep()  | 
|       | 
|     # ¸±±¾½øÐÐÖÐ  | 
|     if fbStep == FB_Step_Fighting:  | 
|         __DoLogic_FB_Fighting(tick)  | 
|     # ¸±±¾½áÊø  | 
|     elif fbStep == FB_Step_Over:  | 
|         __DoLogic_FB_Over(tick)  | 
|       | 
|     return  | 
|   | 
|   | 
| def __CheckNPCRefresh(tick):  | 
|     gameFB = GameWorld.GetGameFB()  | 
|       | 
|     gatherSoulFBCfg = GetGatherSoulFBCfg()  | 
|       | 
|     lastWheelEndTime = gameFB.GetGameFBDictByKey(FBPlayerDict_LastWheelEndTime)  | 
|     if lastWheelEndTime and tick - lastWheelEndTime < gatherSoulFBCfg[Def_WheelRefreshCD]:  | 
|         return  | 
|     lastNPCRTime = gameFB.GetGameFBDictByKey(FBPlayerDict_LastNPCRTime)  | 
|     if lastNPCRTime and tick - lastNPCRTime < gatherSoulFBCfg[Def_NPCRefreshCD]:  | 
|         return  | 
|       | 
|     curWheel = gameFB.GetGameFBDictByKey(FBPlayerDict_CurWheel)  | 
|     curNPCIndex = gameFB.GetGameFBDictByKey(FBPlayerDict_NPCIndex)  | 
|     npcRereshList = GetGatherSoulNPCCfg()  #[[npcid,npcid,],[],[]]  | 
|     if curWheel >= len(npcRereshList):  | 
|         return  | 
|     npcList = npcRereshList[curWheel]  | 
|     if curNPCIndex >= len(npcList):  | 
|         return  | 
|       | 
|     GameWorld.DebugLog('    ¿ªÊ¼Ë¢µÚ%s²¨µÚ%sÖ»¹Ö£¡' % (curWheel + 1, curNPCIndex + 1))  | 
|       | 
|     refreshNPCid = npcList[curNPCIndex]  #±¾´ÎҪˢеÄNPC  | 
| #    npcCntDict = {}  #±êʶµã¶ÔÓ¦ÊýÁ¿  | 
|       | 
| #    gameNPC = GameWorld.GetNPCManager()  | 
| #    for i in xrange(gameNPC.GetCustomNPCRefreshCount()):  | 
| #        npcRefresh = gameNPC.GetCustomNPCRefreshAt(i)  | 
| #        rmark = npcRefresh.GetRefreshMark()  | 
| #        npcCntDict[rmark] = npcCntDict.get(rmark, npcRefresh.GetCount())  | 
|     __RefreshNPC(refreshNPCid)  | 
|       | 
|     if curNPCIndex + 1 >= len(npcList):  | 
|         if curWheel + 1 >= len(npcRereshList):  | 
|             GameWorld.DebugLog('    È«²¿Ð¡¹ÖË¢Í꣡')  | 
|    | 
|     gameFB.SetGameFBDict(FBPlayerDict_NPCIndex, curNPCIndex + 1)  | 
|     gameFB.SetGameFBDict(FBPlayerDict_LastNPCRTime, tick)  | 
|       | 
|     curPlayer = FBCommon.GetCurSingleFBPlayer()  | 
|     if curPlayer:  | 
|         DoFBHelp(curPlayer, tick)  | 
|     return  | 
|   | 
| def __RefreshNPC(refreshNPCid):  | 
|     #Ë¢1Ö»¹ÖÎï  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     curRemainCnt = gameFB.GetGameFBDictByKey(FBPlayerDict_NPCRemainCnt)  | 
|     curMaxCnt = curRemainCnt + 1  | 
|     gatherSoulFBCfg = GetGatherSoulFBCfg()  | 
|     refreshMark = gatherSoulFBCfg[Def_NPCRefreshMark]  | 
|     NPCCustomRefresh.SetNPCRefresh(refreshMark, [refreshNPCid], curMaxCnt, 1)  | 
|     gameFB.SetGameFBDict(FBPlayerDict_NPCRemainCnt, curMaxCnt)  | 
|     return  | 
|   | 
| ## ¸±±¾½øÐÐÖÐ  | 
| #  @param tick:ʱ¼ä´Á  | 
| #  @return ÎÞÒâÒå  | 
| def __DoLogic_FB_Fighting(tick):  | 
|     __CheckNPCRefresh(tick)  | 
|     __CheckAutoRefreshGoldBoss(tick)  | 
|       | 
|     fbCfg = GetGatherSoulNPCCfg()  | 
|     # ¼ä¸ôδµ½  | 
|     if tick - GameWorld.GetGameWorld().GetOpenFBTick() < fbCfg[Def_FightTime] * 1000:  | 
|         return  | 
|       | 
|     __DoGatherSoulOver()  | 
|     return  | 
|   | 
|           | 
| ##¸±±¾¹Ø±ÕÖÐ  | 
| # @param tick:ʱ¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks ¸±±¾¹Ø±ÕÖÐ  | 
| def __DoLogic_FB_Over(tick):  | 
|   | 
|     #gameFB = GameWorld.GetGameFB()  | 
|     fbCfg = GetGatherSoulNPCCfg()  | 
|     # ¼ä¸ôδµ½  | 
|     if tick - GameWorld.GetGameFB().GetFBStepTick() < fbCfg[Def_LeaveTime] * 1000:  | 
|         return  | 
|       | 
|     #¸±±¾¹Ø±Õ  | 
|     GameWorldProcess.CloseFB(tick)  | 
|     FBCommon.SetFBStep(FB_Step_Close, tick)  | 
|     return  | 
|   | 
| def DoFB_NPCDead(curNPC):  | 
|     npcRereshList = GetGatherSoulNPCCfg()  | 
|     npcidlist = [GetGatherSoulFBCfg()[Def_BossID]]  | 
|     for nlist in npcRereshList:  | 
|         npcidlist += nlist  | 
|     if curNPC.GetNPCID() not in npcidlist:  | 
|         return  | 
|       | 
|     gameFB = GameWorld.GetGameFB()  | 
|     curRemainCnt = gameFB.GetGameFBDictByKey(FBPlayerDict_NPCRemainCnt)  | 
|     newRemainCnt = max(0, curRemainCnt - 1)  | 
|     gameFB.SetGameFBDict(FBPlayerDict_NPCRemainCnt, newRemainCnt)  | 
|       | 
|     curWheel = gameFB.GetGameFBDictByKey(FBPlayerDict_CurWheel)  | 
|     curNPCIndex = gameFB.GetGameFBDictByKey(FBPlayerDict_NPCIndex)  | 
|       | 
|     if newRemainCnt <= 0 and curNPCIndex >= len(npcRereshList[curWheel]):  | 
|         #±¾²¨µÄ¹Ö¶¼ËÀµôÁË  | 
|         gameFB.SetGameFBDict(FBPlayerDict_CurWheel, curWheel + 1)  | 
|         gameFB.SetGameFBDict(FBPlayerDict_HasRefreshBoss, 0)  | 
|         curPlayer = FBCommon.GetCurSingleFBPlayer()  | 
|         if curPlayer:  | 
|             DoFBHelp(curPlayer, GameWorld.GetGameWorld().GetTick())  | 
|         if curWheel + 1>=len(npcRereshList):  | 
|             #ËùÓв¨µÄ¹Ö¶¼ËÀÁË£¬½áÊø  | 
|             __DoGatherSoulOver()  | 
|         else:  | 
|             #½øÈëÏÂÒ»²¨  | 
|             gameFB.SetGameFBDict(FBPlayerDict_NPCIndex, 0)  | 
|             gameFB.SetGameFBDict(FBPlayerDict_LastWheelEndTime, GameWorld.GetGameWorld().GetTick())  | 
|             gameFB.SetGameFBDict(FBPlayerDict_LastNPCRTime, 0)  | 
|             if curPlayer:  | 
|                 curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveFamilyWar, 0, GetGatherSoulFBCfg()[Def_WheelRefreshCD], True)  | 
|                       | 
|     return  | 
|   | 
| ##ÊÇ·ñ¿ÉÒÔ¶áÆì  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curNPC NPCʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks  | 
| def OnCanCollect(curPlayer, curNPC, tick):  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     guardNPCID = gameFB.GetGameFBDictByKey(FBPlayerDict_GuardNPCID)  | 
|     gatherSoulFBCfg = GetGatherSoulFBCfg()  | 
|     guardMaxCntDict = gatherSoulFBCfg[Def_GuardInfo]  | 
|     if guardNPCID not in guardMaxCntDict:  | 
|         return False  | 
|     curCnt = gameFB.GetGameFBDictByKey(FBPlayerDict_GuardNPCCnt % guardNPCID)  | 
|     if curCnt >= guardMaxCntDict[guardNPCID]:  | 
|         GameWorld.Log('    ¸ÃÊØÎÀÒÑÂú£¬²»¿ÉÔÙ½¨Ôì guardNPCID=%s,curCnt=%s' % (guardNPCID, curCnt))  | 
|         return False  | 
|     return True  | 
|   | 
|   | 
| ##¸±±¾ÖÐ,Õ¼ÁìNPCµÄLoadingʱ¼ä.  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curNPC NPCʵÀý  | 
| # @return ·µ»ØÖµ, Loadingʱ¼ä  | 
| # @remarks ¸±±¾ÖÐ,Õ¼ÁìNPCµÄLoadingʱ¼ä  | 
| def GetFBPrepareTime(curPlayer, curNPC):  | 
|     return GetGatherSoulFBCfg()[Def_BuildTime]  | 
|   | 
|   | 
| ##Íæ¼ÒÊÕ¼¯³É¹¦(Ëþ, Æì)  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks  | 
| def OnCollectOK(curPlayer, npcID, tick):  | 
|     tagObj = curPlayer.GetActionObj()  | 
|     if not tagObj:  | 
|         return  | 
|     if tagObj.GetGameObjType() != IPY_GameWorld.gotNPC:  | 
|         return  | 
|       | 
|     curNPC = GameWorld.GetNPCManager().GetNPCByIndex(tagObj.GetIndex())  | 
|     if not curNPC:  | 
|         return  | 
|     gatherSoulFBCfg = GetGatherSoulFBCfg()  | 
|     if curNPC.GetNPCID() != gatherSoulFBCfg[Def_BuildNPCID]:  | 
|         return  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     guardNPCID = gameFB.GetGameFBDictByKey(FBPlayerDict_GuardNPCID)  | 
|     if not guardNPCID:  | 
|         GameWorld.ErrLog('²É¼¯Ç°Î´Ö¸¶¨Òª½¨ÔìNPCID', curPlayer.GetID())  | 
|         return  | 
|     ChNPC.OnCollectEnd(curPlayer, curNPC)  | 
|     #Ë¢ÊØÎÀ  | 
|     NPCCustomRefresh.SetNPCRefresh(gatherSoulFBCfg[Def_BuildMark], [(guardNPCID, 1)], 1, 1)  | 
|     key = FBPlayerDict_GuardNPCCnt % guardNPCID  | 
|     gameFB.SetGameFBDict(key, gameFB.GetGameFBDictByKey(key) + 1)  | 
|     gameFB.SetGameFBDict(FBPlayerDict_GuardNPCID, 0)  | 
|     DoFBHelp(curPlayer, tick)  | 
|     return  | 
|   | 
|   | 
| ## ¸±±¾ÐÐΪ  | 
| #  @param curPlayer Íæ¼Ò  | 
| #  @param actionType ÐÐΪÀàÐÍ  | 
| #  @param actionInfo ÐÐΪÐÅÏ¢  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| def DoFBAction(curPlayer, actionType, actionInfo, tick):  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     gatherSoulFBCfg = GetGatherSoulFBCfg()  | 
|     fbStep = gameFB.GetFBStep()  | 
|     if actionType == 0:  #½¨ÔìÊØÎÀ   | 
|         if actionInfo not in gatherSoulFBCfg[Def_GuardInfo]:  | 
|             return  | 
|         gameFB.SetGameFBDict(FBPlayerDict_GuardNPCID, actionInfo)  | 
|           | 
|     elif actionType == 1:  #¿ªÊ¼Ë¢¹Ö   | 
|         if fbStep != FB_Step_Prepare:  | 
|             return  | 
|         FBCommon.SetFBStep(FB_Step_Fighting, tick)  | 
|         FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_GatherSoul)  | 
|     elif actionType == 2:  #ÕÙ»½»Æ½ðBOSS actionInfo 0-ÕÙ»½1´Î 1-×Ô¶¯ÕÙ»½ 2-È¡Ïû×Ô¶¯ÕÙ»½  | 
|         if fbStep != FB_Step_Fighting:  | 
|             return  | 
|         if actionInfo == 0:  | 
|             if gameFB.GetGameFBDictByKey(FBPlayerDict_HasRefreshBoss):  | 
|                 #±¾²¨ÒÑË¢»Æ½ðBOSS  | 
|                 PlayerControl.NotifyCode(curPlayer, 'JHCallForBoss1')  | 
|                 return  | 
|             #ÅжÏÇ®  | 
|             costMoney = gatherSoulFBCfg[Def_BossCostMoney]  | 
|             costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costMoney)  | 
|             if not costMoneyList:  | 
|                 return  | 
|             for moneyType, moneyCnt in costMoneyList:  | 
|                 PlayerControl.PayMoney(curPlayer, moneyType, moneyCnt, ChConfig.Def_Cost_FBGatherSoulBoss)  | 
|             #Á¢¼´Ë¢  | 
|             __RefreshNPC(gatherSoulFBCfg[Def_BossID])  | 
|             gameFB.SetGameFBDict(FBPlayerDict_HasRefreshBoss, 1)  | 
|         elif actionInfo == 1:  | 
|             if gameFB.GetGameFBDictByKey(FBPlayerDict_AutoBoss):  | 
|                 GameWorld.DebugLog('ÒѾÊÇ×Ô¶¯ÕÙ»½BOSS״̬£¡')  | 
|                 return  | 
|             gameFB.SetGameFBDict(FBPlayerDict_AutoBoss, 1)  | 
|         elif actionInfo == 2:  | 
|             if not gameFB.GetGameFBDictByKey(FBPlayerDict_AutoBoss):  | 
|                 GameWorld.DebugLog('²»ÊÇ×Ô¶¯ÕÙ»½BOSS״̬£¬²»ÐèҪȡÏû£¡')  | 
|                 return  | 
|             gameFB.SetGameFBDict(FBPlayerDict_AutoBoss, 0)  | 
|               | 
|     DoFBHelp(curPlayer, tick)  | 
|     return  | 
|   | 
| def __CheckAutoRefreshGoldBoss(tick):  | 
|     ##×Ô¶¯ÕÙ»½»Æ½ðBOSS  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     if not gameFB.GetGameFBDictByKey(FBPlayerDict_AutoBoss):  | 
|         return  | 
|     curPlayer = FBCommon.GetCurSingleFBPlayer()  | 
|     if not curPlayer:  | 
|         gameFB.SetGameFBDict(FBPlayerDict_AutoBoss, 0)  | 
|         return  | 
|     fbStep = gameFB.GetFBStep()  | 
|     if fbStep != FB_Step_Fighting:  | 
|         gameFB.SetGameFBDict(FBPlayerDict_AutoBoss, 0)  | 
|         return  | 
|     if gameFB.GetGameFBDictByKey(FBPlayerDict_HasRefreshBoss):  | 
|         #±¾²¨ÒÑË¢»Æ½ðBOSS  | 
|         return  | 
|     gatherSoulFBCfg = GetGatherSoulFBCfg()  | 
|     lastWheelEndTime = gameFB.GetGameFBDictByKey(FBPlayerDict_LastWheelEndTime)  | 
|     if lastWheelEndTime and tick - lastWheelEndTime < gatherSoulFBCfg[Def_WheelRefreshCD]:  | 
|         return  | 
|       | 
|       | 
|     costMoney = gatherSoulFBCfg[Def_BossCostMoney]  | 
|     costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costMoney, False)  | 
|     if not costMoneyList:  | 
|         PlayerControl.NotifyCode(curPlayer, 'JHCallForBoss2')  | 
|         gameFB.SetGameFBDict(FBPlayerDict_AutoBoss, 0)  | 
|     else:  | 
|         for moneyType, moneyCnt in costMoneyList:  | 
|             PlayerControl.PayMoney(curPlayer, moneyType, moneyCnt, ChConfig.Def_Cost_FBGatherSoulBoss)  | 
|         #Á¢¼´Ë¢  | 
|         __RefreshNPC(gatherSoulFBCfg[Def_BossID])  | 
|           | 
|         gameFB.SetGameFBDict(FBPlayerDict_HasRefreshBoss, 1)  | 
|     DoFBHelp(curPlayer, tick)  | 
|     return  | 
|   | 
|   | 
| ## ÊÇ·ñ¸±±¾¸´»î  | 
| #  @param None  | 
| #  @return ÊÇ·ñ¸±±¾¸´»î  | 
| def OnPlayerReborn():  | 
|     return True  | 
|   | 
|   | 
| ##Íæ¼ÒËÀÍö.  | 
| # @param curPlayer:ËÀÍöµÄÍæ¼Ò   | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks Íæ¼ÒÖ÷¶¯À뿪¸±±¾.  | 
| def DoPlayerDead(curPlayer):  | 
|       | 
|     return  | 
|   | 
|   | 
| ## ¼ì²éÊÇ·ñ¿É¹¥»÷£¬ Ö÷Åж¨²»¿É¹¥»÷µÄÇé¿ö£¬ÆäËûÂß¼ÓÉÍâ²ã¾ö¶¨  | 
| #  @param attacker ¹¥»÷·½  | 
| #  @param defender ·ÀÊØ·½  | 
| #  @return bool  | 
| def CheckCanAttackTagObjInFB(attacker, defender):  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     if gameFB.GetFBStep() != FB_Step_Fighting:  | 
|         return False  | 
|     return True  | 
|   | 
| def KillGatherSoulNPCDropAward(itemID, itemCnt, isBind):  | 
|     ##µôÂä½±Àø {wheel:[[itemid,itemCnt,isBind]]}  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     curWheel = gameFB.GetGameFBDictByKey(FBPlayerDict_CurWheel) + 1  | 
|     #ownerID = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_SingleFBPlayerID)  | 
|     lineID = GameWorld.GetGameWorld().GetLineID()  | 
|     if lineID not in PyGameData.g_gathersoulfbAwardDict:  | 
|         PyGameData.g_gathersoulfbAwardDict[lineID] = {}  | 
|     if curWheel not in PyGameData.g_gathersoulfbAwardDict[lineID]:  | 
|         PyGameData.g_gathersoulfbAwardDict[lineID][curWheel] = []  | 
|     PyGameData.g_gathersoulfbAwardDict[lineID][curWheel].append([itemID, itemCnt, isBind])  | 
|     curPlayer = FBCommon.GetCurSingleFBPlayer()  | 
|     if curPlayer:  | 
|         DoFBHelp(curPlayer, 0)  | 
|     return  | 
|   | 
| ## ¸±±¾½áÊø´¦Àí  | 
| def __DoGatherSoulOver():  | 
|     gameFB = GameWorld.GetGameFB()  | 
|     if gameFB.GetFBStep() == FB_Step_Over:  | 
|         return  | 
|       | 
|     tick = GameWorld.GetGameWorld().GetTick()  | 
|     # ½øÈëÀ뿪½×¶Î  | 
|     FBCommon.SetFBStep(FB_Step_Over, tick)  | 
|     ownerID = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_SingleFBPlayerID)  | 
|     lineID = GameWorld.GetGameWorld().GetLineID()  | 
|     itemDict = PyGameData.g_gathersoulfbAwardDict.pop(lineID, {})  | 
|     totalItemList = []  | 
|     for itemList in itemDict.values():  | 
|         totalItemList += itemList  | 
|     GameWorld.Log('   ¸±±¾½áÊø´¦Àí  itemDict=%s'%itemDict, ownerID)  | 
|     curPlayer = FBCommon.GetCurSingleFBPlayer()  | 
|     if not curPlayer:  | 
|         #½±ÀøÖ±½Ó·¢Óʼþ  | 
|         if totalItemList:  | 
|             PlayerControl.SendMailByKey('JHBagFull2', [ownerID], totalItemList)  | 
|           | 
|         GameWorldProcess.CloseFB(tick)  | 
|         return  | 
|     if totalItemList:  | 
|         needPackSpaceDict = {}  | 
|         for itemID, itemCnt, isBind in totalItemList:  | 
|             curItem = GameWorld.GetGameData().GetItemByTypeID(itemID)  | 
|             if not curItem:  | 
|                 return  | 
|             packType = ChConfig.GetItemPackType(curItem.GetType())  | 
|             needSpace = ItemControler.GetItemNeedPackCount(packType, curItem, itemCnt)  | 
|             needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace  | 
|               | 
|         isSendMail = False #ÊÇ·ñ±³°ü²»×ã  | 
|         for packType, needSpace in needPackSpaceDict.items():  | 
|             if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace):  | 
|                 isSendMail = True  | 
|                 break  | 
|       | 
|         if isSendMail:  | 
|             PlayerControl.SendMailByKey('JHBagFull2', [curPlayer.GetPlayerID()], totalItemList)  | 
|             GameWorld.DebugLog("±³°ü¿Õ¼ä²»¹»£¬·¢ËÍÓʼþ: mailItemList=%s" % str(totalItemList), curPlayer.GetPlayerID())  | 
|         else:  | 
|             for itemID, itemCnt, isBind in totalItemList:  | 
|                 ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [],  | 
|                                                 event=["GatherSoulFB", False, {}])  | 
|               | 
|     fbCfg = GetGatherSoulFBCfg()  | 
|     costTime = tick - GameWorld.GetGameWorld().GetOpenFBTick()  | 
|   | 
|     itemInfo = FBCommon.GetJsonItemList(totalItemList)  | 
|     __SendOverInfo(curPlayer, {FBCommon.Over_isPass:1, FBCommon.Over_costTime:costTime, FBCommon.Over_itemInfo:itemInfo})  | 
|       | 
|     FBCommon.Sync_Player_TimeTick(IPY_GameWorld.tttLeaveMap, fbCfg[Def_LeaveTime] * 1000)  | 
|     return  | 
|   | 
|   | 
| ## ·¢ËÍÌôÕ½½á¹ûÐÅÏ¢  | 
| def __SendOverInfo(curPlayer, overDict):  | 
|     overDict[FBCommon.Over_dataMapID] = ChConfig.Def_FBMapID_GatherSoul  | 
|     #overDict[FBCommon.Over_lineID] = FBCommon.GetFBPropertyMark()  | 
|     GameWorld.DebugLog("__SendOverInfo overDict=%s" % (str(overDict)), curPlayer.GetPlayerID())  | 
|     FBCommon.Notify_FB_Over(curPlayer, overDict)  | 
|     return  | 
|   |