| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package PlayerControl  | 
| # @todo: Íæ¼Ò¿ØÖÆÆ÷  | 
| #  | 
| # @author: panwei  | 
| # @date 2010-02-16  | 
| # @version 2.6  | 
| #  | 
| # @change: "2011-02-23 14:20" panwei ÏµÍ³Ìáʾº¯ÊýÖØÐ´  | 
| # @change: "2011-07-15 19:30" Alee ¶ÓÎé֪ͨ  | 
| # @change: "2011-09-02 16:20" panwei ÐÂÔö¾º¼¼³¡ÉèÖúͻñÈ¡¾ö¶·Öµ½Ó¿Ú  | 
| # @change: "2012-11-06 15:00" jiang ÐÂÔö¾ºÍþÍûÉèÖúͻñÈ¡ÍþÍûÉè½Ó¿Ú  | 
| # @change: "2012-11-07 17:30" wdb ÐÂÔö¿ç·þԤѡÈüÅÅλÐÅÏ¢  | 
| # @change: "2012-11-14 12:00" jiang ÐÞ¸ÄÀ©Õ¹ÊôÐÔ×ֶμǼµÄÊôÐÔÀàÐͱØÐëºÍMapServerÒ»Ö  | 
| # @change: "2013-12-27 13:30" xmnathan ÁÄÌì¼ÓGm±êʶ  | 
| # @change: "2014-02-28 21:10" hxp Ôö¼ÓÐÂÊÖÖ¸µ¼Ô±Âß¼  | 
| # @change: "2014-03-05 10:00" Alee ÁÄÌì֪ͨ±êʶ  | 
| # @change: "2014-11-12 20:00" hxp Ôö¼Ó֪ͨMapServerÔö¼Ó³É¾ÍÍê³É½ø¶È  | 
| # @change: "2015-07-14 21:00" xdh ÁÄÌìÐÅÏ¢Ô¸½¼ÓÖµ¸ÄΪExtras  | 
| # @change: "2015-10-28 00:00" hxp Ôö¼ÓÉèÖöÔÕ½·¿¼äID  | 
| # @change: "2015-11-05 12:00" hxp Ôö¼Ó¿ç·þÈ«·þ¹ã²¥  | 
| # @change: "2015-11-06 16:30" hxp Ôö¼ÓGetMergePlayerName  | 
| # @change: "2017-06-22 15:00" hxp ¿ç·þ¹ã²¥Ôö¼ÓÌõ¼þ¹ýÂË×Ó·þÊÇ·ñÌáÐÑ£»¿ç·þ·þÎñÆ÷È«·þ¹ã²¥Í¬²½×Ó·þ  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2017-06-22 15:00"""  | 
| #---------------------------------------------------------------------  | 
| import GameWorld  | 
| import IPY_GameServer  | 
| import MergeBroadcast  | 
| import IpyGameDataPY  | 
| import ShareDefine  | 
| import ChConfig  | 
| import types  | 
| #---------------------------------------------------------------------  | 
| #ϵͳÌáʾ²ÎÊýÁÐ±í  | 
| NotifyCodeList = IPY_GameServer.IPY_NotifyCodeList()  | 
| #---------------------------------------------------------------------  | 
| ## ÏûÏ¢Ìáʾ  | 
| #  @param curPlayer ÌáʾµÄÍæ¼Ò  | 
| #  @param msgMark ÌáʾÐÅÏ¢Mark  | 
| #  @param msgParamList ÐÅÏ¢²ÎÊýÁÐ±í  | 
| #  @return ÎÞ·µ»ØÖµ  | 
| #  @remarks   | 
| def NotifyCode(curPlayer, msgMark, msgParamList=[]):  | 
|     if curPlayer == None:  | 
|         GameWorld.ErrLog('NotifyCode Player = None')  | 
|         return  | 
|         | 
|     curPlayer.NotifyCode(msgMark, __GetNotifyCodeList(msgParamList))  | 
|     return  | 
|       | 
| ## ¿ç·þÊÀ½ç¹ã²¥  | 
| #  @param country ÌáʾµÄ¹ú¼Ò  | 
| #  @param msgMark ÌáʾÐÅÏ¢Mark  | 
| #  @param msgParamList ÐÅÏ¢²ÎÊýÁÐ±í  | 
| #  @param mergeMinOSD ¸ÃÌáʾÕë¶Ô¿ç·þ×Ó·þÓÐЧµÄ×îС¿ª·þÌì, >=0ʱÓÐÏÞÖÆ  | 
| #  @param mergeMaxOSD ¸ÃÌáʾÕë¶Ô¿ç·þ×Ó·þÓÐЧµÄ×î´ó¿ª·þÌì, >=0ʱÓÐÏÞÖÆ  | 
| #  @param mergeMapInfo ¸ÃÌáʾËùÊôµÄ¿ç·þ»î¶¯µØÍ¼ÐÅÏ¢, Ö÷ÒªÓÃÓÚ²»Í¬×Ó·þ¶ÔÓ¦Ëù¿çµÄ»î¶¯µØÍ¼ID  | 
| #  @remarks   | 
| def MergeWorldNotify(country, msgMark, msgParamList=[], lineID=0, mergeMinOSD=-1, mergeMaxOSD=-1, mergeMapInfo=[], isMapNotify=0):  | 
|     # ·ÇµØÍ¼Í¬²½µÄ¹ã²¥²Å½øÐÐÈ«·þ¹ã²¥  | 
|     if not isMapNotify:  | 
|         GameWorld.GetPlayerManager().CountryNotifyCode(country, msgMark, __GetNotifyCodeList(msgParamList))  | 
|     notifyDict = {"country":country, "msgMark":msgMark, "msgParamList":msgParamList, "lineID":lineID,   | 
|                   "mergeMinOSD":mergeMinOSD, "mergeMaxOSD":mergeMaxOSD, "mergeMapInfo":mergeMapInfo}  | 
|     MergeBroadcast.SendBroadcastMerge(ChConfig.Def_MergeWorldNotify, 0, notifyDict, False)  | 
|     return  | 
|       | 
| ## ÊÀ½ç¹ã²¥  | 
| #  @param country ÌáʾµÄ¹ú¼Ò  | 
| #  @param msgMark ÌáʾÐÅÏ¢Mark  | 
| #  @param msgParamList ÐÅÏ¢²ÎÊýÁÐ±í  | 
| #  @return ÎÞ·µ»ØÖµ  | 
| #  @remarks   | 
| def WorldNotify(country, msgMark, msgParamList=[]):  | 
|     if GameWorld.IsMergeServer():  | 
|         MergeWorldNotify(country, msgMark, msgParamList)  | 
|     else:  | 
|         GameWorld.GetPlayerManager().CountryNotifyCode(country, msgMark, __GetNotifyCodeList(msgParamList))  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## ¼Ò×å¹ã²¥  | 
| #  @param familyID ÌáʾµÄ¼Ò×åID  | 
| #  @param msgMark ÌáʾÐÅÏ¢Mark  | 
| #  @param msgParamList ÐÅÏ¢²ÎÊýÁÐ±í  | 
| #  @return ÎÞ·µ»ØÖµ  | 
| #  @remarks   | 
| def FamilyNotify(familyID, msgMark, msgParamList=[]):  | 
|     GameWorld.GetPlayerManager().FamilyNotifyCode(familyID, msgMark, __GetNotifyCodeList(msgParamList))  | 
|     return  | 
|   | 
| ## ¶ÓÎé¹ã²¥  | 
| #  @param teamID ¶ÓÎéID  | 
| #  @param msgMark ÌáʾÐÅÏ¢Mark  | 
| #  @param msgParamList ÐÅÏ¢²ÎÊýÁÐ±í  | 
| #  @return ÎÞ·µ»ØÖµ  | 
| def TeamNotify(teamID, msgMark, msgParamList=[]):  | 
|     curTeam = GameWorld.GetGameWorld().GetTeamManager().FindTeam(teamID)  | 
|     if curTeam == None:  | 
|         return  | 
|       | 
|     for i in range(curTeam.GetMemberCount()):  | 
|         curPlayer = curTeam.GetMemberPlayer(i)  | 
|         if not curPlayer:  | 
|             continue  | 
|           | 
|         #֪ͨÿ¸ö¶ÓÔ±  | 
|         NotifyCode(curPlayer, msgMark, msgParamList)  | 
|       | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## ¹¹½¨ÏµÍ³Ìáʾ²ÎÊýÁÐ±í  | 
| #  @param msgParamList ÐÅÏ¢²ÎÊýÁÐ±í  | 
| #  @return ÏµÍ³Ìáʾ²ÎÊýÁбí IPY_NotifyCodeList  | 
| #  @remarks   | 
| def __GetNotifyCodeList(msgParamList):  | 
|     #ÏûÏ¢ÌáʾÁбí, ÏÈÇåÔÚÌí¼Ó  | 
|     global NotifyCodeList  | 
|     NotifyCodeList.Clear()  | 
|       | 
|     if not msgParamList:  | 
|         return NotifyCodeList  | 
|       | 
|     for msg in msgParamList:  | 
|         itemPythonType = type(msg)  | 
|           | 
|         if itemPythonType is types.IntType or itemPythonType is types.LongType:  | 
|             #PythonÒªÑéÖ¤ÕûÐͺͳ¤ÕûÐÍ  | 
|             NotifyCodeList.AddInt(msg)  | 
|         else:  | 
|             NotifyCodeList.AddStr(msg)  | 
|   | 
|     return NotifyCodeList  | 
|   | 
|   | 
|   | 
| #waring:ÒÔÏÂʹÓõÄÀ©Õ¹ÊôÐÔ×ֶμǼµÄÊôÐÔÀàÐͱØÐëºÍMapServerÒ»Ö  | 
| #------------------------------------------------------------------------------   | 
| ##ÉèÖþö¶·Öµ(¾º¼¼³¡ÓÃ)  | 
| # @param curPlayer Íæ¼Ò  | 
| # @param value ÊýÖµ  | 
| # @return None  | 
| def SetVsFightValue(curPlayer, value):  | 
|     return  | 
|   | 
|   | 
| ##»ñÈ¡¾ö¶·Öµ(¾º¼¼³¡ÓÃ)  | 
| # @param curPlayer Íæ¼Ò  | 
| # @return ¾ö¶·Öµ  | 
| def GetVsFightValue(curPlayer):  | 
|     return 0  | 
|   | 
| #------------------------------------------------------------------------------   | 
| ## ÉèÖÃÍþÍû  | 
| #  @param curPlayer: Íæ¼ÒʵÀý  | 
| #  @param value: ÍþÍûÖµ  | 
| #  @return:   | 
| def SetPrestige(curPlayer, value):  | 
|     return  | 
|   | 
|   | 
| ## »ñÈ¡ÍþÍû  | 
| #  @param curPlayer: Íæ¼ÒʵÀý  | 
| #  @return: ÍþÍûÖµ  | 
| def GetPrestige(curPlayer):  | 
|     return 0  | 
|   | 
|   | 
| #------------------------------------------------------------------------------   | 
| ## ÉèÖÃÍæ¼Ò¿ç·þÔ¤ÈüÅÅλ  | 
| #  @param curPlayer: Íæ¼ÒʵÀý  | 
| #  @param value: ÍþÍûÖµ  | 
| #  @return:   | 
| def SetMergeWarRank(curPlayer, value):  | 
|     curPlayer.SetExAttr10(value)  | 
|     return  | 
|   | 
|   | 
| ## »ñÈ¡Íæ¼Ò¿ç·þÔ¤ÈüÅÅλ  | 
| #  @param curPlayer: Íæ¼ÒʵÀý  | 
| #  @return: ÍþÍûÖµ  | 
| def GetMergeWarRank(curPlayer):  | 
|     return curPlayer.GetExAttr10()  | 
|   | 
| ## Ö°Òµ½×Êý  | 
| def GetJobRank(curPlayer): return curPlayer.GetExAttr1()  | 
| def SetJobRank(curPlayer, jobRank): return curPlayer.SetExAttr1(jobRank)  | 
|   | 
| ##VIPµ½ÆÚʱ¼ä  | 
| def GetVIPExpireTime(curPlayer): return curPlayer.GetExAttr9()  | 
| def SetVIPExpireTime(curPlayer, expireTime): return curPlayer.SetExAttr9(expireTime)  | 
| def GetValidVIPLV(curPlayer):  | 
|     # @return: ·µ»Øµ±Ç°ÓÐЧµÄVIPµÈ¼¶  | 
| #    vipTime = GetVIPExpireTime(curPlayer)  | 
| #    curTime = GameWorld.ChangeTimeStrToNum(GameWorld.GetCurrentDataTimeStr())  | 
| #    if vipTime <= curTime:  | 
| #        return 0  | 
|     return curPlayer.GetVIPLv()  | 
|   | 
| ## ÊÇ·ñÍÑ»ú¹Ò»ú״̬  | 
| def GetIsTJG(curPlayer):  | 
|     if curPlayer.GetDictByKey(ChConfig.Def_OnlineType):  | 
|         return True  | 
|       | 
|     if curPlayer.GetIP() == "127.0.0.1":  | 
|         # ´Ë´¦Ö»ÄÜÓÃIPÅж¨£¬ÒòΪÍÑ»ú״̬»¹Î´Í¨Öªµ½GameServer  | 
|         return True  | 
|       | 
|     return False  | 
|   | 
| def SetIsTJG(curPlayer, state): curPlayer.SetDict(ChConfig.Def_OnlineType, state)  | 
| ## »ñÈ¡ÍÑ»ú¹Ò»úÊ£Óàʱ¼ä  | 
| def GetTJGTime(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_TJGTime)  | 
| def SetTJGTime(curPlayer, tjgTime): curPlayer.SetDict(ChConfig.Def_TJGTime, tjgTime)  | 
|   | 
| # ½ûÑÔ  | 
| def GetGMForbidenTalk(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_ForbiddenTalk)  | 
| def SetGMForbidenTalk(curPlayer, value): curPlayer.SetDict(ChConfig.Def_ForbiddenTalk, value)  | 
|   | 
|   | 
| #------------------------------------------------------------------------------   | 
|   | 
|   | 
| ## ÉèÖÃÐÂÊÖÖ¸µ¼Ô±ÌìÊý  | 
| #  @param curPlayer: Íæ¼ÒʵÀý  | 
| #  @param day: ÌìÊý  | 
| #  @return:   | 
| def SetFreshmanGuiderDay(curPlayer, day):  | 
|     curPlayer.SetDict(ChConfig.Def_PlayerKey_FreshmanGuiderDay, day)   | 
|     return  | 
|   | 
| ## »ñÈ¡ÐÂÊÖÖ¸µ¼Ô±ÌìÊý  | 
| #  @param curPlayer: Íæ¼ÒʵÀý  | 
| #  @return: ÌìÊý  | 
| def GetFreshmanGuiderDay(curPlayer):  | 
|     return curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_FreshmanGuiderDay)  | 
|   | 
| ## Ôö¼Ó³É¾ÍÍê³É½ø¶È  | 
| #  @param curPlayer  | 
| #  @param successType: ³É¾ÍÀàÐÍ  | 
| #  @param addCnt: Ôö¼Ó½ø¶ÈÖµ  | 
| #  @param condition: À©Õ¹Ìõ¼þ  | 
| #  @return  | 
| def DoAddSuccessProgress(curPlayer, successType, addCnt, condition=[]):  | 
|     if successType not in ShareDefine.SuccessTypeList:  | 
|         return  | 
|       | 
|     sysMsg = '%s'%([successType, addCnt, condition])  | 
|     curPlayer.MapServer_QueryPlayerResult(0, 0, "AddSuccessProgress", sysMsg, len(sysMsg))  | 
|     return  | 
|   | 
| ## ÉèÖÃÍæ¼Ò·¿¼äID  | 
| #  @param curPlayer  | 
| #  @param roomID  | 
| #  @return  | 
| def SetVsRoomId(curPlayer, roomID, isSetMergeRegRoomID=False):  | 
|     curPlayer.SetVsRoomId(roomID)  | 
|     if isSetMergeRegRoomID:  | 
|         curPlayer.SetDict(ChConfig.Def_PlayerKey_MergeRegisterRoomID, roomID)   | 
|       | 
|     battleIDStr = str(roomID)  | 
|     GameWorld.Log("SetVSRoomID playerID=%s, roomID=%s" % (curPlayer.GetPlayerID(), roomID))  | 
|     curPlayer.MapServer_QueryPlayerResult(0, 0, 'CreatePlayerRoomID', battleIDStr, len(battleIDStr))  | 
|     return  | 
|   | 
| ## ¸ù¾Ý×Ó·þÕ˺ż°Ãû³Æ»ñÈ¡¿ç·þ½ÇÉ«Ãû  | 
| def GetMergePlayerName(playerAccID, playerName):  | 
|     orgPlayerName = playerName.strip()  | 
|       | 
|     #È¡Õʺźó׺×÷ÎªÇø·þ±êʶ  | 
|     parserList = playerAccID.split('@')  | 
|     serverSign = ""  | 
|     if len(parserList) >= 2:  | 
|         serverSign = parserList[-1]                 | 
|       | 
|     parserList2 = orgPlayerName.split('-')  | 
|     orgNameServerSign = ""  | 
|     nameNotServerSign = parserList2[0]  | 
|     if len(parserList2) >= 2:  | 
|         orgNameServerSign = parserList2[-1]  | 
|           | 
|     if orgNameServerSign:  | 
|         if orgNameServerSign == serverSign:  | 
|             return orgPlayerName  | 
|         else:  | 
|             return "%s-%s" % (nameNotServerSign, serverSign)  | 
|       | 
|     if serverSign:  | 
|         return "%s-%s" % (nameNotServerSign, serverSign)  | 
|       | 
|     return orgPlayerName  | 
|   | 
| ## µØÍ¼·þÎñÆ÷¿ÛÎïÆ·  | 
| #  @param curPlayer  | 
| #  @param itemList [(itemID,count), (itemID,count),..]  | 
| def MapServerDelItem(curPlayer, itemList, eventName):  | 
|     result = str([itemList, eventName])  | 
|     curPlayer.MapServer_QueryPlayerResult(0, 0, "DelItem", result, len(result))  | 
|     return  | 
|   | 
| ## Ôö¼ÓÏÉÃË»îÔ¾  | 
| #  @param curPlayer  | 
| #  @param successType: ³É¾ÍÀàÐÍ  | 
| #  @param addCnt: Ôö¼Ó½ø¶ÈÖµ  | 
| #  @param condition: À©Õ¹Ìõ¼þ  | 
| #  @return  | 
| def DoAddFamilyActivity(curPlayer, actionid, addCnt):  | 
|     if actionid not in ShareDefine.FamilyActiveIDList:  | 
|         return  | 
|     sysMsg = '%s'%([actionid, addCnt])  | 
|     curPlayer.MapServer_QueryPlayerResult(0, 0, "AddFamilyActivity", sysMsg, len(sysMsg))  | 
|     return  | 
|   | 
| ## »ñÈ¡¹¦ÄÜÏÞÖÆµÈ¼¶(µÈ¼¶Ìõ¼þΪȫ¾Ö)  | 
| def GetFuncLimitLV(funcID):  | 
|     ipyData = IpyGameDataPY.GetIpyGameData("FuncOpenLV", funcID)  | 
|     if not ipyData:  | 
|         return 0  | 
|       | 
|     return ipyData.GetLimitLV()  | 
|   |