| #!/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: "2017-06-22 15:00" hxp ¿ç·þ¹ã²¥Ôö¼ÓÌõ¼þ¹ýÂË×Ó·þÊÇ·ñÌáÐÑ£»¿ç·þ·þÎñÆ÷È«·þ¹ã²¥Í¬²½×Ó·þ  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2017-06-22 15:00"""  | 
| #---------------------------------------------------------------------  | 
| import GameWorld  | 
| import IPY_GameServer  | 
| import IpyGameDataPY  | 
| import CrossRealmMsg  | 
| 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  | 
|   | 
| def GetCrossWorldNotifyInfo(country, msgMark, msgParamList=[]):  | 
|     return {"Type":ShareDefine.CrossNotify_World, "Params":[country, msgMark, msgParamList]}  | 
|   | 
| def GetCrossFamilyNotifyInfo(familyID, msgMark, msgParamList=[]):  | 
|     return {"Type":ShareDefine.CrossNotify_Family, "Params":[familyID, msgMark, msgParamList]}  | 
|   | 
| def CrossNotify(serverGroupIDList, crossNotifyList):  | 
|     ''' ¿ç·þ¹ã²¥ÐÅÏ¢Ìáʾ£¬Ö§³Öͬ²½¶àÌõ£¬Í¬Ê±Ò²½¨Òé¶àÌõÒ»Æðͬ²½  | 
|     @param serverGroupIDList: ÐèҪͬ²½µ½µÄÄ¿±ê·þÎñÆ÷×éIDÁÐ±í  | 
|     @param crossNotifyList: ÐÅÏ¢ÌáʾÁÐ±í£¬Í¨¹ý GetCrossWorldNotifyInfo GetCrossFamilyNotifyInfo º¯Êý»ñµÃ·µ»ØÖµÌí¼Óµ½ÁÐ±í  | 
|     '''  | 
|     CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Notify, crossNotifyList, serverGroupIDList)  | 
|     return  | 
|   | 
| def CrossServerMsg_Notify(crossNotifyList):  | 
|     GameWorld.DebugLog("ÊÕµ½¿ç·þͬ²½µÄ¹ã²¥ÌáʾÄÚÈÝ: count=%s" % len(crossNotifyList))  | 
|     for notifyInfo in crossNotifyList:  | 
|         if "Type" not in notifyInfo or "Params" not in notifyInfo:  | 
|             continue  | 
|         notifyType = notifyInfo["Type"]  | 
|         params = notifyInfo["Params"]  | 
|         if notifyType == ShareDefine.CrossNotify_World:  | 
|             country, msgMark, msgParamList = params  | 
|             WorldNotify(country, msgMark, msgParamList)  | 
|         elif notifyType == ShareDefine.CrossNotify_Family:  | 
|             familyID, msgMark, msgParamList = params  | 
|             FamilyNotify(familyID, msgMark, msgParamList)  | 
|               | 
|     return  | 
|       | 
| ## ÊÀ½ç¹ã²¥  | 
| #  @param country ÌáʾµÄ¹ú¼Ò  | 
| #  @param msgMark ÌáʾÐÅÏ¢Mark  | 
| #  @param msgParamList ÐÅÏ¢²ÎÊýÁÐ±í  | 
| #  @return ÎÞ·µ»ØÖµ  | 
| #  @remarks   | 
| def WorldNotify(country, msgMark, msgParamList=[]):  | 
|     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  | 
|   | 
|   | 
| #------------------------------------------------------------------------------   | 
|   | 
| ##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()  | 
|   | 
| ## ¸ù¾ÝÌØÈ¨ID ºÍ VIPµÈ¼¶»ñµÃÌØÈ¨Öµ  | 
| def GetPrivilegeValue(vipLV, privilegeID):  | 
|     if privilegeID not in ChConfig.VIPPrivilegeList:  | 
|         return 0  | 
|     vipMsg = IpyGameDataPY.GetIpyGameData('VipPrivilege', privilegeID)  | 
|     if not vipMsg:  | 
|         return 0  | 
|     return getattr(vipMsg, 'GetVIP%d' % vipLV)()  | 
|   | 
| ##ÁÄÌìÆøÅÝ¿ò  | 
| def GetChatBubbleBox(curPlayer): return curPlayer.GetExAttr10()  | 
| def SetChatBubbleBox(curPlayer, value): return curPlayer.SetExAttr10(value)  | 
|   | 
| ##½ñÈÕÒÑ»ñµÃÏÉÔµ±Ò  | 
| def GetTodayXianyuanCoin(curPlayer): return curPlayer.GetExAttr11()  | 
| def SetTodayXianyuanCoin(curPlayer, value): return curPlayer.SetExAttr11(value)  | 
|   | 
| ##Íæ¼ÒÖ÷¶¯Í˳öÏÉÃËʱ¼ä(<100´ú±íÍ˳ö´ÎÊý)  | 
| def SetLeaveFamilyTime(curPlayer, value, isSyncMap=True):  | 
|     curPlayer.SetExAttr12(value)  | 
|     if isSyncMap:  | 
|         sysMsg = '%s'%value  | 
|         curPlayer.MapServer_QueryPlayerResult(0, 0, "SetLeaveFamilyTime", sysMsg, len(sysMsg))  | 
|     return   | 
| def GetLeaveFamilyTime(curPlayer):return curPlayer.GetExAttr12()  | 
|   | 
| ## Íæ¼ÒËùÊô·þÎñÆ÷×éID  | 
| def GetPlayerServerGroupID(curPlayer): return curPlayer.GetExAttr13()  | 
| def SetPlayerServerGroupID(curPlayer, groupID): return curPlayer.SetExAttr13(groupID)  | 
|   | 
| ## ÊÇ·ñÍÑ»ú¹Ò»ú״̬  | 
| 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 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)   | 
|     GameWorld.Log("SetVSRoomID playerID=%s, roomID=%s" % (curPlayer.GetPlayerID(), roomID))  | 
|     SetMapServerPlayerAttrValue(curPlayer, "SetVsRoomId", roomID)  | 
|     return  | 
|   | 
| ## ¿ç·þ״̬ËùÔÚµØÍ¼ID: 0-·Ç¿ç·þ״̬£¬·Ç0-¿ç·þ״̬¶ÔÓ¦µÄµØÍ¼ID  | 
| def GetCrossMapID(curPlayer): return curPlayer.GetExAttr5()  | 
| def SetCrossMapID(curPlayer, value):  | 
|     curPlayer.SetExAttr5(value)  | 
|     SetMapServerPlayerAttrValue(curPlayer, "SetExAttr5", value)  | 
|     return  | 
|   | 
| def SetMapServerPlayerAttrValue(curPlayer, attrName, value, exData=[]):  | 
|     ## ÉèÖõØÍ¼·þÎñÆ÷Íæ¼Ò¶ÔÓ¦ÊôÐÔÖµ  | 
|     setAttrInfo = str([attrName, value] + exData)  | 
|     curPlayer.MapServer_QueryPlayerResult(0, 0, "SetPlayerAttr", setAttrInfo, len(setAttrInfo))  | 
|     return  | 
|   | 
| ## µØÍ¼·þÎñÆ÷¿ÛÎïÆ·  | 
| #  @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()  | 
|   |