| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
|   | 
| ##@package GY_GM_StartGame  | 
| # ¿ªÆôϵͳ»î¶¯  | 
| #  | 
| # @author mark  | 
| # @date 2010-3-31  | 
| # @version 1.2  | 
| #  | 
| # ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ  | 
| # @change: "2011-09-15 10:50" jiang ÐÞ¸ÄÌáʾÐÅÏ¢µÄ»ñÈ¡·½Ê½  | 
| # @change: "2014-01-07 15:30" hxp ÏµÍ³markÐÞ¸Ä  | 
| #  | 
| # Ä£¿éÏêϸ˵  | 
| #¿ªÆôϵͳ»î¶¯  | 
| #¿Í»§¶Ë·¢°ü [¿ªÆô(1)»òÕ߹رÕ(0) , Ê¼þID , »î¶¯¿ªÆôʼþ , »î¶¯½áÊøÊ±¼ä ]  | 
| #---------------------------------------------------------------------  | 
| """Version = 2014-01-07 15:30"""  | 
| #---------------------------------------------------------------------  | 
| #µ¼Èë  | 
| import GameWorld  | 
| import PlayerControl  | 
| import datetime  | 
| import ChConfig  | 
| import GMCommon  | 
| #---------------------------------------------------------------------  | 
| #È«¾Ö±äÁ¿  | 
| #---------------------------------------------------------------------  | 
|   | 
| #---------------------------------------------------------------------  | 
| #Â߼ʵÏÖ  | 
| ## Ö´ÐÐÂß¼  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param playerList [¿ªÆô(1)»òÕ߹رÕ(0) , Ê¼þID , »î¶¯¿ªÆôʼþ , »î¶¯½áÊøÊ±¼ä ]  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def OnExec(curPlayer , playerList):  | 
|     playerListLen = len(playerList)  | 
|       | 
|     if playerListLen not in [2,4]:  | 
|         GameWorld.Log("¿Í»§¶Ë·â°ü³¤¶È´íÎó = %s"%playerListLen)  | 
|         return  | 
|       | 
|     eventManager = GameWorld.GetGameWorldEventManager()  | 
|     #¿ªÆô»òÕß¹Ø±Õ  | 
|     isOpen = playerList[0]  | 
|     #¿ªÆô»î¶¯µÄID  | 
|     eventID = playerList[1]  | 
|       | 
|     if eventID not in GMCommon.GetGameServer_GM_GameID():  | 
|         GameWorld.Log("GM¿ªÆô»î¶¯Ê§°Ü,ûÓÐÕâ¸ö»î¶¯ = %s"%(eventID) , curPlayer.GetPlayerID())  | 
|         return  | 
|       | 
|     #¿ªÆô»î¶¯  | 
|     if isOpen:  | 
|         #»î¶¯¿ªÆôʱ¼ä #"2007-11-23 11:23:00"  | 
|         eventStartTime = GameWorld.GetDateTimeByStr(playerList[2])  | 
|         #»î¶¯¹Ø±Õʱ¼ä #"2009-11-23 11:23:00"  | 
|         eventCloseTime = GameWorld.GetDateTimeByStr(playerList[3])  | 
|           | 
|         if not eventStartTime or not eventCloseTime:  | 
|             GameWorld.Log('¿ªÊ¼ÓÎÏ··þÎñÆ÷»î¶¯ , ·â°üÒì³£ = %s,%s'%(playerList[2] , playerList[3]), curPlayer.GetPlayerID())  | 
|             return  | 
|           | 
|         if eventStartTime < datetime.datetime.today():  | 
|             #GM_Activity_OpenTimeNoLegal ¶Ô²»Æð£¬ÄúÊäÈëµÄ¿ªÊ¼Ê±¼äСÓÚµ±Ç°ÏµÍ³Ê±¼ä£¬GMÖ¸Áî²Ù×÷ʧ°Ü  | 
|             PlayerControl.NotifyCode(curPlayer , "GM_Activity_OpenTimeNoLegal")  | 
|             return  | 
|           | 
|         if eventStartTime > eventCloseTime:  | 
|             #GM_Activity_CloseTimeNoLegal02 ¶Ô²»Æð£¬ÄúÊäÈëµÄ½áÊøÊ±¼äСÓÚ¿ªÊ¼Ê±¼ä£¬GMÖ¸Áî²Ù×÷ʧ°Ü  | 
|             PlayerControl.NotifyCode(curPlayer , "GM_Activity_CloseTimeNoLegal02")  | 
|             return  | 
|           | 
|         #Èç¹û»î¶¯ÒѾ¿ªÆô,Ö´Ðи²¸Ç»î¶¯Âß¼  | 
|         GMCommon.CloseProcessingEvent(eventID)  | 
|           | 
|         #ÉèÖûÄÚÈݽø»î¶¯¹ÜÀíÆ÷  | 
|         addEvent = eventManager.AddActiveEvent(eventID)  | 
|         addEvent.SetEventID(eventID)  | 
|         addEvent.SetStartTime('%s'%eventStartTime)  | 
|         addEvent.SetEndTime('%s'%eventCloseTime)  | 
|         addEvent.SetAccID(curPlayer.GetAccID())  | 
|           | 
|         #ÉèÖÃΪδ¼¤»î״̬  | 
|         addEvent.SetIsProcessing(False)  | 
|       | 
|     #¹Ø±Õ»î¶¯  | 
|     else:  | 
|         activeEvent = eventManager.FindActiveEvent(eventID)  | 
|         if not activeEvent:  | 
|             GameWorld.Log("###²éÕÒÒѾ¼¤»îµÄ»î¶¯Òì³£,ʧ°Ü = %s"%(eventID) , curPlayer.GetPlayerID())  | 
|             return  | 
|           | 
|         #Õâ¸ö»î¶¯ÒѾ¼¤»îÁË  | 
|         if activeEvent.GetIsProcessing():  | 
|             #Êä³öϵͳÌáʾ  | 
|             sysMsg = GMCommon.GetGameServer_GM_GameClose_Msg(eventID)  | 
|             if sysMsg != "":  | 
|                 PlayerControl.WorldNotify(0, sysMsg)  | 
|             else:  | 
|                 GameWorld.Log("###ÎÞ·¨²éÕÒµ½»î¶¯ID = %s ¹Ø±ÕÌáʾ"%(eventID))  | 
|           | 
|         eventManager.DelActiveEvent(eventID)  | 
|       | 
|     #GeRen_chenxin_673416 GMÖ¸ÁîÒÑÉúЧ£¬²Ù×÷³É¹¦  | 
|     PlayerControl.NotifyCode(curPlayer,"GeRen_chenxin_673416")  | 
|       | 
|     #ÍÑ»ú¹¤¾ßʹÓà  | 
|     curPlayer.GMAnswer('%s;%s'%('GY_GM_StartGame', True))  | 
|       | 
|     return  | 
|   | 
|   |