hxp
2018-11-25 ae8e857873ba53e55392ab06237cd7b16426d93e
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/ChPlayer.py
@@ -62,9 +62,9 @@
import PlayerActivity
import PlayerTeHui
import FBCommon
import HighLadderTube
import PlayerBindJadeWheel
import BossHurtMng
import PlayerAction
import PlayerWishingWell
import PlayerAttrFruit
import PlayerSuccess
import PlayerDienstgrad
@@ -72,10 +72,10 @@
import PlayerFreeGoods
import ShopItemManage
import PlayerRecover
import Operate_EquipSuitCompose
import GameLogic_IceLode
import PlayerEquipDecompose
import PlayerCoat
import PlayerQQ
import PlayerGreatMaster
import PlayerCostVIP
import PlayerMergeKing
import PlayerMergePK
@@ -102,11 +102,14 @@
import PlayerTJG
import GameLogic_XMZZ
import GameLogic_SealDemon
import PlayerFlashSale
import PlayerFlashGiftbag
import PlayerCostRebate
import PlayerActTotalRecharge
import PlayerSpringSale
import PlayerFairyCeremony
import ChNetSendPack
import FamilyRobBoss
import PyGameData
import PlayerCoin
import PlayerGeTui
@@ -236,6 +239,7 @@
    curPlayer.SetDict(ChConfig.Def_PlayerKey_LoadMapIsLogin, 1)
    #通知时间
    Sync_PyServerDataTimeToClient(curPlayer)
    Sync_OpenServerDay(curPlayer)
    #通知玩家基本信息
    curPlayer.Sync_ClientPlayerLogin()
    
@@ -325,7 +329,7 @@
    Operate_EquipStone.OnLogin(curPlayer)
    
    #大师
    #PlayerGreatMaster.MasterOnLogin(curPlayer)
    PlayerGreatMaster.MasterOnLogin(curPlayer)
    
    #֪ͨVIP
    PlayerVip.DoOnLogin(curPlayer, tick)
@@ -427,7 +431,7 @@
    # 古神禁地
    GameLogic_GodArea.GodAreaOnLogin(curPlayer)
#    # 采集NPC次数通知
#    NPCCommon.SyncCollNPCTime(curPlayer)
    NPCCommon.SyncCollNPCTime(curPlayer)
#        
#    # 特惠活动
#    PlayerTeHui.PlayerLogin_TeHui(curPlayer)
@@ -484,11 +488,14 @@
    
    #消费返利
    PlayerCostRebate.OnPlayerLogin(curPlayer)
    #累计充值
    PlayerActTotalRecharge.OnPlayerLogin(curPlayer)
    #限时特惠
    PlayerSpringSale.OnPlayerLogin(curPlayer)
    #限时礼包
    PlayerFlashGiftbag.OnPlayerLogin(curPlayer)
    #限时抢购
    PlayerFlashSale.OnPlayerLogin(curPlayer)
#    # 消费VIP
#    PlayerCostVIP.CostVIPOnLogin(curPlayer, tick)
#    
@@ -517,7 +524,6 @@
    #仙魔之争
    GameLogic_XMZZ.OnXMZZLogin(curPlayer)
    PlayerOnlinePrize.OnPlayerLogin(curPlayer)
    GameLogic_SealDemon.NotifyFMTDouble(curPlayer)
    #装备分解
    PlayerEquipDecompose.PlayerLogin(curPlayer)
    #防沉迷
@@ -538,15 +544,28 @@
    GameFuncComm.DoFuncOpenLogic(curPlayer)
    # 神兽
    PlayerDogz.OnPlayerLogin(curPlayer)
    # 骑宠
    FamilyRobBoss.OnPlayerLogin(curPlayer)
    # 绑玉转盘
    PlayerBindJadeWheel.OnLogin(curPlayer)
    # 许愿池
    PlayerWishingWell.OnLogin(curPlayer)
    # 上线查询一次充值订单
    curPlayer.SendDBQueryRecharge()
    # 小助手
    SyncLittleHelper(curPlayer)
    # 聊天气泡框
    SyncChatBubbleBoxState(curPlayer)
    
    curPlayer.SetState(0)   # 脱机挂恢复为正常上线
    curPlayer.SetFacePic(0) # 通知数据库是否保存还是下线,做一次恢复,1为保存 0为正常下线
    tjgTime = PlayerTJG.GetTJGTime(curPlayer)
    if tjgTime:
        curPlayer.SendGameServerRefreshState(IPY_GameWorld.CDBPlayerRefresh_HappyPoint, tjgTime)
    # 如果被禁言的,上线同步前端
    if curPlayer.GetGMForbidenTalk():
        curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_ForbidenTalk, curPlayer.GetGMForbidenTalk(), False)
    return
@@ -667,8 +686,21 @@
    itemManager = curPlayer.GetItemManager()
    
    for packIndex in ChConfig.Def_PlayerLoginInitPackIndexList:
        itemManager.GetPack(packIndex).Sync_Refresh()
        rolePack = itemManager.GetPack(packIndex)
        rolePack.Sync_Refresh()
        # 刷下装备评分,仓库可以暂不处理,取出装备后登录触发刷新
        for i in xrange(rolePack.GetCount()):
            curItem = rolePack.GetAt(i)
            if curItem.IsEmpty():
                continue
            newScore = ItemCommon.CalcEquipGS(curItem)
            hisScore = ItemCommon.GetEquipGearScore(curItem)
            if hisScore != newScore:
                ItemCommon.SetEquipGearScore(curItem, newScore)
                GameWorld.Log("登录更新装备评分: packType=%s,i=%s,hisScore=%s,newScore=%s,itemID=%s,guid=%s"
                              % (packIndex, i, hisScore, newScore, curItem.GetItemTypeID(), curItem.GetGUID()), curPlayer.GetPlayerID())
    for packIndex in ChConfig.Def_VPackCnt_Dict.keys():
        ItemControler.Sync_VPackItem_Refresh(curPlayer, packIndex)
        
@@ -910,14 +942,23 @@
    #这里只做初始化逻辑
    #在玩家切换场景的时候, 不会调用到这里
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    InitLoginPlayer(curPlayer, tick)
    DoPlayerLogin(curPlayer, tick)
    try:
        InitLoginPlayer(curPlayer, tick)
        DoPlayerLogin(curPlayer, tick)
        #锁住玩家, 等到读取地图成功, 再解锁
        curPlayer.SetCanMove(False)
        #登陆发图形验证码
        PlayerAutoCheckOnline.PlayerLoginCaptcha(curPlayer, tick)
    except:
        curPlayer.Kick(IPY_GameWorld.disWaitForPlayerLoinError)
        import traceback
        GameWorld.ErrLog("玩家上线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
        if GameWorld.GetGameWorld().GetDebugLevel():
            raise Exception("玩家上线逻辑错误~~~~\r\n%s" % traceback.format_exc())
    return
    
    #锁住玩家, 等到读取地图成功, 再解锁
    curPlayer.SetCanMove(False)
    #登陆发图形验证码
    PlayerAutoCheckOnline.PlayerLoginCaptcha(curPlayer, tick)
    
#---------------------------------------------------------------------
##C++封包触发, 玩家切换地图的时候, 在本地图登录
@@ -1842,6 +1883,7 @@
    curMap = GameWorld.GetMap()
    #校验客户端时间
    if not PlayerControl.PlayerMoveCheckClientWorldTick(curPlayer, clientWorldTick, client_StartX, client_StartY):
        curPlayer.Sync_ClientTick()
        return
    
    #移动点检查
@@ -2404,7 +2446,7 @@
        import traceback
        GameWorld.ErrLog("玩家下线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
        if GameWorld.GetGameWorld().GetDebugLevel():
            raise Exception("玩家下线~~~~~\r\n%s" % traceback.format_exc())
            raise Exception("玩家下线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
        
    #调用底层使玩家下线
    curPlayer.DoDisconnect(tick)
@@ -2502,6 +2544,113 @@
        return
    
    curPlayer.SetSetting(setting)
    return
#// A2 30 设置聊天气泡框 #tagCMSetChatBubbleBox
#
#struct    tagCMSetChatBubbleBox
#{
#    tagHead         Head;
#    BYTE        BubbleBoxType;    //气泡框类型
#};
def OnSetChatBubbleBox(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    useBoxID = clientData.BubbleBoxType
    GameWorld.DebugLog("设置使用的聊天气泡框ID: useBoxID=%s" % useBoxID, curPlayer.GetPlayerID())
    ipyData = IpyGameDataPY.GetIpyGameData("ChatBubbleBox", useBoxID)
    if not ipyData:
        return
    curBoxState = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_ChatBubbleBoxState, useBoxID)
    if not curBoxState:
        needLV = ipyData.GetNeedLV()
        if needLV and curPlayer.GetLV() < needLV:
            GameWorld.DebugLog("    等级不足,无法使用该气泡框!needLV=%s" % needLV, curPlayer.GetPlayerID())
            return
        needVIPLVGift = ipyData.GetNeedVIPLVGift() # 兼容已购买VIP礼包的老号用
        if needVIPLVGift:
            record = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_VipAwardRecord)
            hasBuy = record & pow(2, needVIPLVGift)
            if not hasBuy:
                GameWorld.DebugLog("    未购买VIP礼包,无法使用该气泡框!needVIPLVGift=%s" % needVIPLVGift, curPlayer.GetPlayerID())
                return
    PlayerControl.SetChatBubbleBox(curPlayer, useBoxID)
    return
def DoActivateChatBubbleBox(curPlayer, boxID):
    ## 激活聊天气泡框
    ipyData = IpyGameDataPY.GetIpyGameData("ChatBubbleBox", boxID)
    if not ipyData:
        return
    GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_ChatBubbleBoxState, boxID, 1)
    SyncChatBubbleBoxState(curPlayer)
    return True
def SyncChatBubbleBoxState(curPlayer):
    ## 同步聊天气泡框状态
    boxState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ChatBubbleBoxState % 0)
    if not boxState:
        return
    boxStatePack = ChPyNetSendPack.tagMCChatBubbleBoxState()
    boxStatePack.BoxState = boxState
    NetPackCommon.SendFakePack(curPlayer, boxStatePack)
    return
#// A2 29 设置小助手 #tagCMSetLittleHelper
#
#struct    tagCMSetLittleHelper
#{
#    tagHead         Head;
#    BYTE        SetNum;    // 托管功能设置编号1~20,每个编号对应的托管功能前端自定义
#    DWORD        Value1;    // 自定义值1
#    DWORD        Value2;    // 自定义值2
#    DWORD        Value3;    // 自定义值3
#    DWORD        Value4;    // 自定义值4
#    DWORD        Value5;    // 自定义值5
#    DWORD        Value6;    // 自定义值6
#};
def OnSetLittleHelper(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    setNum = clientData.SetNum
    if setNum > ChConfig.LittleHelperSetNumCount:
        GameWorld.ErrLog("小助手不支持该设置编号! setNum=%s" % setNum, curPlayer.GetPlayerID())
        return
    for i in xrange(1, ChConfig.LittleHelperValueCount + 1):
        if not hasattr(clientData, "Value%s" % i):
            GameWorld.ErrLog("小助手不支持该值编号设置! setNum=%s,value%s" % (setNum, i), curPlayer.GetPlayerID())
            continue
        value = getattr(clientData, "Value%s" % i)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_LittleHelperValue % (setNum, i), value)
        GameWorld.DebugLog("小助手值设置: setNum=%s,value%s=%s" % (setNum, i, value), curPlayer.GetPlayerID())
    return
def SyncLittleHelper(curPlayer):
    ## 同步小助手设置,仅有值的同步
    funcSetList = []
    for setNum in xrange(ChConfig.LittleHelperSetNumCount + 1):
        funcSet = None
        for i in xrange(1, ChConfig.LittleHelperValueCount + 1):
            value = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_LittleHelperValue % (setNum, i))
            if not value:
                continue
            if not funcSet:
                funcSet = ChPyNetSendPack.tagMCLittleHelperFuncSet()
                funcSet.SetNum = setNum
            if hasattr(funcSet, "Value%s" % i):
                setattr(funcSet, "Value%s" % i, value)
        if funcSet:
            funcSetList.append(funcSet)
    if not funcSetList:
        return
    setPack = ChPyNetSendPack.tagMCLittleHelperSet()
    setPack.FuncSetList = funcSetList
    setPack.FuncSetCount = len(setPack.FuncSetList)
    NetPackCommon.SendFakePack(curPlayer, setPack)
    return
#// A2 22 设置引导成功 #tagCMSetGuideOK
@@ -3432,7 +3581,7 @@
#@return 返回值无意义
#@remarks 客户端封包响应 //03 10 退出副本#tagCExitFB
def __Func_ExitFB(curPlayer, tick):
    if GameWorld.GetMap().GetMapFBType() == IPY_GameWorld.fbtNull:
    if GameWorld.GetMap().GetMapFBType() == IPY_GameWorld.fbtNull and curPlayer.GetMapID() not in IpyGameDataPY.GetFuncEvalCfg("MapLine", 4):
        return
    
    GameWorld.Log('玩家 = %s , 主动离开副本' % (curPlayer.GetName()) , curPlayer.GetID())
@@ -3475,8 +3624,14 @@
        return
    
    mapID = curPlayer.GetMapID()
    activityLineID = 0 # 活动线, 默认1线
    activityMapLineDict = IpyGameDataPY.GetFuncEvalCfg("MapLine", 2, {})
    if mapID in activityMapLineDict:
        activityLineID = max(0, activityMapLineDict[mapID] - 1)
    mapLineDict = IpyGameDataPY.GetFuncEvalCfg("MapLine", 1)
    if mapID in mapLineDict and changLineID >= mapLineDict[mapID]:
    if changLineID != activityLineID and mapID in mapLineDict and changLineID >= mapLineDict[mapID]:
        GameWorld.ErrLog("该地图没有开放此线路,无法手动切换!mapID=%s,changLineID=%s,maxLine=%s" 
                         % (mapID, changLineID, mapLineDict[mapID]), curPlayer.GetID())
        return
@@ -3659,6 +3814,7 @@
    rebornTime = GetRebronTime(curPlayer, playerRebornType)    
    #冷却时间到了
    if not CanRebornByTimeOver(curPlayer, rebornTime):
        PlayerControl.NotifyCode(curPlayer, 'RebornCD')
        return False
    
    isFBReborn = False
@@ -4371,16 +4527,6 @@
        PlayerControl.NotifyCode(curPlayer, "04BBF813-7A30-47A8-927DE1ACCC4F378E")
        return
#===============================================================================
#    isFreedomTransBuff = SkillCommon.GetPlayerBuffBySkillTypeID(curPlayer, ShareDefine.Def_FreedomTransBuffID)
#    if not PlayerControl.IsPlayerInFight(curPlayer):
#
#        if (transportType == ChConfig.Def_Transport_Type_BigMap) or (not isFreedomTransBuff):
#            #传送支付处理
#
#            if not PayForTransport(curPlayer, transportType, isAutoBuy):
#                return
#===============================================================================
    #是任务传送,VIP等级不够,且传送符不足,不处理
    if transportType == ChConfig.Def_Transport_Type_Mission and \
       not TransportVipLvRestrict(curPlayer, transportType) and \
@@ -4482,12 +4628,6 @@
#  @param transportType 传送类型
#  @return 是否vip等级限制
def TransportVipLvRestrict(curPlayer, transportType):
    #大地图标记传送不能体验无限飞buff功能
    if transportType != ChConfig.Def_Transport_Type_BigMap:
        if SkillCommon.GetPlayerBuffBySkillTypeID(curPlayer, ShareDefine.Def_FreedomTransBuffID):
            #有无限飞buff
            return True
    return PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_FreeTransport)
@@ -4965,6 +5105,9 @@
    # 领取消费返利奖励
    elif rewardType == ChConfig.Def_RewardType_CostRebate:
        PlayerCostRebate.OnGetCostRebateAward(curPlayer, dataEx)
    # 领取累计充值奖励
    elif rewardType == ChConfig.Def_RewardType_TotalRecharge:
        PlayerActTotalRecharge.OnGetTotalRechargeAward(curPlayer, dataEx)
    # 领取boss复活活动奖励
    elif rewardType == ChConfig.Def_RewardType_BossReborn:
        PlayerBossReborn.GetBossRebornActionAward(curPlayer, dataEx)
@@ -4977,6 +5120,16 @@
    # 领取分包下载奖励
    elif rewardType == ChConfig.Def_RewardType_DownLoad:
        GetDownloadAward(curPlayer, dataEx)
    # 领取许愿池奖励
    elif rewardType == ChConfig.Def_RewardType_WishingWell:
        PlayerWishingWell.DoGetWishingAward(curPlayer)
    # 功能开启奖励
    elif rewardType == ChConfig.Def_RewardType_OpenFunc:
        GameFuncComm.GetFuncOpenAward(curPlayer, dataEx)
    # 冰晶矿脉星级奖励
    elif rewardType == ChConfig.Def_RewardType_IceLodeStar:
        GameLogic_IceLode.GetIceLodeStarAward(curPlayer, dataEx)
#
#    # 充值豪礼奖励
#    elif rewardType == ShareDefine.Def_RewardType_GoldGift:
@@ -5217,6 +5370,56 @@
    return
## 地图NPC数量查询封包 A2 27 查询地图NPC数量信息 #tagCMQueryNPCCntInfo
#  @param curPlayer
#  @return None
def OnQueryMapNPCCntInfo(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    if not curPlayer:
        return
    # 查询间隔控制
    if not clientData.IsNoTimeLimit:
        if not GameWorld.CheckPlayerTick(curPlayer, ChConfig.TYPE_Player_Tick_QueryMapNPCInfo, tick):
            GameWorld.DebugLog("OnQueryMapNPCCntInfo 查询过于频繁!")
            return
    tagMapID = clientData.MapID
    tagLineID = clientData.LineID
    queryNPCStr = clientData.NPCIDList
    npcIDList = []
    if queryNPCStr:
        try:
            npcIDList = eval(clientData.NPCIDList)
        except BaseException:
            GameWorld.ErrLog("OnQueryMapNPCCntInfo, npcIDList=%s" % clientData.NPCIDList)
            return
        if not isinstance(npcIDList, list):
            GameWorld.ErrLog("OnQueryMapNPCCntInfo, npcIDList=%s is not list!" % str(npcIDList))
            return
    GameWorld.DebugLog("OnQueryMapNPCCntInfo tagMapID=%s,tagLineID=%s,npcIDList=%s"
                       % (tagMapID, tagLineID, str(npcIDList)))
    curMapID = GameWorld.GetMap().GetMapID()
    # 如果是同张地图,直接查询通知
    if curMapID == tagMapID:
        npcInfoDict = NPCCommon.GetNPCCntInfo(npcIDList, tick)
        GameWorld.DebugLog("    同地图查询curMapID=%s,tagLineID=%s,npcInfoDict=%s"
                           % (curMapID, tagLineID, str(npcInfoDict)))
        NPCCommon.SyncNPCCntInfo(curPlayer, tagMapID, npcInfoDict)
    else:
        # 请求GameServer目标地图NPC信息
        sendMsg = "%s" % str([tagMapID, tagLineID, npcIDList])
        curPlayer.GameServer_QueryPlayerByID(ChConfig.queryType_NPCCnt, 0,
                                 'NPCCnt', sendMsg, len(sendMsg))
    return
## 跨服赛报名状态
#  @param index 玩家索引
#  @param tick 当前时间
@@ -5261,6 +5464,29 @@
    NetPackCommon.SendFakePack(curPlayer, serverDateTime)
    return
## 通知开服天数
#  @param curPlayer: 玩家实例
#  @return: None
def Sync_OpenServerDay(curPlayer):
    serverTime = GameWorld.GetCurrentTime()
    if not serverTime:
        return
    gw = GameWorld.GetGameWorld()
    packData = ChPyNetSendPack.tagOpenServerDay()
    packData.Clear()
    packData.Day = gw.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay)
    packData.IsMixServer = gw.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_IsMixServer)
    packData.MixDay = gw.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_MixServerDay)
    packData.OpenWeekday = gw.GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_OpenServerWeekday)
    packData.NowYear = serverTime.year
    packData.NowMonth = serverTime.month
    packData.NowDay = serverTime.day
    packData.NowHour = serverTime.hour
    packData.NowMinute = serverTime.minute
    packData.NowSecond = serverTime.second
    packData.NowMicSecond = serverTime.microsecond
    NetPackCommon.SendFakePack(curPlayer, packData)
    return
#===============================================================================
# //B4 09 玩家移动 # tagCMPyMove
@@ -5354,6 +5580,7 @@
    #校验客户端时间
    if not PlayerControl.PlayerMoveCheckClientWorldTick(curPlayer, sendPack_WorldTick, sendPack_SeverPosX, sendPack_SeverPosY):
        curPlayer.Sync_ClientTick()
        return False
    dist = GameWorld.GetDist(curPlayer.GetPosX(), curPlayer.GetPosY(), sendPack_SeverPosX, sendPack_SeverPosY)
@@ -5454,4 +5681,17 @@
    sendPack.Clear()
    sendPack.Record = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DownloadAwardState)
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    return
    return
def NotifyPlayerMove(curPlayer, posX, posY, npcID=0):
    '''通知前端向某个点移动
                这里前端可能需要针对某次移动做额外处理,比如移动到某个点后需要自动战斗等
                所以这里只做通知前端可以向某个点移动,最终移动由前端发起
    '''
    sendPack = ChPyNetSendPack.tagMCNotifyPlayerMove()
    sendPack.Clear()
    sendPack.PosX = posX
    sendPack.PosY = posY
    sendPack.NPCID = npcID
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    return