| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #  | 
| #  | 
| ##@package GY_Query_MergeWarRegister.py  | 
| #  | 
| # @todo:¿ç·þÈü±¨Ãûµ÷ÓÃ½Ó¿Ú  | 
| #  | 
| # @author wdb  | 
| # @date 2012-11-01  | 
| # @version 2.2  | 
| # @note:  | 
| # @change: "2013-03-13 17:00" wdb É¾³ý·â°ü  | 
| # @change: "2015-09-11 15:00" hxp »Ö¸´·â°ü£¬Ôö¼ÓÏà¹ØÈÕÖ¾; ÐÞ¸´ÉÏ´«Ê§°Üʱ±¨´íÎÊÌâ  | 
| # @change: "2015-09-18 19:30" hxp ÉÏ´«Êý¾ÝÔö¼Ó¿ÉÖ¸¶¨µØÍ¼×ø±êÐÅÏ¢  | 
| # @change: "2015-09-26 15:30" hxp ¿ç·þÖ÷·þÎñÆ÷²»ÔÊÐíÉÏ´«±¨ÃûÊý¾Ý  | 
| # @change: "2015-10-10 10:10" hxp Ôö¼ÓͬÀàÐÍ¿ç·þ»î¶¯¶àµØÍ¼Ö§³Ö  | 
| # @change: "2015-10-22 23:00" hxp Ôö¼Ó¿ÉÖ¸¶¨ÉÏ´«Êý¾ÝµÄµØÍ¼ÐÅÏ¢Ö§³Ö  | 
| # @change: "2015-11-05 12:00" hxp Ôö¼ÓÕ½¶·Á¦ÐÅÏ¢  | 
| # @change: "2015-11-13 17:00" hxp ÍõÕßÕù°ÔÉÏ´«Êý¾ÝÖ§³Ö  | 
| # @change: "2016-12-20 17:30" hxp È¥³ýÉÏ´«¿ç·þÊý¾ÝÀäȴʱ¼äÏÞÖÆ£¬ÓÐÐèÒªÓÐGameServerÏÞÖÆ  | 
| # @change: "2017-06-22 15:00" hxp ¿ç·þ»î¶¯µØÍ¼·ÖÅ乿Ôò¸ÄΪÓÉGameServer¾ö¶¨  | 
| # @change: "2017-07-03 20:00" hxp ÉÏ´«Êý¾Ýǰ¸üÐÂ×Ô¼ºËùÊô·þÎñÆ÷×éID  | 
| # @change: "2017-07-11 16:00" hxp ¿ç·þbossÉÏ´«Êý¾ÝÊÓΪÊ״βÎÓ룬ÉèÖÿÉÁìÈ¡Ê״βÎÓë½±Àø  | 
| #------------------------------------------------------------------------------   | 
| #"""Version = 2017-07-11 16:00"""  | 
| #------------------------------------------------------------------------------   | 
| # µ¼Èë  | 
| import GameWorld  | 
| import IPY_GameWorld  | 
| import ChPyNetSendPack  | 
| import PlayerControl  | 
| #import ReadChConfig  | 
| import NetPackCommon  | 
| #import DataRecordPack  | 
| import ShareDefine  | 
| import ChConfig  | 
| import ChPlayer  | 
|   | 
| #import random  | 
| #------------------------------------------------------------------------------   | 
|   | 
| #------------------------------------------------------------------------------   | 
| ## ¿ç·þÈü±¨Ãûµ÷ÓÃ½Ó¿Ú  | 
| #  @param query_Type ÇëÇóÀàÐÍ  | 
| #  @param query_ID ÇëÇóµÄÍæ¼ÒID  | 
| #  @param packCMDList ·¢°üÃüÁî  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return "True" or "False" or ""  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def DoLogic(query_Type, query_ID, packCMDList, tick):   | 
|     return  | 
|   | 
|   | 
| #------------------------------------------------------------------------------   | 
| ## Ö´Ðнá¹û  | 
| #  @param curPlayer ·¢³öÇëÇóµÄÍæ¼Ò  | 
| #  @param callFunName ¹¦ÄÜÃû³Æ  | 
| #  @param funResult ²éѯµÄ½á¹û  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def DoResult(curPlayer, callFunName, funResult, tick):  | 
|     resultInfo = eval(funResult)  | 
|     actionType = resultInfo[0]  | 
|     mapPosInfo = resultInfo[1:]  | 
|     if not curPlayer:  | 
|         GameWorld.Log("GY_Query_MergeWarRegister DoResult not curPlayer!!!")  | 
|         return  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     GameWorld.Log("GY_Query_MergeWarRegister DoResult %s" % funResult, playerID)  | 
|   | 
|     if GameWorld.IsMergeServer():  | 
|         GameWorld.Log("    ¿ç·þ·þÎñÆ÷²»ÔÊÐíÉÏ´«±¨ÃûÊý¾Ý!", playerID)  | 
|         return  | 
|       | 
| #    if actionType in [ShareDefine.Def_MergeAction_MergePK, ShareDefine.Def_MergeAction_MergeKing]:  | 
| #        mapPosInfo = actionInfo  | 
| #    else:  | 
| #        mapPosInfo = __GetMergeActionMapPos(actionType)  | 
|           | 
|     if not mapPosInfo:  | 
|         return  | 
|       | 
|     #¿ç·þǰ¸üÐÂ×Ô¼ºËùÊô·þÎñÆ÷×éID  | 
|     ChPlayer.UpdatePlayerServerGroupID(curPlayer)  | 
|       | 
|     mapID, dataMapID, copyMapID, posX, posY = mapPosInfo  | 
|       | 
|     #¿ç·þÈü±¨Ãû״̬  | 
|     SendRegisterState(curPlayer, ShareDefine.Def_MergeRegisterState_Start)  | 
|       | 
|     curPlayer.SendMergeRegisterPlayer(mapID, dataMapID, copyMapID, posX, posY)  | 
|     #DataRecordPack.DR_MergeWarRegister(curPlayer, hasRegister, 0, 0)     | 
|     GameWorld.Log("    curPlayer.SendMergeRegisterPlayer(%s) OK!" % str(mapPosInfo), playerID)  | 
|       | 
|     if actionType == ShareDefine.Def_MergeAction_Boss:  | 
|         firstJoinAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MergeBoss_FirstJoinAwardRecord)  | 
|         # ÉÏ´«Êý¾Ý¼´ÊÓΪ²ÎÓ룬µ±²»¿ÉÁìÈ¡µÄʱºò£¬ÉèÖÃΪ¿ÉÁìÈ¡£¬´Ë´¦²»Í¬²½¿Í»§¶Ë״̬±ä¸ü£¬½öÔڵǼʱͬ²½  | 
|         if firstJoinAwardState == 0:  | 
|             PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MergeBoss_FirstJoinAwardRecord, 1)  | 
|               | 
|     return  | 
|   | 
| ### »ñÈ¡¿ç·þ»î¶¯¶ÔÓ¦ÉÏ´«Êý¾ÝµØÍ¼×ø±ê  | 
| #def __GetMergeActionMapPos(actionType):  | 
| #    MergeActionMapPosDict = ReadChConfig.GetEvalChConfig("MergeActionMapPos")  | 
| #    if actionType not in MergeActionMapPosDict:  | 
| #        GameWorld.ErrLog("¿ç·þÉÏ´«Êý¾ÝÕÒ²»µ½»î¶¯ÀàÐÍ(%s)¶ÔÓ¦µØÍ¼×ø±êÅäÖ㬼ì²éMergeActionMapPos.txt!" % actionType)  | 
| #        return  | 
| #      | 
| #    mapPosDict = MergeActionMapPosDict[actionType]  | 
| #    if not mapPosDict:  | 
| #        GameWorld.ErrLog("¿ç·þÉÏ´«Êý¾ÝÕÒ²»µ½»î¶¯ÀàÐÍ(%s)¶ÔÓ¦µØÍ¼×ø±êÅäÖ㬼ì²éMergeActionMapPos.txt!!" % actionType)  | 
| #        return  | 
| #      | 
| #    mapPosList = []  | 
| #    # Íæ¼ÒËùÊôÔʼ·þÎñÆ÷ID  | 
| #    mergeServerID = GameWorld.GetMergeServerID()  | 
| #    for serverIDTupleKey, posList in mapPosDict.items():  | 
| #        for serverID in serverIDTupleKey:  | 
| #            if (isinstance(serverID, int) and serverID == mergeServerID) or \  | 
| #                (isinstance(serverID, tuple) and len(serverID) == 2 \  | 
| #                    and serverID[0] <= mergeServerID <= serverID[1]):  | 
| #                mapPosList = posList  | 
| #                break  | 
| #              | 
| #        if mapPosList:  | 
| #            break  | 
| #      | 
| #    if not mapPosList:  | 
| #        GameWorld.ErrLog("¿ç·þÉÏ´«Êý¾ÝÕÒ²»µ½»î¶¯ÀàÐÍ(%s),serverID=%s,¶ÔÓ¦µØÍ¼×ø±êÅäÖ㬼ì²éMergeActionMapPos.txt!!"   | 
| #                         % (actionType, mergeServerID))  | 
| #        return  | 
| #      | 
| #    mapPosInfo = random.choice(mapPosList)  | 
| #    if len(mapPosInfo) != 5:  | 
| #        GameWorld.ErrLog("¿ç·þÉÏ´«Êý¾Ý»î¶¯ÀàÐÍ(%s),serverID=%s,¶ÔÓ¦µØÍ¼×ø±êÅäÖôíÎ󣬼ì²éMergeActionMapPos.txt!"   | 
| #                         % (actionType, mergeServerID))  | 
| #        return  | 
| #      | 
| #    return mapPosInfo  | 
|   | 
|   | 
| ## ¿ç·þÈü±¨Ãû½á¹û£¨ÉÏ´«Êý¾Ý£©  | 
| #  @param index Íæ¼ÒË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| def GameServer_MergeRegisterResult(index, tick):  | 
|     registerResult = IPY_GameWorld.IPY_GMMergeRegisterPlayerResult()  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|       | 
|     playerID = curPlayer.GetPlayerID()  | 
|     newAccount = ""  | 
|     newPwd = ""  | 
|     errorMsg = ""  | 
|     result = registerResult.GetResult()  | 
|     if not result:  | 
|         errorMsg = registerResult.GetErrorMsg()  | 
|         #¿ç·þÈü±¨Ãû״̬  | 
|         SendRegisterState(curPlayer, ShareDefine.Def_MergeRegisterState_Err)      | 
|         GameWorld.Log("Merge war register result Error:%s"%errorMsg, playerID)  | 
|     else:  | 
|         newAccount = registerResult.GetAccount()  | 
|         newPwd = registerResult.GetPwd()  | 
|           | 
|         #¿ç·þÈü±¨Ãû״̬  | 
|         SendRegisterState(curPlayer, ShareDefine.Def_MergeRegisterState_Success)  | 
|           | 
|     msgList = str([newAccount, newPwd, curPlayer.GetFightPower(), curPlayer.GetLV(), curPlayer.GetMaxHP()])   | 
|     GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0,  | 
|                                                               'MergeRegister', msgList, len(msgList))  | 
|     # Á÷Ïò¼Ç¼  | 
|     #DataRecordPack.DR_MergeWarRegisterResult(curPlayer, result, errorMsg, newAccount)      | 
|     GameWorld.Log("GameServer_MergeRegisterResult msgList=%s" % msgList, playerID)  | 
|     return  | 
|   | 
|   | 
| ## ¿ç·þÈü±¨Ãû״̬  | 
| #  @param index Íæ¼ÒË÷Òý  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return None  | 
| def SendRegisterState(curPlayer, state):  | 
|     resultPack = ChPyNetSendPack.tagMergeWarRegisterState()  | 
|     resultPack.Clear()  | 
|       | 
|     resultPack.RegisterState = state  | 
|     NetPackCommon.SendFakePack(curPlayer, resultPack)  | 
|     return  | 
|   | 
|   | 
| ## »ñÈ¡ÉÏ´«´ÎÊý¶ÔÓ¦µÄcdʱ¼ä  | 
| #  @param curPlayer: Íæ¼ÒʵÀý  | 
| #  @return: ÉÏ´«´ÎÊý¶ÔÓ¦µÄcdʱ¼ä  | 
| def GetCDTimeByCount(curPlayer):  | 
|     return 30 * 60 * 1000  | 
|     #return int(eval(ReadChConfig.GetChConfig('UpdateMergeWarPlayerDataCDTime')))  | 
|      |