#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#
|
##@package E:/GameSVN/U3DGame/ProjectSServer/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerFriend.py
|
# @todo:
|
#
|
# @author: Alee
|
# @date 2017-8-28 ÏÂÎç10:28:54
|
# @version 1.0
|
#
|
# @note:
|
#
|
#---------------------------------------------------------------------
|
#"""Version = 2017-8-28 21:00"""
|
#---------------------------------------------------------------------
|
import IPY_GameServer
|
import GameWorld
|
import ChConfig
|
import PlayerRequest
|
import PlayerControl
|
import ChPyNetSendPack
|
import NetPackCommon
|
import ShareDefine
|
import PyDataManager
|
import IpyGameDataPY
|
import random
|
import PlayerSocial
|
import copy
|
import PlayerViewCache
|
import PlayerTeam
|
|
#---------------------------------------------------------------------
|
|
|
############################################################
|
#·â°ü
|
|
#===============================================================================
|
# //B3 01 Ìí¼ÓºÃÓÑ#tagCGAddFriend
|
#
|
# struct tagCGAddFriend
|
# {
|
# tagHead Head;
|
# char TagName[33]; //Íæ¼ÒÃû³Æ
|
# DWORD TagID; //Íæ¼ÒID
|
# };
|
#===============================================================================
|
## Ìí¼ÓºÃÓÑ
|
def AddFriend(index, clientData, tick):
|
#»ñÈ¡Íæ¼Ò
|
playerManager = GameWorld.GetPlayerManager()
|
curPlayer = playerManager.GetPlayerByIndex(index)
|
curTagPlayerID = clientData.TagID
|
|
limitLV = GetFuncLimitLV(ShareDefine.GameFuncID_Friend)
|
if curPlayer.GetLV() < limitLV:
|
PlayerControl.NotifyCode(curPlayer, 'LvErr')
|
return
|
|
if not CheckFriendCount(curPlayer, True, curPlayer.GetID()):
|
#ºÃÓÑÒѾÂúÁË
|
GameWorld.DebugLog("ºÃÓÑÒѾÂúÁË")
|
return
|
|
#»ñÈ¡Ä¿±êÍæ¼Ò
|
tagPlayer = None
|
tagLV = 0
|
if clientData.TagID != 0:
|
tagPlayer = playerManager.FindPlayerByID(curTagPlayerID)
|
else:
|
tagPlayer = playerManager.FindPlayerByName(clientData.TagName)
|
#Ãû³Æ¼ÓºÃÓѲ»Ö§³ÖÀëÏß
|
if tagPlayer == None:
|
#XW_SJ_AimOffline Íæ¼ÒÒÑÏÂÏß
|
PlayerControl.NotifyCode(curPlayer, 'Friend_OffLine')
|
return
|
|
if not tagPlayer:
|
curCache = PlayerViewCache.FindViewCache(curTagPlayerID)
|
if not curCache:
|
#Íæ¼ÒµÄÊý¾ÝûÓлº´æ¹ý
|
PlayerControl.NotifyCode(curPlayer, 'Friend_OffLine')
|
return
|
tagLV = curCache.LV
|
else:
|
tagLV = tagPlayer.GetLV()
|
|
if tagLV < limitLV:
|
PlayerControl.NotifyCode(curPlayer, 'Friend_OtherLessLv')
|
return
|
|
curPlayerID = curPlayer.GetID()
|
|
if curPlayerID == curTagPlayerID:
|
#²»ÔÊÐíÌí¼Ó×Ô¼º
|
GameWorld.DebugLog("²»ÔÊÐíÌí¼Ó×Ô¼º")
|
return
|
|
# ºÚÃûµ¥¼ì²é
|
if PyDataManager.GetBlacklistManager().CheckBlacklistBoth(curPlayerID, curTagPlayerID, curPlayer):
|
GameWorld.DebugLog("ºÚÃûµ¥¼ì²é")
|
return
|
|
curPlayerFriendStruct = GetFriendStruct(curPlayerID)
|
|
tagFriend = curPlayerFriendStruct.Find(curTagPlayerID)
|
|
if tagFriend != None:
|
#XW_SJ_Repeat:¶Ô²»Æð,xxxÒÑÊÇÄúµÄºÃÓÑ,Ìí¼ÓºÃÓÑʧ°Ü!</n>
|
PlayerControl.NotifyCode(curPlayer, "Friend_YetFriend")
|
return
|
|
# Òì³£¼ì²é
|
__CheckAddFriend(curPlayer, curTagPlayerID)
|
|
#µ±Ç°Íæ¼ÒÌí¼ÓÇëÇó
|
#curPlayer.AddRequest(curTagPlayerID, IPY_GameServer.reqFriend, tick, ChConfig.Def_EventClearTime)
|
PlayerRequest.PYAddRequest(curPlayer, curTagPlayerID, IPY_GameServer.reqFriend)
|
|
#Óë¿Í»§¶ËÔ¼¶¨Ãû×Öºó¼ÓÍæ¼ÒÖ°ÒµºÍµÈ¼¶£¬¿Í»§¶Ë×ÔÐвð¿ª
|
#tagPlayer.Frm_AddFriendAsk(curPlayerID, '|'.join([curPlayer.GetName(), str(curPlayer.GetJob()), str(curPlayer.GetLV())]))
|
|
if tagPlayer:
|
askFriendPack = ChPyNetSendPack.tagGCFriendAskIfJoin()
|
askFriendPack.AskID = curPlayerID
|
askFriendPack.Name = curPlayer.GetName()
|
askFriendPack.LV = curPlayer.GetLV()
|
askFriendPack.RealmLV = curPlayer.GetOfficialRank()
|
askFriendPack.Face = curPlayer.GetFace()
|
askFriendPack.FacePic = curPlayer.GetFacePic()
|
|
NetPackCommon.SendFakePack(tagPlayer, askFriendPack)
|
|
#XW_SJ_ApplyFriend ºÃÓÑÇëÇó·¢Ëͳɹ¦
|
PlayerControl.NotifyCode(curPlayer, 'Friend_ApplyFriend')
|
return
|
|
|
#---------------------------------------------------------------------
|
##»ñÈ¡Íæ¼Ò½á¹¹Ìå
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @return IPY_Friend ʵÀý
|
# @remarks
|
def GetFriendStruct(playerID):
|
curFriends = PyDataManager.GetFriendManager().GetFriends(playerID)
|
|
if curFriends != None:
|
return curFriends
|
|
return PyDataManager.GetFriendManager().AddFriends(playerID)
|
|
def IsFriend(playerID, tagPlayerID):
|
## ÅжÏË«·½ÊÇ·ñºÃÓÑ
|
curFriends = PyDataManager.GetFriendManager().GetFriends(playerID)
|
if not curFriends:
|
return False
|
return curFriends.Find(tagPlayerID) != None
|
|
#---------------------------------------------------------------------
|
##ºÃÓѼì²é
|
# @param curPlayer ÉêÇëºÃÓѵÄÍæ¼Ò
|
# @param tagPlayer ½ÓÊÜÉêÇëºÃÓѵÄÍæ¼Ò
|
# @return None
|
# @remarks
|
def __CheckAddFriend(curPlayer, curTagPlayerID):
|
curPlayerID = curPlayer.GetID()
|
#»ñÈ¡ÉêÇëºÃÓÑÍæ¼ÒÐÅÏ¢
|
curPlayerFriendStruct = GetFriendStruct(curPlayerID)
|
curPlayerHasThisFriend = curPlayerFriendStruct.Find(curTagPlayerID)
|
#»ñÈ¡½ÓÊÜÉêÇëºÃÓѵÄÍæ¼ÒÐÅÏ¢
|
tagPlayerFriendStruct = GetFriendStruct(curTagPlayerID)
|
tagPlayerHasThisFriend = tagPlayerFriendStruct.Find(curPlayerID)
|
|
if curPlayerHasThisFriend != None and tagPlayerHasThisFriend != None:
|
# ͬʱÊǶԷ½ºÃÓÑ
|
return
|
|
if curPlayerHasThisFriend == None and tagPlayerHasThisFriend == None:
|
# ͬʱ¶¼²»ÊǶԷ½ºÃÓÑ
|
return
|
|
#״̬Ò쳣ɾ³ýË«·½µÄ¹Øϵ
|
GameWorld.ErrLog('AddFriend, (%s, %s)ºÃÓÑÒì³£, ɾ³ýË«·½ºÃÓѹØϵ' % (curPlayerID, curTagPlayerID))
|
|
# Ö»ÓÐijһ·½ÊÇÁíÒ»·½ºÃÓÑ
|
if curPlayerHasThisFriend != None:
|
curPlayerFriendStruct.DelFriend(curTagPlayerID)
|
|
if tagPlayerHasThisFriend != None:
|
tagPlayerFriendStruct.DelFriend(curPlayerID)
|
|
return
|
|
#===============================================================================
|
# //B3 02 ɾ³ýºÃÓÑ#tagCGDeleteFriend
|
#
|
# struct tagCGDeleteFriend
|
# {
|
# tagHead Head;
|
# DWORD FriendID;
|
# };
|
#===============================================================================
|
## ɾ³ýºÃÓÑ
|
def DeleteFriend(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
playerID = curPlayer.GetPlayerID()
|
curFriends = PyDataManager.GetFriendManager().GetFriends(playerID)
|
if curFriends == None:
|
GameWorld.Log('DeleteFriend -> ·â°üÒì³£ ->ûÓкÃÓÑ',playerID)
|
return
|
|
friendID = clientData.FriendID
|
curFriend = curFriends.Find(friendID)
|
if curFriend == None:
|
GameWorld.Log('DeleteFriend -> ·â°üÒì³£ ->ûÓÐÕâ¸öÍæ¼Ò', playerID)
|
return
|
|
couple = PyDataManager.GetDBPyCoupleManager().GetCouple(playerID)
|
if couple and couple.GetCoupleID(playerID) == friendID:
|
#GameWorld.Log('DeleteFriend -> ·â°üÒì³£ ->°é²»ÄÜɾ³ýºÃÓÑ.friendID=%s' % friendID, playerID)
|
PlayerControl.NotifyCode(curPlayer, "DelFriendCoupleLimit")
|
return
|
|
#ÀëÏߺÃÓÑͬʱɾ³ý¼Ç¼
|
PyDataManager.GetFriendManager().DelFriendBoth(playerID, friendID)
|
|
#XW_SJ_DeleteFriend ½â³ýºÃÓѳɹ¦
|
PlayerControl.NotifyCode(curPlayer, 'Friend_DeleteFriend')
|
|
tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(friendID)
|
if tagPlayer != None:
|
PlayerControl.NotifyCode(tagPlayer, 'Friend_DeleteFriend2', [curPlayer.GetName()])
|
PlayerTeam.OnTeamMemFriendChange(curPlayer, friendID, False)
|
|
# Ç×ÃܶȼõÉÙ
|
decIntimacyPer = IpyGameDataPY.GetFuncCfg("IntimacyReduce", 1)
|
if decIntimacyPer:
|
PyDataManager.GetIntimacyManager().DelIntimacyBothPer(playerID, friendID, decIntimacyPer)
|
|
return
|
|
|
## ¼ì²âºÃÓÑÊýÊÇ·ñ´ïµ½ÉÏÏÞ
|
# @param curPlayer µ±Ç°Íæ¼Ò
|
# @return ²¼¶ûÖµ
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def CheckFriendCount(curPlayer, isNotify, playerID):
|
|
curFriends = PyDataManager.GetFriendManager().GetFriends(playerID)
|
if curFriends == None:
|
return True
|
|
if curFriends.GetCount() >= IpyGameDataPY.GetFuncCfg("FriendMaxCnt"):
|
# ºÃÓÑÒÑÂú
|
if isNotify:
|
PlayerControl.NotifyCode(curPlayer, "Friend_FullList")
|
return False
|
|
return True
|
|
#===============================================================================
|
# //B3 03 ÊÇ·ñÔÊÐí¼ÓÈëºÃÓѵĻØÓ¦#tagCGJoinFriendAnswer
|
#
|
# struct tagCGJoinFriendAnswer
|
# {
|
# tagHead Head;
|
# DWORD TagID;
|
# BYTE Answer; //0: ¾Ü¾ø 1: ½ÓÊÜ
|
# };
|
#===============================================================================
|
## ÊÇ·ñÔÊÐí¼ÓÈëºÃÓѵĻØÓ¦
|
def JoinFriendAnswer(index, clientData, tick):
|
playerManager = GameWorld.GetPlayerManager()
|
curPlayer = playerManager.GetPlayerByIndex(index)
|
|
srcPlayerID = clientData.TagID # ÇëÇóÕßµÄID
|
srcPlayer = playerManager.FindPlayerByID(srcPlayerID)
|
if srcPlayer == None:
|
# Íæ¼ÒÒÑÏÂÏß
|
curCache = PlayerViewCache.FindViewCache(srcPlayerID)
|
if not curCache:
|
#Íæ¼ÒµÄÊý¾ÝûÓлº´æ¹ý
|
#PlayerControl.NotifyCode(curPlayer, 'Friend_OffLine')
|
return
|
|
playerID = curPlayer.GetPlayerID()
|
|
if playerID == srcPlayerID:
|
GameWorld.Log('JoinFriendAnswer -> ·â°üÒì³£ ->²»ÄܼÓÈë×Ô¼ºÎªºÃÓÑ', playerID)
|
return
|
|
if not PlayerRequest.PYCheckRequest(srcPlayerID, curPlayer, IPY_GameServer.reqFriend):
|
GameWorld.Log("JoinFriendAnswer -> ·â°üÒì³£ ->Íæ¼ÒûÓÐÕâ¸öÇëÇó", playerID)
|
return
|
|
if not clientData.Answer:
|
if srcPlayer:
|
#XW_SJ_RefuseApply XXX¾Ü¾ø°ÑÄã¼ÓΪºÃÓÑ
|
PlayerControl.NotifyCode(srcPlayer, 'Friend_RejectFriend', [curPlayer.GetName()])
|
return
|
|
# ºÚÃûµ¥¼ì²é
|
if PyDataManager.GetBlacklistManager().CheckBlacklistBoth(playerID, srcPlayerID, curPlayer):
|
return
|
|
#×Ô¼ºµÄºÃÓÑÂúÔ±
|
if not CheckFriendCount(curPlayer, True, curPlayer.GetID()):
|
|
GameWorld.DebugLog("#×Ô¼ºµÄºÃÓÑÂúÔ±")
|
return
|
|
#¶Ô·½µÄºÃÓÑÂúÔ±
|
if not CheckFriendCount(None, False, srcPlayerID):
|
PlayerControl.NotifyCode(curPlayer, "Friend_OtherFullList")
|
return
|
|
curFriends = PyDataManager.GetFriendManager().GetFriends(playerID)
|
if curFriends == None:
|
curFriends = PyDataManager.GetFriendManager().AddFriends(playerID)
|
|
tagFriend = curFriends.Find(playerID)
|
if tagFriend != None:
|
#Õâ¸öºÃÓÑÒѾÔÚ×Ô¼ºµÄºÃÓÑÁбíÖÐ
|
GameWorld.Log('JoinFriendAnswer -> ·â°üÒì³£ ->Õâ¸öºÃÓÑÒѾÔÚ×Ô¼ºµÄºÃÓÑÁбíÖÐ', playerID)
|
return
|
|
PyDataManager.GetFriendManager().AddFriendBoth(playerID, srcPlayerID)
|
|
#XW_SJ_AppendFriend xxx³ÉΪÁËÄúµÄºÃÓÑ
|
##·¢ËÍÌí¼ÓºÃÓѳɹ¦µ½µØͼ·þÎñÆ÷
|
# ´Ë´¦Í¨ÖªÖ»ÊÇ´¥·¢Í¬Ò»¸öºÃÓÑÌí¼Óɾ³ý¿É´¥·¢¶à´Î£¬ MapServer_SyncFriendInfoΪ¾ßÌåµÄºÃÓÑÊýÁ¿£¬¸ù¾Ý²ß»®ÐèÇóÖÆ×÷
|
#curPlayer.MapServer_QueryPlayerResult(0, 0, 'AddFriendSucceed', "", 0)
|
if srcPlayer:
|
PlayerControl.NotifyCode(curPlayer, 'Friend_MakeFriend', [srcPlayer.GetName()])
|
PlayerControl.NotifyCode(srcPlayer, 'Friend_MakeFriend', [curPlayer.GetName()])
|
#srcPlayer.MapServer_QueryPlayerResult(0, 0, 'AddFriendSucceed', "", 0)
|
else:
|
cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
PlayerControl.NotifyCode(curPlayer, 'Friend_MakeFriend', [cacheDict['Name']])
|
# ¼Ç¼µÈ¶Ô·½ÉÏÏß֪ͨµØͼ£¬ÈÎÎñµÈ»áÓõ½´¥·¢Âß¼£¬Í¨ÓüǼ´ÎÊý¼´¿É£¬ MapServer_SyncFriendInfoΪ¾ßÌåµÄºÃÓÑÊýÁ¿£¬¸ù¾Ý²ß»®ÐèÇóÖÆ×÷
|
pass
|
PlayerTeam.OnTeamMemFriendChange(curPlayer, srcPlayerID, True)
|
return
|
|
|
|
#//06 02 Ìí¼ÓµÐÈË#tagGAddEnemy
|
#tagGAddEnemy * GettagGAddEnemy();
|
#
|
#class IPY_GAddEnemy
|
#{
|
#public:
|
#
|
# int GetEnemyID();
|
#
|
# char * GetEnemyName();
|
#};
|
## Ìí¼ÓµÐÈË
|
# @param index Íæ¼ÒË÷Òý
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def MapServer_AddEnemy(index, tick):
|
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
pack = IPY_GameServer.IPY_GAddEnemy()
|
tagID = pack.GetEnemyID()
|
playerID = curPlayer.GetPlayerID()
|
|
friends = PyDataManager.GetFriendManager().GetFriends(playerID)
|
if friends and friends.Find(tagID):
|
#ºÃÓѲ»¼ÓÈë³ðÈË
|
return
|
|
enemies = PyDataManager.GetEnemyManager().GetEnemies(playerID)
|
if enemies and enemies.GetCount() > IpyGameDataPY.GetFuncCfg("EnemiesMaxCnt"):
|
return
|
|
# ÐèÒª¸üÐÂ×îÐÂÊý¾ÝÕâÀï²»¹ýÂËÊÇ·ñÒѾÊdzðÈË
|
PyDataManager.GetEnemyManager().AddEnemy(playerID, tagID)
|
|
return
|
|
#===============================================================================
|
# //B3 04 ¼ÓÈëºÚÃûµ¥ #tagCGAddBlackList
|
#
|
# struct tagCGAddBlackList
|
# {
|
# tagHead Head;
|
# DWORD TagID; //Íæ¼ÒID
|
# };
|
#===============================================================================
|
def AddBlackList(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
tagID = clientData.TagID
|
|
# ·ÇÉ罻ȦÄÚÍæ¼Ò²»ÄܼÓÈëºÚÃûµ¥
|
#===========================================================================
|
# if not PyDataManager.GetPersonalSocialManager().GetSocialPlayer(tagID):
|
# #¼Ù·â°ü»òÕßÒì³£
|
# GameWorld.DebugLog("#¼Ù·â°ü»òÕßÒì³£")
|
# return
|
#===========================================================================
|
|
couple = PyDataManager.GetDBPyCoupleManager().GetCouple(curPlayer.GetID())
|
if couple and couple.GetCoupleID(curPlayer.GetID()) == tagID:
|
#GameWorld.DebugLog("°é²»ÄܼÓÈëºÚÃûµ¥! tagID=%s" % tagID, curPlayer.GetID())
|
PlayerControl.NotifyCode(curPlayer, "AddBlackCoupleLimit")
|
return
|
|
tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagID)
|
if not tagPlayer:
|
curCache = PlayerViewCache.FindViewCache(tagID)
|
if not curCache:
|
return
|
cacheDict = PlayerViewCache.GetCachePropDataDict(curCache)
|
playerName = cacheDict['Name']
|
else:
|
playerName = tagPlayer.GetName()
|
|
players = PyDataManager.GetBlacklistManager().GetBlacklist(curPlayer.GetID())
|
if players != None:
|
|
if players.GetCount() >= IpyGameDataPY.GetFuncCfg("BlacklistMaxCnt"):
|
PlayerControl.NotifyCode(curPlayer, 'BlacklistFull')
|
return False
|
|
PyDataManager.GetBlacklistManager().JoinBlacklist(curPlayer.GetPlayerID(), tagID)
|
|
PlayerControl.NotifyCode(curPlayer, 'AddBlackList', [playerName])
|
|
# Ç×ÃܶȼõÉÙ
|
decIntimacyPer = IpyGameDataPY.GetFuncCfg("IntimacyReduce", 2)
|
if decIntimacyPer:
|
PyDataManager.GetIntimacyManager().DelIntimacyBothPer(curPlayer.GetPlayerID(), tagID, decIntimacyPer)
|
|
return
|
|
|
#===============================================================================
|
# //B3 05 ÒƳýºÚÃûµ¥ #tagCGDelBlackList
|
#
|
# struct tagCGDelBlackList
|
# {
|
# tagHead Head;
|
# DWORD TagID;
|
# };
|
#===============================================================================
|
def DelBlackList(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
PyDataManager.GetBlacklistManager().DelBlacklist(curPlayer.GetPlayerID(), clientData.TagID)
|
PlayerControl.NotifyCode(curPlayer, 'DelBlackSuccess')
|
#GameWorld.DebugLog("pack DelBlackList %s "%clientData.TagID)
|
return
|
|
############################################################
|
## µÇ½ºó֪ͨºÃÓÑ
|
def __OnPlayerLoginFriend(curPlayer, tick):
|
#Íæ¼ÒµÇ¼
|
curFriends = PyDataManager.GetFriendManager().GetFriends(curPlayer.GetID())
|
if curFriends == None:
|
return
|
|
curFriends.Sync_SocialsInfo(curPlayer)
|
#Ìí¼ÓÀëÏß¼ÓºÃÓÑ£¬ÉÏÏß֪ͨmapserver
|
curFriends.MapServer_SyncFriendInfo(curPlayer)
|
|
#֪ͨºÃÓÑÇëÇóÐÅÏ¢
|
PlayerRequest.Sync_LoginRequest(curPlayer)
|
return
|
|
## µÇ½ºó֪ͨ³ðÈË
|
def __OnPlayerLoginEnemy(curPlayer, tick):
|
#֪ͨ³ðÈËÐÅÏ¢
|
players = PyDataManager.GetEnemyManager().GetEnemies(curPlayer.GetID())
|
if players == None:
|
return
|
|
players.Sync_SocialsInfo(curPlayer)
|
return
|
|
# ×î½üÁªÏµÈË
|
def __OnPlayerLoginContacts(curPlayer, tick):
|
players = PyDataManager.GetContactsManager().GetContacts(curPlayer.GetID())
|
if players == None:
|
return
|
|
players.Sync_SocialsInfo(curPlayer)
|
return
|
|
#ºÚÃûµ¥
|
def __OnPlayerLoginBlacklist(curPlayer, tick):
|
players = PyDataManager.GetBlacklistManager().GetBlacklist(curPlayer.GetID())
|
if players == None:
|
return
|
|
players.Sync_SocialsInfo(curPlayer)
|
return
|
|
#Ç×ÃÜ
|
def __OnPlayerLoginIntimacylist(curPlayer, tick):
|
intimacys = PyDataManager.GetIntimacyManager().GetIntimacys(curPlayer.GetID())
|
if intimacys == None:
|
return
|
|
intimacys.Sync_SocialsInfo(curPlayer)
|
return
|
|
## Íæ¼ÒµÇ½
|
# @param curPlayer µ±Ç°Íæ¼Ò
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def OnPlayerLogin(curPlayer, tick):
|
socialPlayer = PyDataManager.GetPersonalSocialManager().GetSocialPlayer(curPlayer.GetID())
|
if socialPlayer:
|
socialPlayer.playerInfo.OnlineType = ChConfig.Def_Online
|
__OnPlayerLoginFriend(curPlayer, tick)
|
__OnPlayerLoginEnemy(curPlayer, tick)
|
__OnPlayerLoginContacts(curPlayer, tick)
|
__OnPlayerLoginBlacklist(curPlayer, tick)
|
__OnPlayerLoginIntimacylist(curPlayer, tick)
|
|
# Ïòµ±Ç°Íæ¼Ò֪ͨÏà¹ØÁªµÄËùÓÐÍæ¼ÒÐÅÏ¢
|
PlayerSocial.Sync_AllSocialsInfo(curPlayer)
|
|
# ÏòÏà¹ØÁªµÄËùÓÐÍæ¼Ò֪ͨµ±Ç°Íæ¼ÒÐÅÏ¢
|
PlayerSocial.Notify_All(curPlayer.GetID(), ChConfig.Def_CDBPlayerRefresh_Online, ChConfig.Def_Online)
|
return
|
|
|
|
## Íæ¼ÒÏÂÏß
|
# @param curPlayer µ±Ç°Íæ¼Ò
|
# @param tick µ±Ç°Ê±¼ä
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def OnPlayerDisconnect(curPlayer, tick):
|
if PlayerControl.GetIsTJG(curPlayer):
|
return
|
|
socialPlayer = PyDataManager.GetPersonalSocialManager().GetSocialPlayer(curPlayer.GetID())
|
if socialPlayer == None:
|
return
|
socialPlayer.playerInfo.OnlineType = ChConfig.Def_Offline
|
|
PlayerSocial.Notify_All(curPlayer.GetID(), ChConfig.Def_CDBPlayerRefresh_Online, ChConfig.Def_Offline)
|
return
|
|
|
|
#// A9 A3 ²é¿´ÍƼöºÃÓÑ #tagCGQueryRecommendFriends
|
#
|
#struct tagCGQueryRecommendFriends
|
#{
|
# tagHead Head;
|
#};
|
## ÍƼöºÃÓÑ
|
def Client_RecommendFriends(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
#recommendDict = [(5000, [0, 30]), (8000,[31, 50]), (9500,[51, 70]), (10000,[71, 800])]
|
recommendFriend = copy.deepcopy(IpyGameDataPY.GetFuncEvalCfg("recommendFriend"))
|
needCnt = IpyGameDataPY.GetFuncCfg("SerchFriendCnt")
|
|
playerLV = curPlayer.GetLV()
|
curPlayerID = curPlayer.GetPlayerID()
|
curPlayerFriendStruct = GetFriendStruct(curPlayerID)
|
|
limitLV = GetFuncLimitLV(ShareDefine.GameFuncID_Friend)
|
if playerLV < limitLV:
|
return
|
#¹¹½¨²éѯÁбí
|
allPlayerID = set()
|
playerManager = GameWorld.GetPlayerManager()
|
for i in range(0, playerManager.GetActivePlayerCount()):
|
findPlayer = playerManager.GetActivePlayerAt(i)
|
if findPlayer == None or not findPlayer.GetInitOK():
|
continue
|
curTagPlayerID = findPlayer.GetPlayerID()
|
if curPlayerID == curTagPlayerID:
|
#²»ÔÊÐíÌí¼Ó×Ô¼º
|
continue
|
|
# ÍƼöºÃÓÑÈ¥³ýÍÑ»ú¹ÒÍæ¼Ò
|
if PlayerControl.GetIsTJG(findPlayer):
|
continue
|
|
#ÒÑÊǺÃÓÑ
|
tagFriend = curPlayerFriendStruct.Find(curTagPlayerID)
|
if tagFriend != None:
|
continue
|
|
#ÔÚºÚÃûµ¥ÖÐ
|
if PyDataManager.GetBlacklistManager().CheckBlacklistBoth(curPlayerID, curTagPlayerID):
|
GameWorld.DebugLog("ºÚÃûµ¥¼ì²é")
|
continue
|
|
# ÒÑÔÚÇëÇóÁбíÖÐ
|
if PlayerRequest.IsRequesting(curPlayerID, curTagPlayerID, IPY_GameServer.reqFriend):
|
continue
|
|
#°´µÈ¼¶Çø¼ä·Ö×é
|
findLV = findPlayer.GetLV()
|
if findLV < limitLV:
|
# ÏÞÖƵȼ¶
|
continue
|
|
for recommend in recommendFriend:
|
minLV = recommend[1][0]
|
maxLV = recommend[1][1]
|
# ²»ÔÚÖ¸¶¨Çø¼äÄÚ
|
if not ((playerLV - maxLV) <= findLV <= (playerLV - minLV) and \
|
(playerLV + minLV) <= findLV <= (playerLV + maxLV)):
|
continue
|
|
if len(recommend) == 2:
|
recommend[1].append([])
|
recommend[1][2].append(curTagPlayerID)
|
|
# ×îÖÕɸѡÓÃ
|
allPlayerID.add(curTagPlayerID)
|
|
GameWorld.DebugLog("recommendFriend %s"%(recommendFriend,))
|
|
|
|
# °´È¨ÖزéÕÒÍæ¼Ò
|
playeIDs = []
|
for i in xrange(needCnt*2):
|
lvlimit = GameWorld.GetResultByRandomList(recommendFriend)
|
if len(lvlimit) == 2:
|
# ûÓÐÍæ¼Ò
|
continue
|
|
playerID = random.choice(lvlimit[2])
|
if playerID in playeIDs:
|
continue
|
|
if len(playeIDs) == needCnt:
|
break
|
|
#ÐÞÕý²»×ã
|
fixCnt = needCnt - len(playeIDs)
|
if fixCnt > 0:
|
fixList = list(allPlayerID - set(playeIDs))
|
playeIDs.extend(random.sample(fixList, min(fixCnt, len(fixList))))
|
|
sendPack = ChPyNetSendPack.tagGCRecommendFriendsInfo()
|
sendPack.Cnt = len(playeIDs)
|
sendPack.FriendsList = []
|
for playerID in playeIDs:
|
tagPlayer = playerManager.FindPlayerByID(playerID)
|
if not tagPlayer:
|
continue
|
rceFriendsData = ChPyNetSendPack.tagRecommendFriendsData()
|
rceFriendsData.ID = playerID
|
rceFriendsData.Name = tagPlayer.GetName()
|
rceFriendsData.LV = tagPlayer.GetLV()
|
rceFriendsData.Job = tagPlayer.GetJob()
|
rceFriendsData.RealmLV = tagPlayer.GetOfficialRank()
|
rceFriendsData.Face = tagPlayer.GetFace()
|
rceFriendsData.FacePic = tagPlayer.GetFacePic()
|
sendPack.FriendsList.append(rceFriendsData)
|
|
#GameWorld.DebugLog("Client_RecommendFriends:%s"%sendPack.FriendsList)
|
NetPackCommon.SendFakePack(curPlayer, sendPack)
|
return
|
|
|
#===============================================================================
|
# // A9 A4 ²éÕÒÍæ¼Ò #tagCGFuzzySearchPlayer
|
#
|
# struct tagCGFuzzySearchPlayer
|
# {
|
# tagHead Head;
|
# char Name[33];
|
# };
|
#===============================================================================
|
|
def FuzzySearchPlayer(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
findName = clientData.Name
|
limitLV = GetFuncLimitLV(ShareDefine.GameFuncID_Friend)
|
if curPlayer.GetLV() < limitLV:
|
return
|
|
players = []
|
curPlayerFriendStruct = GetFriendStruct(curPlayer.GetPlayerID())
|
playerManager = GameWorld.GetPlayerManager()
|
for i in range(0, playerManager.GetActivePlayerCount()):
|
findPlayer = playerManager.GetActivePlayerAt(i)
|
if findPlayer == None or not findPlayer.GetInitOK():
|
continue
|
|
curTagPlayerID = findPlayer.GetPlayerID()
|
if curPlayer.GetPlayerID() == curTagPlayerID:
|
#²»ÔÊÐíÌí¼Ó×Ô¼º
|
continue
|
|
#ÒÑÊǺÃÓÑ
|
tagFriend = curPlayerFriendStruct.Find(curTagPlayerID)
|
if tagFriend != None:
|
continue
|
|
if findPlayer.GetLV() < limitLV:
|
# ÏÞÖƵȼ¶
|
continue
|
|
if findName in findPlayer.GetName():
|
players.append(findPlayer)
|
|
|
sendPack = ChPyNetSendPack.tagGCRecommendFriendsInfo()
|
sendPack.Cnt = len(players)
|
sendPack.FriendsList = []
|
for tagPlayer in players:
|
rceFriendsData = ChPyNetSendPack.tagRecommendFriendsData()
|
rceFriendsData.ID = tagPlayer.GetID()
|
rceFriendsData.Name = tagPlayer.GetName()
|
rceFriendsData.LV = tagPlayer.GetLV()
|
rceFriendsData.Job = tagPlayer.GetJob()
|
rceFriendsData.RealmLV = tagPlayer.GetOfficialRank()
|
rceFriendsData.Face = tagPlayer.GetFace()
|
rceFriendsData.FacePic = tagPlayer.GetFacePic()
|
sendPack.FriendsList.append(rceFriendsData)
|
|
|
NetPackCommon.SendFakePack(curPlayer, sendPack)
|
return
|
|
|
|
## »ñÈ¡¹¦ÄÜÏÞÖƵȼ¶(µÈ¼¶Ìõ¼þΪȫ¾Ö)
|
def GetFuncLimitLV(funcID):
|
ipyData = IpyGameDataPY.GetIpyGameData("FuncOpenLV", funcID)
|
if not ipyData:
|
return 0
|
|
return ipyData.GetLimitLV()
|
|
|