#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package PlayerRecall # # @todo: Íæ¼ÒÕÙ»ØÍæ¼Ò # @author Alee # @date 2011-07-22 15:00 # @version 1.5 # # ÏêϸÃèÊö: # @change: "2011-07-25 19:00" Alee ÁìÈ¡½±ÀøÅж¨ºÍÉêÇëÑûÇëÂë֪ͨ # @change: "2011-07-26 15:30" Alee GameServerºÍMapServer½»»¥¼ä¸ôÎÞÅжϵ¼Ö£¬ÁìÈ¡¶à·ÝÀñÎï # @change: "2011-07-29 11:40" Alee Ð޸ļÇÂ¼Íæ¼ÒÌá½»ÑûÇëÂë # @change: "2011-07-29 17:30" Alee Ïêϸ¼Ç¼ºÍÊä³ö # @change: "2012-05-16 14:30" jiang C++½Ó¿ÚÐÞ¸ÄMapServer_QueryPlayerResultºÍMapServer_QueryPlayerÐÞ¸Ä #------------------------------------------------------------------------------ """Version = 2012-05-16 14:30""" #------------------------------------------------------------------------------ import GameWorld import ChConfig import ReadChConfig import ShareDefine import PlayerControl import IPY_GameServer ##µÇ½ͬʱ¿Í»§¶ËÍæ¼ÒÕÙ»ØÐÅÏ¢ # @param curPlayer Íæ¼ÒʵÀý # @return None def LoginSync_PlayerRecallInfo(curPlayer): if ReadChConfig.GetEvalChConfig('PlayerRecall_Open') != ShareDefine.Def_Player_Recall_Open: return playerID = curPlayer.GetPlayerID() recallMgr = GameWorld.GetGameWorld().GetPlayerRecallMgr() recall = recallMgr.FindPlayerRecallByPlayerID(playerID) if recall == None: return recallCount = recall.GetRecallCount() awardInfo = recall.GetReceiveFlag() #GameWorld.Log("ÉÏÏß֪ͨ¿Í»§¶Ë %s,%s,%s"%(playerID, recallCount, awardInfo)) curPlayer.Sync_PlayerRecallInfo(recallCount, awardInfo) curPlayer.Sync_SendInviteCode(playerID) return ##Íæ¼Ò·¢ËÍÑûÇëÂë # @param srcPlayerID ·¢ËÍÕßID # @param tagPlayerID ÑûÇëÕßID # @return 0ʧ°Ü 1³É¹¦ def PlayerRecall_InviteCode(srcPlayerID, tagPlayerID): srcPlayer = GameWorld.GetPlayerManager().FindPlayerByID(srcPlayerID) if not srcPlayer: GameWorld.ErrLog("PlayerRecall_InviteCode no srcPlayer id=%s"%srcPlayerID) return '0' recallMgr = GameWorld.GetGameWorld().GetPlayerRecallMgr() recall = recallMgr.FindPlayerRecallByPlayerID(tagPlayerID) if recall == None: return '0' recallCount = recall.GetRecallCount() + 1 recall.SetRecallCount(recallCount) srcPlayerName = srcPlayer.GetName() #֪ͨ¿Í»§¶Ë tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID) if not tagPlayer: return '1' tagPlayer.Sync_PlayerRecallInfo(recallCount, recall.GetReceiveFlag()) PlayerControl.NotifyCode(tagPlayer, "GeRen_lhs_592851", [srcPlayerName, recallCount]) return '1' #=============================================================================== # //03 3C ÁìÈ¡Õٻؽ±Àø#tagCReceiveRecallReward # struct tagCReceiveRecallReward # { # tagHead Head; # WORD RecallCount; //ÕٻظöÊý # }; #=============================================================================== ##ÁìÈ¡ÕٻظöÊý½±Àø #@param index Íæ¼ÒË÷Òý #@param tick ʱ¼ä´Á #@return ·µ»ØÖµÎÞÒâÒå def ReceiveRecallReward(index, tick): if ReadChConfig.GetEvalChConfig('PlayerRecall_Open') != ShareDefine.Def_Player_Recall_Open: return pack = IPY_GameServer.IPY_CReceiveRecallReward() recallCount = pack.GetRecallCount() curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) playerID = curPlayer.GetID() recallMgr = GameWorld.GetGameWorld().GetPlayerRecallMgr() recall = recallMgr.FindPlayerRecallByPlayerID(curPlayer.GetPlayerID()) if recall == None: GameWorld.ErrLog("ReceiveRecallReward ûÓÐÉêÇë¹ýÑûÇëÂë", playerID) return realCount = recall.GetRecallCount() #ÁìÈ¡½±ÀøÈËÊýÑéÖ¤ if recallCount > realCount: GameWorld.ErrLog("ReceiveRecallReward CntErr packCount=%s realCount=%s"%(recallCount, realCount), playerID) return awardDict = ReadChConfig.GetEvalChConfig('PlayerRecall_RecallCount') awardList = awardDict.get(recallCount) if awardList == None: GameWorld.ErrLog("ReceiveRecallReward AwardErr count=%s awardDict=%s"%(recallCount, awardDict), playerID) return #Ìí¼Ó×ÖµäÓÃÓÚÔÚMapServer »Ø¸´ÏûϢǰ£¬ÏÞÖÆ·¢°ü£¬Î´È·ÈϽá¹û if curPlayer.GetDictByKey(ChConfig.Def_Player_NoSave_Dict_RecallCountGift) == 1: return curPlayer.SetDict(ChConfig.Def_Player_NoSave_Dict_RecallCountGift, 1) awardFlag = awardList[0] realFlag = recall.GetReceiveFlag() #ÑéÖ¤ÊÇ·ñÁìÈ¡¹ý£¬ÕæÕýµÄÅжÏÊÇ·ñÁìÈ¡ if awardFlag&realFlag != 0: #ÒòΪҪÁ첻ͬµÄÀñÎÔÚÅжÏÒÑÁìÈ¡ºó»¹Ô­¿É´¦ÀíÏÂÒ»¸ö°ü±êʶ curPlayer.SetDict(ChConfig.Def_Player_NoSave_Dict_RecallCountGift, 0) GameWorld.ErrLog("ReceiveRecallReward HadReceive count=%s awardFlag=%s, \ realFlag=%s"%(recallCount, awardFlag, realFlag), playerID) return mapID = GameWorld.GetQueryPlayerMapID(curPlayer) #GameWorld.Log("·¢Ë͸øMapServer") #·¢ËÍÇëÇóÖÁÄ¿±êµØÍ¼ GameWorld.GetPlayerManager().MapServer_QueryPlayer(playerID, 0, playerID, mapID, 'ReveiveRecallAward', '%s'%awardList, len(str(awardList)), curPlayer.GetRouteServerIndex()) return ##ÁìÈ¡ÕٻظöÊý½±Àø #@param srcPlayerID Íæ¼ÒID #@param resultName ÁìÈ¡½á¹û #@return ·µ»ØÖµÎÞÒâÒå def ReveiveRecallAwardResult(srcPlayerID, resultName): srcPlayer = GameWorld.GetPlayerManager().FindPlayerByID(srcPlayerID) if not srcPlayer: return #»Ö¸´¿É´¦Àí°üÂß¼­ srcPlayer.SetDict(ChConfig.Def_Player_NoSave_Dict_RecallCountGift, 0) #Áìȡʧ°ÜÍ˳ö if resultName == '0': return recallMgr = GameWorld.GetGameWorld().GetPlayerRecallMgr() recall = recallMgr.FindPlayerRecallByPlayerID(srcPlayerID) if recall == None: return curFlag = int(resultName)|recall.GetReceiveFlag() recall.SetReceiveFlag(curFlag) srcPlayer.Sync_PlayerRecallInfo(recall.GetRecallCount(), curFlag) return #=============================================================================== # //03 3F ÉêÇëÑûÇëÂë#tagCRequestInviteCode # struct tagCRequestInviteCode # { # tagHead Head; # }; #=============================================================================== ##ÉêÇëÑûÇëÂë #@param index Íæ¼ÒË÷Òý #@param tick ʱ¼ä´Á #@return ·µ»ØÖµÎÞÒâÒå def ApplyInviteCode(index, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) playerID = curPlayer.GetPlayerID() recallMgr = GameWorld.GetGameWorld().GetPlayerRecallMgr() recall = recallMgr.FindPlayerRecallByPlayerID(playerID) if recall != None: return if playerID < 0: #ÒÔºó¿ÉÒÔɾ³ýÁË GameWorld.ErrLog('ApplyInviteCode Íæ¼ÒID=%sÒì³£'%playerID) #³õʼ»¯Ò»´Î recall = recallMgr.GetPlayerRecallByPlayerID(playerID) recall.SetRecallCount(0) recall.SetReceiveFlag(0) curPlayer.Sync_PlayerRecallInfo(0, 0) curPlayer.Sync_SendInviteCode(playerID) PlayerControl.NotifyCode(curPlayer, 'GeRen_lhs_770488') return