| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package PlayerExam  | 
| # @todo: ´ðÌâ»î¶¯  | 
| #  | 
| # @author: panwei  | 
| # @date 2011-03-31  | 
| # @version 1.7  | 
| #  | 
| # @change: "2011-04-07 19:00" panwei ´ðÌâÐÂÔöÒ»¸öÎÞµÐBuff  | 
| # @change: "2011-04-08 10:40" panwei ´ðÌâ½øÈëÐÂÔöµÈ¼¶ÑéÖ¤, Íæ¼ÒÏÂÏßÍ˳ö´ðÌâÂß¼ÐÞ¸Ä  | 
| # @change: "2012-05-16 15:00" jiang C++Ð޸ĽӿÚGameServer_QueryPlayerByIDºÍGameServer_QueryPlayerResult  | 
| # @change: "2013-04-17 20:35" Alee Í³Ò»BUFFɾ³ýº¯ÊýDelBuffBySkillID  | 
| # @change: "2013-04-25 13:30" Alee ×ªÒÆDelBuffBySkillID  | 
| # @change: "2014-05-04 15:00" xcc Ð޸ĴðÌâ»î¶¯£¬²»ÅжÏÍæ¼Òµ±Ç°×´Ì¬ºÍËø¶¨Íæ¼Òµ±Ç°×´Ì¬  | 
| # @change: "2014-07-14 18:30" hxp Ôö¼ÓÿÈÕ»îÔ¾¶È  | 
| #------------------------------------------------------------------------------   | 
| """Version = 2014-07-14 18:30"""  | 
| #---------------------------------------------------------------------  | 
| import GameWorld  | 
| import ShareDefine  | 
| import PlayerControl  | 
| import ChConfig  | 
| import SkillCommon  | 
| import BuffSkill  | 
| import PetControl  | 
| import ReadChConfig  | 
| import IPY_GameWorld  | 
| import PlayerActivity  | 
| #---------------------------------------------------------------------  | 
| #Íæ¼Ò²»¿É²Î¼Ó´ðÌâ״̬ϵͳÌáʾ  | 
| Def_Exam_JionFailByPlayerActionNotifyDict = {IPY_GameWorld.paDie: 'FB_liubo_692265',   | 
|                                              IPY_GameWorld.paAttack: 'FB_liubo_837087',   | 
|                                              IPY_GameWorld.paTrade: 'Campaign_lhs_372238',   | 
|                                              IPY_GameWorld.paSit:'Campaign_lhs_425673',   | 
|                                              IPY_GameWorld.paProduce:'FB_liubo_902992',   | 
|                                              }  | 
|   | 
| #---------------------------------------------------------------------  | 
| #===============================================================================  | 
| # //01 1B²Î¼Ó»î¶¯#tagCJoinAction  | 
| # //¶ÔÐÔÄÜÓ°Ïì²»´ó  | 
| # struct tagCJoinAction  | 
| # {  | 
| #    BYTE Type;//»î¶¯ÀàÐÍ  | 
| # };  | 
| #===============================================================================  | 
| ##²Î¼Ó»î¶¯#tagCJoinAction  | 
| # @param index Íæ¼ÒË÷Òý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ¿Í»§¶Ë·â°üÏìÓ¦ 01 1B²Î¼Ó»î¶¯#tagCJoinAction  | 
| def Client_JoinAction(index, tick):  | 
| #    GameWorld.Log("¿Í»§¶Ë·¢°ü£¬ÇëÇó¼ÓÈë/Í˳ö´ðÌâ»î¶¯")  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|       | 
|     pack = IPY_GameWorld.IPY_CJoinAction()  | 
|     sendExamType = pack.GetType()  | 
|       | 
|     if sendExamType == 0:  | 
|         #Í˳ö»î¶¯  | 
| #        GameWorld.Log("¿Í»§¶Ë·¢°ü£¬ÇëÇóÍ˳ö´ðÌâ»î¶¯")  | 
|         DoLogic_ExitExam(curPlayer, tick)  | 
|         return  | 
|       | 
|     #---ÑéÖ¤·â°üºÏ·¨ÐÔ---  | 
|     if sendExamType not in ShareDefine.Def_Game_ExamTypeList:  | 
|         GameWorld.ErrLog('Client_JoinAction, sendExamType = %s Ìâ¿âÒì³£'%(sendExamType))  | 
|         return  | 
|       | 
|     serverExamType = __GetExamType()   | 
|       | 
|     if sendExamType != serverExamType:  | 
|         #GameWorld.Log('Client_JoinAction Err sendExamType = %s, serverExamType = %s'%(sendExamType, serverExamType))  | 
|         #FB_liubo_656426 ÏÖÔÚ²»Êǻʱ¼ä,²»Äܲμӻà¡!  | 
|         PlayerControl.NotifyCode(curPlayer, "FB_liubo_656426")  | 
|         return  | 
|       | 
|     #---¼ì²éÊÇ·ñ¿ÉÒԲμӻ---  | 
|     if not __CheckPlayerCanJoinExam(curPlayer, serverExamType):  | 
| #        GameWorld.Log("Íæ¼Òµ±Ç°×´Ì¬ÎÞ·¨²Î¼Ó»î¶¯")  | 
|         return  | 
|       | 
|     # »îÔ¾¶È  | 
|     #PlayerActivity.AddActivityFinishCnt(curPlayer, ShareDefine.ActivityNum_JoinZXH)  | 
|       | 
|     #·¢ËÍ·â°üµ½GameServer²ÎÓë´ðÌâ»î¶¯  | 
| #    GameWorld.Log("MapServer ·¢°ü¸ø GameServerÍ¨ÖªÍæ¼ÒÇëÇó¼ÓÈë´ðÌâ»î¶¯")  | 
|     curPlayer.GameServer_QueryPlayerByID(ChConfig.queryType_JionExam, sendExamType, '', '', 0)  | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ##¼ì²éÍæ¼ÒÊÇ·ñ¿ÉÒÔ²ÎÓë´ðÌâ  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param serverExamType µ±Ç°´ðÌâÀàÐÍ  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks   | 
| def __CheckPlayerCanJoinExam(curPlayer, serverExamType):  | 
|     #ÑéÖ¤Íæ¼ÒµÈ¼¶  | 
|     curPlayerLv = curPlayer.GetLV()  | 
|     enterExamLvDict = ReadChConfig.GetEvalChConfig('ExamJionLv')  | 
|     enterExamLv = enterExamLvDict.get(serverExamType)  | 
|       | 
|     if enterExamLv != None and enterExamLv > curPlayerLv:  | 
|         #FB_admin_0 <n color="255,255,255" BKCOLOR="0,0,0">ÄúµÄµÈ¼¶²»×ã{%S1%},ÎÞ·¨²Î¼Ó´Ë»î¶¯!  | 
|         PlayerControl.NotifyCode(curPlayer, "FB_admin_0", [enterExamLv])  | 
|         return False  | 
|       | 
| #    if curPlayer.IsMoving():  | 
| #        PlayerControl.NotifyCode(curPlayer, "Campaign_lhs_671654")  | 
| #        return False  | 
| #      | 
| #    if curPlayer.IsBattleState():  | 
| #        PlayerControl.NotifyCode(curPlayer, "FB_liubo_837087")  | 
| #        return False  | 
| #      | 
| #    playerAction = curPlayer.GetPlayerAction()  | 
| #      | 
| #    if playerAction in Def_Exam_JionFailByPlayerActionNotifyDict:  | 
| #        PlayerControl.NotifyCode(curPlayer, Def_Exam_JionFailByPlayerActionNotifyDict[playerAction])  | 
| #        return False  | 
| #      | 
| #    if playerAction != IPY_GameWorld.paNull:  | 
| #        PlayerControl.NotifyCode(curPlayer, "FB_liubo_314575")  | 
| #        return False  | 
| #      | 
| #    if GameWorld.GetMap().GetMapFBType() != IPY_GameWorld.fbtNull:  | 
| #        PlayerControl.NotifyCode(curPlayer, "FB_liubo_314885")  | 
| #        return False  | 
|       | 
|     return True  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##»ñÈ¡´ðÌâÀàÐÍ.  | 
| # @param ÎÞ²ÎÊý  | 
| # @return Def_Game_Exam_Type  | 
| # @remarks   | 
| def __GetExamType():  | 
|     return GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_Game_EXAM)  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##Íæ¼ÒÖ÷¶¯Í˳ö´ðÌâ  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @param needRefresh ÊÇ·ñÁ¢¼´Ë¢Ð  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def DoLogic_ExitExam(curPlayer, tick, needRefresh=True):  | 
|     #ɾ³ý´ðÌâBuff  | 
|     if not ClearExamBuff(curPlayer, tick, needRefresh = True):  | 
| #        GameWorld.Log("ɾ³ý´ðÌâbuffʧ°Ü")  | 
|         return  | 
|       | 
| #    GameWorld.Log("֪ͨGameServer,Íæ¼ÒÍ˳ö´ðÌâ")  | 
|     #֪ͨGameServerÍ˳ö´ðÌâ ÕâÀïÓпÉÄÜÍæ¼ÒÒѾÏÂÏß, ²»Äܵ÷ÓÃcurPlayer.GameServer_QueryPlayerByID  | 
|     GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, 'ExitExam', '', 0)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##Íæ¼ÒÖ÷¶¯½øÈë´ðÌâ  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def DoLogic_EnterExam(curPlayer, tick):  | 
| #    GameWorld.Log("GameServer Í¨Öª MapServer Íæ¼Ò²Î¼Ó´ðÌâ³É¹¦")  | 
| #    #ÕÙ»½»Ø³öÕ½µÄ³èÎï  | 
| #    PetControl.ReCallFightPet(curPlayer)  | 
| #    #¸øÍæ¼ÒÌí¼Ó´ðÌâBuff  | 
| #    SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer, ChConfig.Def_SkillID_JoinExam, tick)  | 
| #    #¸øÍæ¼Ò¼Ó»î¶¯ÎÞµÐBuff  | 
| #    SkillCommon.AddBuffBySkillType(curPlayer, ChConfig.Def_SkillID_ActionWuDi, tick)  | 
| #    #ÉèÖÃÍæ¼ÒΪ´ðÌâ״̬  | 
| #    PlayerControl.ChangePlayerAction(curPlayer, IPY_GameWorld.paDOT)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##ɾ³ý´ðÌâBuff  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @param needRefresh ÊÇ·ñÁ¢¼´Ë¢Ð  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks   | 
| def ClearExamBuff(curPlayer, tick, needRefresh=True):  | 
|     #ɾ³ý»î¶¯Buff  | 
| #    BuffSkill.DelBuffBySkillID(curPlayer, ChConfig.Def_SkillID_ActionWuDi, tick)  | 
| #      | 
| #    #ɾ³ý´ðÌâBuff  | 
| #    if not BuffSkill.DelBuffBySkillID(curPlayer, ChConfig.Def_SkillID_JoinExam, tick):  | 
| #        return False  | 
| #      | 
| #    #Íæ¼Ò״̬±ä¸ü  | 
| #    PlayerControl.ChangePlayerAction(curPlayer, IPY_GameWorld.paNull)  | 
| #      | 
| #    if not needRefresh:  | 
| #        return True  | 
| #      | 
| #    #ÖØÐÂË¢ÐÂÊôÐÔ  | 
| #    playerControl = PlayerControl.PlayerControl(curPlayer)  | 
| #    playerControl.RefreshAllState()  | 
|     return True  | 
|   |