#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
  
 | 
##@package ProMovement  
 | 
# Êý¾Ý¿âGMÃüÁîÖ´ÐÐ->¿ªÆô»î¶¯ [ID ,¿ªÊ¼/¹Ø±Õ, ¿ªÊ¼Ê±¼ä,½áÊøÊ±¼ä,²ÎÊýÁбí[0,0,0]]  
 | 
#  
 | 
# @author mark  
 | 
# @date 2010-3-31  
 | 
# @version 1.0  
 | 
#  
 | 
# ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ  
 | 
# @change: "2011-09-15 10:50" jiang ÐÞ¸ÄÌáʾÐÅÏ¢µÄ»ñÈ¡·½Ê½,ɾ³ýÌØÊâ»î¶¯µÄÅж¨  
 | 
#  
 | 
# Ä£¿éÏêϸ˵  
 | 
#½Å±¾ËµÃ÷  
 | 
#Êý¾Ý¿âGMÃüÁîÖ´ÐÐ->¿ªÆô»î¶¯ [ID ,¿ªÊ¼/¹Ø±Õ, ¿ªÊ¼Ê±¼ä,½áÊøÊ±¼ä,²ÎÊýÁбí[0,0,0]]  
 | 
#---------------------------------------------------------------------  
 | 
"""Version = 2011-09-15 10:50"""  
 | 
#---------------------------------------------------------------------  
 | 
  
 | 
#µ¼Èë  
 | 
import GMCommon  
 | 
import ChConfig  
 | 
import GameWorld  
 | 
import PlayerControl  
 | 
import datetime  
 | 
#---------------------------------------------------------------------  
 | 
#È«¾Ö±äÁ¿  
 | 
#---------------------------------------------------------------------  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
#Â߼ʵÏÖ(ÕâÀïcurPlayer = None)  
 | 
## Ö´ÐÐÂß¼  
 | 
#  @param curPlayer µ±Ç°Íæ¼Ò  
 | 
#  @param gmList [cmdIndex]  
 | 
#  @return None  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def OnExec(curPlayer, gmList):  
 | 
    cmdIndex = gmList[0]  
 | 
      
 | 
    result = __DoLogic_StartGame( gmList )  
 | 
      
 | 
    if result :  
 | 
        GMCommon.Send_DataServer_GMCommandResult(cmdIndex, ChConfig.Def_GMTool_Succeed)  
 | 
    else:  
 | 
        GMCommon.Send_DataServer_GMCommandResult(cmdIndex, ChConfig.Def_GMTool_Fail)  
 | 
      
 | 
## Ö´ÐпªÆô»î¶¯Âß¼  
 | 
#  @param gmList [gmAccID isOpen eventID beginTime overTime]  
 | 
#  @return None or True  
 | 
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
 | 
def __DoLogic_StartGame( gmList ):  
 | 
    #²Ù×÷Ô±ID  
 | 
    gmAccID = gmList[1]  
 | 
    #¿ªÆô»òÕß¹Ø±Õ  
 | 
    isOpen = int( gmList[2] )  
 | 
    #¿ªÆô»î¶¯µÄID  
 | 
    eventID = int( gmList[3] )  
 | 
      
 | 
    eventManager = GameWorld.GetGameWorldEventManager()  
 | 
      
 | 
    #ÅųýÌØÊâÇé¿öÅж¨  
 | 
    if eventID not in GMCommon.GetGameServer_GM_GameID():  
 | 
        GameWorld.Log("Êý¾Ý¿â¶ÁÈ¡GMÃüÁî:¿ªÆô»î¶¯Ê§°Ü,ûÓÐÕâ¸ö»î¶¯ = %s"%(eventID))  
 | 
        return  
 | 
      
 | 
    #¿ªÆô»î¶¯  
 | 
    if isOpen:  
 | 
        #¿ªÊ¼Ê±¼ä  
 | 
        beginTime = gmList[4]  
 | 
        #½áÊøÊ±¼ä  
 | 
        overTime = gmList[5]  
 | 
          
 | 
        #»î¶¯¿ªÆôʱ¼ä #"2007-11-23 11:23:00"  
 | 
        eventStartTime = GameWorld.GetDateTimeByStr( beginTime )  
 | 
        #»î¶¯¹Ø±Õʱ¼ä #"2009-11-23 11:23:00"  
 | 
        eventCloseTime = GameWorld.GetDateTimeByStr( overTime )  
 | 
          
 | 
        if not eventStartTime or not eventCloseTime:  
 | 
            GameWorld.Log('Êý¾Ý¿â¶ÁÈ¡GMÃüÁî:¿ªÆô»î¶¯Ê§°Ü, Ê±¼äÒì³£ = %s,%s'%(beginTime , overTime))  
 | 
            return  
 | 
          
 | 
        if eventStartTime < datetime.datetime.today():  
 | 
            GameWorld.Log('Êý¾Ý¿â¶ÁÈ¡GMÃüÁî:¿ªÆô»î¶¯Ê§°Ü , ÊäÈëµÄ¿ªÊ¼Ê±¼äСÓÚµ±Ç°ÏµÍ³Ê±¼ä ')  
 | 
            return  
 | 
          
 | 
        if eventStartTime > eventCloseTime:  
 | 
            GameWorld.Log('Êý¾Ý¿â¶ÁÈ¡GMÃüÁî:¿ªÆô»î¶¯Ê§°Ü , ÄúÊäÈëµÄ½áÊøÊ±¼äСÓÚ¿ªÊ¼Ê±¼ä')  
 | 
            return  
 | 
          
 | 
        eventPar = ''  
 | 
          
 | 
        #Èç¹û»î¶¯ÒѾ¿ªÆô,Ö´Ðи²¸Ç»î¶¯Âß¼  
 | 
        GMCommon.CloseProcessingEvent(eventID)  
 | 
          
 | 
        #ÉèÖûÄÚÈݽø»î¶¯¹ÜÀíÆ÷  
 | 
        addEvent = eventManager.AddActiveEvent(eventID)  
 | 
          
 | 
        addEvent.SetEventID(eventID)  
 | 
        addEvent.SetStartTime('%s'%eventStartTime)  
 | 
        addEvent.SetEndTime('%s'%eventCloseTime)  
 | 
        addEvent.SetAccID( gmAccID )  
 | 
        addEvent.SetPar('%s'%(eventPar))  
 | 
          
 | 
        #ÉèÖÃΪδ¼¤»î״̬  
 | 
        addEvent.SetIsProcessing(False)  
 | 
      
 | 
    #¹Ø±Õ»î¶¯  
 | 
    else:  
 | 
        activeEvent = eventManager.FindActiveEvent(eventID)  
 | 
        if not activeEvent:  
 | 
            GameWorld.Log('Êý¾Ý¿â¶ÁÈ¡GMÃüÁî:¹Ø±Õ»î¶¯Ê§°Ü , ÎÞ¼¤»î´Ë»î¶¯ = %s'%(eventID))  
 | 
            return  
 | 
          
 | 
        #Õâ¸ö»î¶¯ÒѾ¼¤»îÁË  
 | 
        if activeEvent.GetIsProcessing():  
 | 
            #Êä³öϵͳÌáʾ  
 | 
            sysMsg = GMCommon.GetGameServer_GM_GameClose_Msg(eventID)  
 | 
            if sysMsg != "":  
 | 
                PlayerControl.WorldNotify(0, sysMsg)  
 | 
            else:  
 | 
                GameWorld.Log("Êý¾Ý¿â¶ÁÈ¡GMÃüÁî:ÎÞ·¨²éÕÒµ½»î¶¯ID = %s ¹Ø±ÕÌáʾ"%(eventID))  
 | 
          
 | 
        eventManager.DelActiveEvent(eventID)  
 | 
      
 | 
    return True  
 | 
      
 |