ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerControl.py
@@ -12,7 +12,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一致
@@ -28,6 +27,7 @@
#"""Version = 2017-06-22 15:00"""
#---------------------------------------------------------------------
import GameWorld
import PlayerDBOper
import IPY_GameServer
import IpyGameDataPY
import CrossRealmMsg
@@ -52,36 +52,74 @@
    curPlayer.NotifyCode(msgMark, __GetNotifyCodeList(msgParamList))
    return
def NotifyCodeToClientServer(serverGroupIDList, playerID, msgMark, msgParamList=[]):
    dataMsg = {"Type":"Player", "ID":playerID, "Mark":msgMark, "Param":msgParamList}
    CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Notify, dataMsg, serverGroupIDList)
def CrossNotifyCode(serverGroupID, playerID, msgMark, msgParamList=[]):
    crossNotifyList = [{"Type":ShareDefine.CrossNotify_Player, "Params":[playerID, msgMark, msgParamList]}]
    CrossNotify([serverGroupID], crossNotifyList)
    return
def CrossServerMsg_Notify(notifyInfoDict):
    notifyType = notifyInfoDict["Type"]
    notifyID = notifyInfoDict["ID"]
    if notifyType == "Player":
        curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(notifyID)
        if not curPlayer:
            return
        NotifyCode(curPlayer, notifyInfoDict["Mark"], notifyInfoDict["Param"])
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
## 跨服世界广播
#  @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}
    #.SendBroadcastMerge(ChConfig.Def_MergeWorldNotify, 0, notifyDict, False)
def CrossNotifyEx(serverGroupIDList, crossNotifyList):
    ''' 跨服广播信息提示,支持同步多条,同时也建议多条一起同步
    @param serverGroupIDList: 需要同步到的目标服务器组ID列表
    @param crossNotifyList: 信息提示列表,[[notifyType, paramsList, 自定义扩展信息], ...]  notifyType 如 ShareDefine.CrossNotify_CrossAct
    '''
    CrossRealmMsg.SendMsgToClientServer(ShareDefine.CrossServerMsg_Notify, crossNotifyList, serverGroupIDList)
    return
def CrossServerMsg_Notify(crossNotifyList):
    GameWorld.DebugLog("收到跨服同步的广播提示内容: count=%s" % len(crossNotifyList))
    for notifyInfo in crossNotifyList:
        if isinstance(notifyInfo, dict):
            if "Type" not in notifyInfo or "Params" not in notifyInfo:
                continue
            notifyType = notifyInfo["Type"]
            params = notifyInfo["Params"]
        elif isinstance(notifyInfo, list) and len(notifyInfo) >= 2:
            notifyType, params = notifyInfo[:2]
        else:
            continue
        if notifyType == ShareDefine.CrossNotify_World:
            country, msgMark, msgParamList = params
            WorldNotify(country, msgMark, msgParamList)
        elif notifyType == ShareDefine.CrossNotify_CrossAct:
            country, msgMark, msgParamList = params
            serverIDRangeList = notifyInfo[2]
            playerManager = GameWorld.GetPlayerManager()
            for i in xrange(playerManager.GetPlayerCount()):
                curPlayer = playerManager.GetPlayerByIndex(i)
                if curPlayer == None or not curPlayer.GetInitOK() or GetIsTJG(curPlayer):
                    continue
                if not serverIDRangeList:
                    NotifyCode(curPlayer, msgMark, msgParamList)
                    return
                playerServerID = GameWorld.GetPlayerServerID(curPlayer)
                for serverIDA, serverIDB in serverIDRangeList:
                    if serverIDA <= playerServerID <= serverIDB:
                        NotifyCode(curPlayer, msgMark, msgParamList)
                        break
        elif notifyType == ShareDefine.CrossNotify_Family:
            familyID, msgMark, msgParamList = params
            FamilyNotify(familyID, msgMark, msgParamList)
        elif notifyType == ShareDefine.CrossNotify_Player:
            playerID, msgMark, msgParamList = params
            curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
            if curPlayer:
                NotifyCode(curPlayer, msgMark, msgParamList)
    return
    
## 世界广播
@@ -91,10 +129,7 @@
#  @return 无返回值
#  @remarks 
def WorldNotify(country, msgMark, msgParamList=[]):
    if GameWorld.IsCrossServer():
        MergeWorldNotify(country, msgMark, msgParamList)
    else:
        GameWorld.GetPlayerManager().CountryNotifyCode(country, msgMark, __GetNotifyCodeList(msgParamList))
    GameWorld.GetPlayerManager().CountryNotifyCode(country, msgMark, __GetNotifyCodeList(msgParamList))
    return
#---------------------------------------------------------------------
@@ -156,21 +191,6 @@
#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: 威望值
@@ -187,10 +207,16 @@
#------------------------------------------------------------------------------ 
## 协助目标玩家ID
def SetAssistTagPlayerID(curPlayer, value):
    curPlayer.SetExAttr1(value)
    SetMapServerPlayerAttrValue(curPlayer, "SetAssistTagPlayerID", value)
    return
def GetAssistTagPlayerID(curPlayer): return curPlayer.GetExAttr1()
## 职业阶数
def GetJobRank(curPlayer): return curPlayer.GetExAttr1()
def SetJobRank(curPlayer, jobRank): return curPlayer.SetExAttr1(jobRank)
## 副本功能线路ID
def SetFBFuncLineID(curPlayer, funcLineID): return curPlayer.SetExAttr3(funcLineID)
def GetFBFuncLineID(curPlayer): return curPlayer.GetExAttr3()
##VIP到期时间
def GetVIPExpireTime(curPlayer): return curPlayer.GetExAttr9()
@@ -216,10 +242,6 @@
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)
@@ -231,6 +253,7 @@
## 玩家所属服务器组ID
def GetPlayerServerGroupID(curPlayer): return curPlayer.GetExAttr13()
def SetPlayerServerGroupID(curPlayer, groupID): return curPlayer.SetExAttr13(groupID)
## 是否脱机挂机状态
def GetIsTJG(curPlayer):
@@ -252,23 +275,16 @@
def GetGMForbidenTalk(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_ForbiddenTalk)
def SetGMForbidenTalk(curPlayer, value): curPlayer.SetDict(ChConfig.Def_ForbiddenTalk, value)
# 玩家账号状态值
def SetPlayerAccState(curPlayer, accState):
    #curPlayer.SetAccState(accState)
    curPlayer.SetExAttr17(accState)
    #需要立即更新DB
    PlayerDBOper.UpdateDBOper(PlayerDBOper.Table_DBPlayer, {"PlayerID":curPlayer.GetPlayerID()}, {"AccState":accState, "ExAttr17":accState})
    return
#------------------------------------------------------------------------------ 
## 设置新手指导员天数
#  @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
@@ -296,14 +312,12 @@
    SetMapServerPlayerAttrValue(curPlayer, "SetVsRoomId", roomID)
    return
## 跨服状态: 0-非跨服状态,1-跨服状态
def GetCrossRealmState(curPlayer): return curPlayer.GetExAttr5()
def SetCrossRealmState(curPlayer, value):
    ''' 设置玩家跨服状态
    @param isExitCrossRealm: 非跨服状态时是否通知前端退出跨服服务器
    '''
## 跨服状态所在地图ID: 0-非跨服状态,非0-跨服状态对应的地图ID
def GetCrossMapID(curPlayer): return curPlayer.GetExAttr5()
def SetCrossMapID(curPlayer, value, isNotifyMapServer=True):
    curPlayer.SetExAttr5(value)
    SetMapServerPlayerAttrValue(curPlayer, "SetExAttr5", value)
    if isNotifyMapServer:
        SetMapServerPlayerAttrValue(curPlayer, "SetExAttr5", value)
    return
def SetMapServerPlayerAttrValue(curPlayer, attrName, value, exData=[]):