| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package GameWorldLogic.FBProcess.GameLogic_FamilyParty  | 
| #  | 
| # @todo:Õ½ÃËÊ¢Ñç  | 
| # @author xdh  | 
| # @date 2018-04-16  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: Õ½ÃËÊ¢Ñç  | 
| #  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2018-04-16 17:20"""  | 
| #---------------------------------------------------------------------  | 
| import ShareDefine  | 
| import FBCommon  | 
| import ChConfig  | 
| import IPY_GameWorld  | 
| import PlayerControl  | 
| import GameWorld  | 
| import PlayerFamily  | 
| import IpyGameDataPY  | 
| import PlayerFeastTravel  | 
| import PlayerFairyCeremony  | 
| import PlayerNewFairyCeremony  | 
| import PlayerActLogin  | 
| import EventReport  | 
| import PyGameData  | 
| import ItemCommon  | 
| import ItemControler  | 
| import Item_AddLV  | 
| import PlayerTalk  | 
| import PlayerActivity  | 
| import PlayerWeekParty  | 
|   | 
| #---Õ½Ã˸±±¾---  | 
| FBPlayerDict_TagPlayerID = 'XMYH_TagPlayerID%s'  # ÑûÇë´«¹¦Ä¿±êÍæ¼ÒID  | 
|   | 
| g_familyMapPlayerIDDict = {}#{lineID:[playerID,..]}  | 
|   | 
| def OnDayFamilyPartyPlayer(curPlayer):  | 
|     GameWorld.DebugLog("ÖØÖÃÏÉÃËÑç»áÏà¹ØÊý¾Ý£¬º¬´«¹¦!", curPlayer.GetPlayerID())  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyJoinSign, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartySitState, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyHelpSitCount, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyCollectState, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyTotalExp, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyTotalExpPoint, 0)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyTotalPoint, 0)  | 
|     return  | 
|   | 
| ##¿ªÆô¸±±¾  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ¿ªÆô¸±±¾  | 
| def OnOpenFB(tick):  | 
|     return  | 
|   | 
|   | 
| ##¹Ø±Õ¸±±¾  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks   | 
| def OnCloseFB(tick):  | 
|     global g_familyMapPlayerIDDict  | 
|     lineID = GameWorld.GetGameWorld().GetLineID()  | 
|     g_familyMapPlayerIDDict.pop(lineID, None)  | 
|     return  | 
|   | 
|   | 
| ## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë  | 
| #  @param curPlayer Íæ¼ÒʵÀý  | 
| #  @param mapID µØÍ¼ID  | 
| #  @param lineID Ïß·id  | 
| #  @param tick Ê±¼ä´Á  | 
| #  @return ²¼¶ûÖµ  | 
| def OnEnterFBEvent(curPlayer, mapID, lineID, tick):  | 
|     return __CheckEnter(curPlayer, mapID)  | 
|   | 
|   | 
| ##½øÈ븱±¾¼ì²é  | 
| #  @param curPlayer Íæ¼ÒʵÀý  | 
| #  @param mapID µØÍ¼ID  | 
| #  @param lineID Ïß·id  | 
| # @return None  | 
| def __CheckEnter(curPlayer, mapID):  | 
|       | 
|     # ÊÇ·ñÓÐÕ½ÃË  | 
|     if curPlayer.GetFamilyID() <= 0:  | 
|         GameWorld.DebugLog("ûÓÐÕ½ÃË£¬²»ÄܽøÈëÕ½ÃËboss¸±±¾£¡")  | 
|         return False  | 
|       | 
|     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 ÇëÇó½á¹¹Ìå  | 
| # @param tick Ê±¼ä´Á  | 
| # @return  | 
| def OnChangeMapAsk(ask, tick):  | 
|     return IPY_GameWorld.cmeAccept  | 
|   | 
|   | 
| ##Íæ¼Ò½øÈ븱±¾  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks Íæ¼Ò½øÈ븱±¾  | 
| def DoEnterFB(curPlayer, tick):  | 
|     global g_familyMapPlayerIDDict  | 
|     mapID = GameWorld.GetGameWorld().GetMapID()  | 
|     playerID = curPlayer.GetPlayerID()  | 
|     if not __CheckEnter(curPlayer, mapID):  | 
|         PlayerControl.PlayerLeaveFB(curPlayer)  | 
|         return  | 
|       | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     partyActionState = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyParty)  | 
|     if partyActionState:  | 
|         remainSeconds = PlayerActivity.GetDailyActionRemainSeconds(ShareDefine.DailyActionID_FamilyParty)  | 
|         __DoEnterJoinFamilyParty(curPlayer, remainSeconds)  | 
|           | 
|     lineID = GameWorld.GetGameWorld().GetLineID()  | 
|     if lineID not in g_familyMapPlayerIDDict:  | 
|         g_familyMapPlayerIDDict[lineID] = []  | 
|     if playerID not in g_familyMapPlayerIDDict[lineID]:  | 
|         g_familyMapPlayerIDDict[lineID].append(playerID)  | 
|       | 
|     playerManager = GameWorld.GetMapCopyPlayerManager()  | 
|     for index in xrange(playerManager.GetPlayerCount()):  | 
|         curPlayer = playerManager.GetPlayerByIndex(index)  | 
|         if not curPlayer:  | 
|             continue  | 
|         DoFBHelp(curPlayer, tick, True)  | 
|           | 
|     return  | 
|   | 
| def __DoEnterJoinFamilyParty(curPlayer, remainSeconds):  | 
|     ## Íæ¼ÒÕýʽ¿ªÊ¼²ÎÓëÏÉÃËÑç»á£¬ÒòΪ¶à¸öÏÉÃ˻¿ÉÄܹ²ÓøõØÍ¼£¬Íæ¼Ò¿ÉÄܻ¿ªÊ¼Ê±ÒѾÔڸõØÍ¼  | 
|     GameWorld.DebugLog("Íæ¼Ò²Î¼ÓÏÉÃËÑç»á!remainSeconds=%s" % remainSeconds, curPlayer.GetPlayerID())  | 
|     if remainSeconds:  | 
|         curPlayer.Sync_TimeTick(IPY_GameWorld.tttTowerTake, 0, remainSeconds * 1000, True)  | 
|           | 
|     if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyJoinSign):  | 
|         return  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyJoinSign, 1)  | 
|       | 
|     #FBCommon.AddEnterFBCount(curPlayer, ChConfig.Def_FBMapID_FamilyParty)  | 
|     PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_FamilyParty)  | 
|     PlayerFamily.AddFamilyActivity(curPlayer, ShareDefine.FamilyActive_Party)  | 
|     EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_FamilyParty, 0, ChConfig.CME_Log_Start)  | 
|     PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_FamilyParty, 1)  | 
|     PlayerNewFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_FamilyParty, 1)  | 
|     PlayerFeastTravel.AddFeastTravelTaskValue(curPlayer, ChConfig.Def_FeastTravel_FamilyParty, 1)  | 
|     PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_FamilyParty, 1)  | 
|     return  | 
|   | 
| ## ÊÇ·ñ¿ÉÒÔ»ñµÃ¸±±¾µØÍ¼ÇøÓò¾Ñé  | 
| def OnCanGetAreaExp(curPlayer):  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     partyActionState = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyParty)  | 
|     return partyActionState  | 
|   | 
| ##¸±±¾¶¨Ê±Æ÷  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ¸±±¾¶¨Ê±Æ÷  | 
| def OnProcess(tick):  | 
|     familyID = GameWorld.GetGameWorld().GetPropertyID()  | 
|     if not familyID:  | 
|         return  | 
|       | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     partyActionState = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyParty)  | 
|     if partyActionState:  | 
|         FBCommon.NotifyCopyMapPlayerFBHelp(tick, DoFBHelp, 5000)  | 
|           | 
|     return  | 
|   | 
|   | 
| def FamilyPartyAnswerRight(curPlayer, answerInfo):  | 
|     #»Ø´ðÕýÈ·£¬¸ø½±Àø  | 
|       | 
|     rightPlayerID = answerInfo[0]  | 
|       | 
|     #¸ø±¾Ìâ´ðÌâ½±Àø£¬±¾µØÍ¼ÖеļÒ×å³ÉÔ±²Å¸ø  | 
|     answerRWItemReward = IpyGameDataPY.GetFuncEvalCfg('PartyReward2', 1)  | 
|     rightItemID, wrongItemID = answerRWItemReward  | 
|     playerManager = GameWorld.GetMapCopyPlayerManager()  | 
|     for index in xrange(playerManager.GetPlayerCount()):  | 
|         player = playerManager.GetPlayerByIndex(index)  | 
|         if not player:  | 
|             continue  | 
|         if player.GetFamilyID() != curPlayer.GetFamilyID():  | 
|             continue  | 
|         if player.GetPlayerID() == rightPlayerID:  | 
|             giveItemID = rightItemID  | 
|         else:  | 
|             giveItemID = wrongItemID  | 
|         itemCount, isAuctionItem = 1, False  | 
|         ItemControler.GivePlayerItem(player, giveItemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem])  | 
|           | 
|     if curPlayer.GetPlayerID() != rightPlayerID:  | 
|         return  | 
|       | 
|     addPoint, addExp = IpyGameDataPY.GetFuncEvalCfg('PartyReward', 2)  | 
|     #ÏÉÃ˹±Ï×¶È  | 
|     PlayerFamily.AddPlayerFamilyActiveValue(curPlayer, addPoint, True, ShareDefine.Def_AddFAVReason_FamilyParty, True)  | 
|     #´ðÌâ¾Ñé¸üР | 
|     PlayerControl.PlayerControl(curPlayer).AddExp(addExp, ShareDefine.Def_ViewExpType_SysEx)  | 
|     PlayerControl.FamilyNotify(curPlayer.GetFamilyID(), 'Party_Answer', [curPlayer.GetName(), rightItemID])  | 
|     curAnswerCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt, curAnswerCnt + 1)      | 
|       | 
|     if GameWorld.GetMap().GetMapID() == ChConfig.Def_FBMapID_FamilyParty:  | 
|         DoFBHelp(curPlayer, 0)  | 
|     return  | 
|   | 
|   | 
| def OnFamilyPartyStateChange(state, tick):  | 
|     #»î¶¯×´Ì¬±ä¸ü  | 
|     mapID = GameWorld.GetMap().GetMapID()  | 
|     if mapID != ChConfig.Def_FBMapID_FamilyParty:  | 
|         return  | 
|       | 
|     GameWorld.DebugLog('ÏÉÃËÑç»á»î¶¯×´Ì¬±ä¸ü state=%s' % state)  | 
|     if state == 1:  | 
|         remainSeconds = PlayerActivity.GetDailyActionRemainSeconds(ShareDefine.DailyActionID_FamilyParty)  | 
|         playerManager = GameWorld.GetPlayerManager()  | 
|         for i in xrange(playerManager.GetPlayerCount()):  | 
|             curPlayer = playerManager.GetPlayerByIndex(i)  | 
|             if not curPlayer or curPlayer.IsEmpty():  | 
|                 continue  | 
|             __DoEnterJoinFamilyParty(curPlayer, remainSeconds)  | 
|     else:  | 
|         PyGameData.g_familyPartyInfo = []  | 
|           | 
|     return  | 
|   | 
|   | 
| ##Íæ¼ÒÍ˳ö¼Ò×å´¦Àí  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| def OnLeaveFamily(curPlayer, tick):  | 
|     #GameWorld.DebugLog("OnLeaveFamily...")  | 
|     PlayerControl.PlayerLeaveFB(curPlayer)  | 
|     return  | 
|   | 
|   | 
| ##»ñµÃ¸±±¾°ïÖúÐÅÏ¢  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks ÓÃÓÚ֪ͨÕóÓª±È·ÖÌõ  | 
| def DoFBHelp(curPlayer, tick, isSyncPlayerID=False):  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     chuangongActionState = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyChuanGong)  | 
|     partyActionState = gameWorld.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyParty)  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     curAnswerCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyAnswerCnt)  | 
|     addPoint, addExp = IpyGameDataPY.GetFuncEvalCfg('PartyReward', 2)  | 
|     exp = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyTotalExp)  | 
|     expPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyTotalExpPoint)  | 
|     totalExp = expPoint * ChConfig.Def_PerPointValue + exp + addExp * curAnswerCnt  | 
|     exp = totalExp % ChConfig.Def_PerPointValue  | 
|     expPoint = totalExp / ChConfig.Def_PerPointValue  | 
|       | 
|     totalPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyTotalPoint)  | 
|     #totalPoint += IpyGameDataPY.GetFuncCfg('PartyReward') #¼Ó²ÎÓë½±  | 
|     totalPoint += addPoint * curAnswerCnt  | 
|     hasCollect = int(curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyCollectState) or not partyActionState) # ·Ç»î¶¯ÆÚ¼äҲͬ²½ÒѲɼ¯£¬Ç°¶Ë¸ù¾Ý´Ë״̬¿ØÖư´Å¥ÏÔÒþ  | 
|     hasSit = int(curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartySitState) or not chuangongActionState) # ·Ç»î¶¯ÆÚ¼äҲͬ²½ÒÑ´«¹¦£¬Ç°¶Ë¸ù¾Ý´Ë״̬¿ØÖư´Å¥ÏÔÒþ  | 
|       | 
|     helpDict = {FBCommon.Help_exp:exp, FBCommon.Help_expPoint:expPoint, FBCommon.Help_score:totalPoint, "hasCollect":hasCollect, "hasSit":hasSit}  | 
|     if PyGameData.g_familyPartyInfo:  | 
|         rankList = []  | 
|         for i, info in enumerate(PyGameData.g_familyPartyInfo[0], 1):  | 
|             rankList.append({"rank":i, "name":info[1], "cnt":info[2]})  | 
|         helpDict['familyPartyRank'] = rankList  | 
|         helpDict['familyPartyTop'] = {'name':PyGameData.g_familyPartyInfo[1], "cnt":PyGameData.g_familyPartyInfo[2]}  | 
|     if isSyncPlayerID:  | 
|         lineID = GameWorld.GetGameWorld().GetLineID()  | 
|         helpDict['familyPartyPlayer'] = g_familyMapPlayerIDDict.get(lineID, [])  | 
|           | 
|     GameWorld.DebugLog("DoFBHelp %s" % helpDict, playerID)  | 
|     FBCommon.Notify_FBHelp(curPlayer, helpDict)  | 
|     return  | 
|   | 
|   | 
| ##ÊÇ·ñ¿ÉÒԲɼ¯  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curNPC NPCʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks  | 
| def OnCanCollect(curPlayer, curNPC, tick):  | 
|     partyActionState = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyParty)  | 
|     if not partyActionState:  | 
|         PlayerControl.NotifyCode(curPlayer, 'Party_NotInPartyTime')  | 
|         return  | 
|     hasCollect = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyCollectState)  | 
|     if hasCollect:  | 
|         PlayerControl.NotifyCode(curPlayer, 'Party_HadCollected')  | 
|         return  | 
|     needSpace = len(IpyGameDataPY.GetFuncEvalCfg('FamilyPartyDesk', 3))  | 
|     packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)  | 
|     if needSpace > packSpace:  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")  | 
|         return  | 
|     return True  | 
|   | 
|   | 
| ##¸±±¾ÖÐ,²É¼¯ÎïÐèÒªLoadingʱ¼ä.  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curNPC NPCʵÀý  | 
| # @return ·µ»ØÖµ, Loadingʱ¼ä  | 
| # @remarks ¸±±¾ÖÐ,²É¼¯ÎïÐèÒªLoadingʱ¼ä  | 
| def GetFBPrepareTime(curPlayer, curNPC):  | 
|     return IpyGameDataPY.GetFuncCfg('FamilyPartyDesk', 2) * 1000  | 
|   | 
|   | 
| ##Íæ¼ÒÊÕ¼¯³É¹¦(Ëþ, Æì)  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks  | 
| def OnCollectOK(curPlayer, npcID, tick):  | 
|     playerID = curPlayer.GetID()  | 
|     #gameWorld = GameWorld.GetGameWorld()  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyCollectState, 1)  | 
|       | 
|     GameWorld.DebugLog('    Ñç»á²É¼¯³É¹¦£¡', playerID)  | 
|     #¸ø½±Àø  | 
|     itemAward = IpyGameDataPY.GetFuncEvalCfg('FamilyPartyDesk', 3)  | 
|     for itemID, itemCount, isBind in itemAward:  | 
|         ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])  | 
|     addPoint = IpyGameDataPY.GetFuncCfg('FamilyPartyDesk')  | 
|     PlayerControl.NotifyCode(curPlayer, 'Party_CollectSuccess', [addPoint])  | 
|     PlayerFamily.AddPlayerFamilyActiveValue(curPlayer, addPoint, True, ShareDefine.Def_AddFAVReason_FamilyParty)  | 
|       | 
|     totalPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyTotalPoint)  | 
|     updPoint = totalPoint + addPoint  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyTotalPoint, updPoint)  | 
|     DoFBHelp(curPlayer, 0)  | 
|     return  | 
|   | 
| ## »ñµÃ¾Ñé  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param addExp »ñµÃµÄ¾Ñé  | 
| #  @param expViewType ¾ÑéÀàÐÍ  | 
| #  @return True or False  | 
| def OnGetExp(curPlayer, addExp, expViewType):  | 
|       | 
|     if expViewType != ShareDefine.Def_ViewExpType_SysEx:  | 
|         return  | 
|     exp = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyTotalExp)  | 
|     expPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyTotalExpPoint)  | 
|     newTotalExp = expPoint * ChConfig.Def_PerPointValue + exp + addExp  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyTotalExp, newTotalExp % ChConfig.Def_PerPointValue)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyTotalExpPoint, newTotalExp / ChConfig.Def_PerPointValue)  | 
|     return  | 
|   | 
| ##Íæ¼ÒÍ˳ö¸±±¾  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| def DoExitFB(curPlayer, tick):  | 
|     global g_familyMapPlayerIDDict  | 
|     __GiveSitAward(curPlayer)  | 
|     lineID = GameWorld.GetGameWorld().GetLineID()  | 
|     playerID = curPlayer.GetID()  | 
|     if playerID in g_familyMapPlayerIDDict.get(lineID, []):  | 
|         g_familyMapPlayerIDDict[lineID].remove(playerID)  | 
|         if g_familyMapPlayerIDDict[lineID]:  | 
|             playerManager = GameWorld.GetMapCopyPlayerManager()  | 
|             for index in xrange(playerManager.GetPlayerCount()):  | 
|                 curPlayer = playerManager.GetPlayerByIndex(index)  | 
|                 if not curPlayer:  | 
|                     continue  | 
|                 DoFBHelp(curPlayer, tick, True)  | 
|     return  | 
|   | 
| ## ¸±±¾ÐÐΪ  | 
| #  @param curPlayer Íæ¼Ò  | 
| #  @param actionType ÐÐΪÀàÐÍ  | 
| #  @param actionInfo ÐÐΪÐÅÏ¢  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| def DoFBAction(curPlayer, actionType, actionInfo, tick):  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     playerID = curPlayer.GetID()  | 
|     if actionType == 0:  #ÑûÇë´ò×ø  | 
|         tagPlayerID = actionInfo  | 
|         if curPlayer.GetPlayerAction() in [IPY_GameWorld.paSit, IPY_GameWorld.paPreparing]:  | 
|             GameWorld.DebugLog('ÑûÇë´ò×ø,Íæ¼ÒÒÑ´¦ÓÚ´ò×ø»ò²É¼¯×´Ì¬', playerID)  | 
|             return  | 
|         hasSit = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartySitState)  | 
|         if hasSit:  | 
|             GameWorld.Log('ÑûÇë´ò×ø,Íæ¼ÒÒÑ´ò×ø¹ýÒ»´Î', playerID)  | 
|             return  | 
|   | 
|         copyMapPlayerManager = GameWorld.GetMapCopyPlayerManager()  | 
|         tagPlayer = copyMapPlayerManager.FindPlayerByID(tagPlayerID)  | 
|         if not tagPlayer:  | 
|             GameWorld.DebugLog('ÑûÇë%s´ò×ø,¸ÃÍæ¼Ò²»ÔÚ¸±±¾Àï' % tagPlayerID, playerID)  | 
|             PlayerControl.NotifyCode(curPlayer, 'PartySitFail')  | 
|             return  | 
|         gameWorld.SetGameWorldDict(FBPlayerDict_TagPlayerID % playerID, tagPlayerID)  | 
|         curPlayer.StopMove()  | 
|         curPlayer.Sit()  | 
| #        if not gameWorld.GetGameWorldDictByKey(FBPlayerDict_HasSit % tagPlayerID):  | 
| #            if tagPlayer.GetPlayerAction() not in [IPY_GameWorld.paSit, IPY_GameWorld.paPreparing]:  | 
| #                tagPlayer.StopMove()  | 
| #                tagPlayer.Sit()  | 
|     elif actionType == 1:  #´ò×ø½áÊø¸ø½±Àø  | 
|         if not __GiveSitAward(curPlayer):  | 
|             return  | 
|   | 
|         DoFBHelp(curPlayer, 0)  | 
|           | 
|   | 
|     return  | 
|   | 
| def __GiveSitAward(curPlayer):  | 
|     #¸ø´ò×ø½±Àø  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     playerID = curPlayer.GetID()  | 
|     hasSit = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartySitState)  | 
|     if hasSit:  | 
|         GameWorld.Log('´ò×ø½áÊø¸ø½±Àø,Íæ¼ÒÒÑ´ò×ø¹ýÒ»´Î', playerID)  | 
|         return  | 
|     if curPlayer.GetPlayerAction() != IPY_GameWorld.paSit:  | 
|         GameWorld.Log('´ò×ø½áÊø¸ø½±Àø,Íæ¼Ò²»ÔÚ´ò×ø×´Ì¬', playerID)  | 
|         return  | 
|     curPlayer.Stand()  | 
|     reLV = curPlayer.GetLV()  | 
|     worldlv = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)  | 
|     giveLV = eval(IpyGameDataPY.GetFuncCompileCfg('FamilyPartySitAward', 2))  | 
|     addExp = 0  | 
|     if giveLV:  | 
|         addExp = Item_AddLV.DoAddLVEx(curPlayer, giveLV, True, True, 0)  | 
|     reLV = curPlayer.GetLV()  | 
|     reExp = PlayerControl.GetPlayerReExp(curPlayer)  | 
|     giveExp = eval(IpyGameDataPY.GetFuncCompileCfg('FamilyPartySitAward'))  | 
|     if giveExp:  | 
|         PlayerControl.PlayerControl(curPlayer).AddExp(giveExp, ShareDefine.Def_ViewExpType_SysEx)  | 
|           | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartySitState, 1)  | 
|     PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_FamilyChuanGong)  | 
|     PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_FamilyChuanGong, 1)  | 
|     DoFBHelp(curPlayer, 0)  | 
|       | 
|     #°ïÖú´«¹¦½±Àø  | 
|     helpSitActivityAward = IpyGameDataPY.GetFuncEvalCfg('FamilyPartySitAward', 3)  | 
|     if helpSitActivityAward and len(helpSitActivityAward) == 2:  | 
|         helpFamilyActivity, maxHelpAwardCount = helpSitActivityAward  | 
|         helpThanks = IpyGameDataPY.GetFuncCfg('FamilyPartySitAward', 4) % (helpFamilyActivity, maxHelpAwardCount)  | 
|         sitThanks = helpThanks.decode(ShareDefine.Def_Game_Character_Encoding).encode(GameWorld.GetCharacterEncoding())  | 
|         tagPlayerID = gameWorld.GetGameWorldDictByKey(FBPlayerDict_TagPlayerID % playerID)  | 
|         PlayerTalk.TalkPrivateByID(curPlayer, tagPlayerID, sitThanks)  | 
|         tagPlayer = GameWorld.GetMapCopyPlayerManager().FindPlayerByID(tagPlayerID)  | 
|         if tagPlayer:  | 
|             helpCount = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyPartyHelpSitCount) + 1  | 
|             PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyPartyHelpSitCount, helpCount)  | 
|             GameWorld.DebugLog("°ïÖú´«¹¦½±Àø: sitPlayerID=%s,tagPlayerID=%s,helpCount=%s" % (playerID, tagPlayerID, helpCount))  | 
|             if helpCount <= maxHelpAwardCount:  | 
|                 PlayerControl.GiveMoney(tagPlayer, ShareDefine.TYPE_Price_FamilyActivity, helpFamilyActivity)  | 
|                   | 
|     GameWorld.DebugLog('    ´«¹¦½áÊø£¬giveLV=%s, giveExp=%s, worldlv=%s' % (giveLV, giveExp, worldlv))  | 
|     return True  | 
|   | 
| def DoAddFamilyMemberFamilyActivity(familyID, addFamilyActivity):  | 
|     playerManager = GameWorld.GetPlayerManager()  | 
|     for index in xrange(playerManager.GetPlayerCount()):  | 
|         curPlayer = playerManager.GetPlayerByIndex(index)  | 
|         if not curPlayer:  | 
|             continue  | 
|         if curPlayer.GetFamilyID() != familyID:  | 
|             continue  | 
|         PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FamilyActivity, addFamilyActivity)  | 
|         GameWorld.DebugLog("Ôö¼Ó±¾ÏÉÃ˳ÉÔ±´ðÌâ»îÔ¾Áî, playerID=%s,addFamilyActivity=%s" % (curPlayer.GetPlayerID(), addFamilyActivity))  | 
|     return  |