ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGreatMaster.py
@@ -6,82 +6,51 @@
#
##@package Player.PlayerGreatMaster
#
# @todo:大师系统
# @author hxp
# @date 2015-2-27
# @version 1.8
# @todo:天赋系统
# @author xdh
# @date 2018-9-26
# @version 1.0
#
# @change: "2015-03-05 11:00" hxp 根据大师等级获取大师所需升级经验
# @change: "2015-03-07 00:00" hxp 天赋buff刷属性时机修改
# @change: "2015-03-07 04:10" ljd 保存成功系统提示
# @change: "2015-05-28 14:00" hxp 刷属性优化
# @change: "2015-07-29 15:20" xdh 大师改成等级开启
# @change: "2015-08-24 14:40" zqx 增加分配x点天赋点成就
# @change: "2016-01-26 15:00" hxp PY表支持重读
# @change: "2016-06-02 20:00" hxp 功能开放逻辑修改
#
# 详细描述: 大师系统
# 详细描述: 天赋系统
#
#---------------------------------------------------------------------
#"""Version = 2016-06-02 20:00"""
#"""Version = 2018-9-26 20:00"""
import GameWorld
import PyMapTable
import PlayerControl
import IPY_GameWorld
import PlayerBillboard
import ChPyNetSendPack
import DataRecordPack
import NetPackCommon
import ReadChConfig
import SkillCommon
import ShareDefine
import SkillShell
import BuffSkill
import ChConfig
import PlayerSuccess
import GameFuncComm
import IpyGameDataPY
import ItemCommon
import PassiveBuffEffMng
## 大师功能是否开启
#  @param curPlayer
#  @return
def IsGreatMasterOpen(curPlayer):
#    curReinCnt = curPlayer.GetReincarnationLv() # 当前转生次数
#    if curReinCnt < 3:
#        return False
    if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_GreatMaster):
    if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Talent):
        return False
    return True
## 增加大师天赋点
#  @param curPlayer
#  @return
def AddGreatMasterSkillPointByLV(curPlayer, addPoint):
    if not addPoint:
        return
def DoTalentOpen(curPlayer):
    '''天赋功能开启处理天赋点 '''
    curLV = curPlayer.GetLV()
    openLV = GameFuncComm.GetFuncLimitLV(ShareDefine.GameFuncID_Talent)
    setTalentPoint = 0
    for lv in xrange(openLV, curLV+1):
        lvIpyData = PlayerControl.GetPlayerLVIpyData(lv)
        addTalentPoint = lvIpyData.GetTalentPoint() if lvIpyData else 0
        setTalentPoint += addTalentPoint
    curFreeSkillPoint = GetGreatMasterFreeSkillPoint(curPlayer)
    #GameWorld.DebugLog("大师天赋点!curFreeSkillPoint = %s"%curFreeSkillPoint)
    SetGreatMasterFreeSkillPoint(curPlayer, curFreeSkillPoint + addPoint)
    Sync_GreatMasterFreeSkillPoint(curPlayer)
    return
## 转生处理
#  @param curPlayer
#  @return
def OnReincarnation(curPlayer):
    #如果是满级的,则多余经验转移到大师经验
    isFullLV = curPlayer.GetLVEx() >= IpyGameDataPY.GetFuncCfg("PlayerMaxLV") # 玩家已满级
    if not isFullLV:
        return
    curTotalExp = PlayerControl.GetPlayerTotalExp(curPlayer) # 当前经验
    PlayerControl.SetPlayerTotalExp(curPlayer, 0)
    AddGreatMasterExp(curPlayer, curTotalExp)
    if setTalentPoint != curFreeSkillPoint:
        SetGreatMasterFreeSkillPoint(curPlayer, setTalentPoint)
        Sync_GreatMasterFreeSkillPoint(curPlayer)
        GameWorld.Log('    天赋功能开启处理天赋点 beforeTalentPoint=%s,setTalentPoint=%s, curLV=%s'%(curFreeSkillPoint, setTalentPoint, curLV), curPlayer.GetID())
    return
## 登录处理
@@ -91,47 +60,22 @@
    if not IsGreatMasterOpen(curPlayer):
        return
    
    Sync_GreatMasterExp(curPlayer)
    Sync_GreatMasterFreeSkillPoint(curPlayer)
    return
## 获取当前大师经验(不算经验点的)
def GetCurGreatMasterExp(curPlayer):
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Master_Exp, 0, ChConfig.Def_PDictType_GreatMaster)
## 设置当前大师经验(不算经验点的)
def SetCurGreatMasterExp(curPlayer, value):
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Master_Exp, value, ChConfig.Def_PDictType_GreatMaster)
## 增加大师天赋点
#  @param curPlayer
#  @return
def AddGreatMasterSkillPointByLV(curPlayer, addPoint):
    if not addPoint:
        return
    curFreeSkillPoint = GetGreatMasterFreeSkillPoint(curPlayer)
    GameWorld.DebugLog("大师天赋点!curFreeSkillPoint = %s"%curFreeSkillPoint)
    SetGreatMasterFreeSkillPoint(curPlayer, curFreeSkillPoint + addPoint)
    Sync_GreatMasterFreeSkillPoint(curPlayer)
    return
## 获取当前大师经验点
def GetGreatMasterExpPoint(curPlayer):
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Master_ExpPoint, 0, ChConfig.Def_PDictType_GreatMaster)
## 设置当前大师经验点
def SetGreatMasterExpPoint(curPlayer, value):
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Master_ExpPoint, value, ChConfig.Def_PDictType_GreatMaster)
    return
## 获取当前大师总经验(包含经验点)
def GetTotalGreatMasterExp(curPlayer):
    masterExp = GetCurGreatMasterExp(curPlayer)
    masterExpPoint = GetGreatMasterExpPoint(curPlayer)
    totalMasterExp = masterExpPoint * ChConfig.Def_PerPointValue + masterExp
    return totalMasterExp
## 设置当前大师总经验(包含经验点)
def SetTotalGreatMasterExp(curPlayer, totalExp):
    curExp = totalExp % ChConfig.Def_PerPointValue
    expPoint = totalExp / ChConfig.Def_PerPointValue
    # 更新大师经验、经验点
    SetCurGreatMasterExp(curPlayer, curExp)
    SetGreatMasterExpPoint(curPlayer, expPoint)
    #GameWorld.DebugLog("SetTotalGreatMasterExp totalExp=%s,expPoint=%s,curExp=%s"
    #                   % (totalExp, expPoint, curExp), curPlayer.GetPlayerID())
    Sync_GreatMasterExp(curPlayer)
    return
## 获取当前剩余大师技能点
def GetGreatMasterFreeSkillPoint(curPlayer):
@@ -142,161 +86,12 @@
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Master_FreeSkillPoint, value, ChConfig.Def_PDictType_GreatMaster)
    return
## 根据大师等级获取升级所需经验
#  @param masterLV: 大师等级
#  @return: -1-已满级; >=0升级所需经验
def GetTotalExpByGreatMasterLV(masterLV):
    masterExpTable = PyMapTable.GetPyMapTable("GreatMasterExp")
    maxMasterLV = masterExpTable.GetRecordCount() - 1
    if masterLV >= maxMasterLV:
        return -1
    expInfoList = masterExpTable.GetRecordByIndex(masterLV)
    totalExp = int(expInfoList["Exp"])
    return totalExp
## 增加大师等级经验
#  @param curPlayer
#  @param addExp
#  @return 是否成功
def AddGreatMasterExp(curPlayer, addExp):
    # 取消大师等级
    return
    if not IsGreatMasterOpen(curPlayer):
        return False
    #取得人物当前经验
    playerID = curPlayer.GetPlayerID()
    masterLV = curPlayer.GetLV2() # 大师等级, 从0级开始
    masterExpTable = PyMapTable.GetPyMapTable("GreatMasterExp")
    maxMasterLV = masterExpTable.GetRecordCount() - 1
    #GameWorld.DebugLog("增加大师等级经验 addExp=%s,masterLV=%s,maxMasterLV=%s"
    #                   % (addExp, masterLV, maxMasterLV), playerID)
    if masterLV >= maxMasterLV:
        PlayerControl.NotifyCode(curPlayer, "GeRen_admin_825676")
        GameWorld.DebugLog("大师等级已满级!", playerID)
        return False
    curTotalMasterExp = GetTotalGreatMasterExp(curPlayer) + addExp
    # 先加再处理升级
    SetTotalGreatMasterExp(curPlayer, curTotalMasterExp)
    expInfoList = masterExpTable.GetRecordByIndex(masterLV)
    needExp = int(expInfoList["Exp"])
    if needExp <= 0:
        GameWorld.ErrLog("大师升级所需经验配置错误!masterLV=%s,needExp=%s" % (masterLV, needExp), playerID)
        return True
    #GameWorld.DebugLog("    expInfoList=%s,needExp=%s,curTotalMasterExp=%s"
    #                   % (str(expInfoList), needExp, curTotalMasterExp), playerID)
    isLVUP = False
    while curTotalMasterExp >= needExp:
        isLVUP = True
        masterLV += 1
        curPlayer.SetLV2(masterLV)
        curTotalMasterExp -= needExp
        #GameWorld.DebugLog("    大师等级升级needExp=%s,nextMasterLV=%s,curTotalMasterExp=%s"
        #                   % (needExp, masterLV, curTotalMasterExp), playerID)
        # 给大师天赋点
        addSkillPoint = int(expInfoList["AddSkillPoint"])
        curFreeSkillPoint = GetGreatMasterFreeSkillPoint(curPlayer)
        SetGreatMasterFreeSkillPoint(curPlayer, curFreeSkillPoint + addSkillPoint)
        # 升级流向
        DataRecordPack.DR_PlayerMasterLVChange(curPlayer, curTotalMasterExp)
        # 循环升级
        if masterLV >= maxMasterLV:
            GameWorld.DebugLog("    循环升级大师等级已满级!", playerID)
            break
        expInfoList = masterExpTable.GetRecordByIndex(masterLV)
        needExp = int(expInfoList["Exp"])
        if needExp <= 0:
            GameWorld.DebugLog("    循环升级下一级经验为0!masterLV=%s" % masterLV, playerID)
            break
    # 升级处理
    if isLVUP:
        #GameWorld.DebugLog("    大师升级处理!", playerID)
        PlayerBillboard.UpdatePlayerLVBillboard(curPlayer)
        #重刷所有属性
        PlayerControl.PlayerControl(curPlayer).RefreshAllState()
        #将血设置为最大
        curPlayer.SetHP(curPlayer.GetMaxHP())
        curPlayer.SetMP(curPlayer.GetMaxMP())
        Sync_GreatMasterFreeSkillPoint(curPlayer)
        # 更新剩余总经验
        SetTotalGreatMasterExp(curPlayer, curTotalMasterExp)
    return True
## 同步大师经验
#  @param curPlayer
#  @return
def Sync_GreatMasterExp(curPlayer):
    masterExpPack = ChPyNetSendPack.tagMCGreatMasterExp()
    masterExpPack.Clear()
    masterExpPack.MasterExpPoint = GetGreatMasterExpPoint(curPlayer)
    masterExpPack.CurMasterEXP = GetCurGreatMasterExp(curPlayer)
    NetPackCommon.SendFakePack(curPlayer, masterExpPack)
    return
## 同步大师剩余天赋点
#  @param curPlayer
#  @return 
def Sync_GreatMasterFreeSkillPoint(curPlayer):
    #PlayerControl.NotifyPlayerDictValue(curPlayer, ChConfig.Def_PDict_Master_FreeSkillPoint)
    return
#// A5 48 兑换大师等级经验 #tagCMExchangeMasterEXP
#
#struct    tagCMExchangeMasterEXP
#{
#    tagHead        Head;
#    BYTE        Multiples;        // 20亿经验倍数
#    DWORD        ExtraExp;    // 额外附加经验(不超过20亿)
#};
## 兑换大师经验
#  @param index: 玩家索引
#  @param clientData: 封包结构体
#  @param tick: 时间戳
#  @return: None
def OnExchangeMasterExp(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    if not IsGreatMasterOpen(curPlayer):
        GameWorld.ErrLog("大师功能未开启!不能兑换大师等级经验!", curPlayer.GetPlayerID())
        return
    exchangeExp = clientData.Multiples * ChConfig.Def_PerPointValue + clientData.ExtraExp
    curTotalExp = PlayerControl.GetPlayerTotalExp(curPlayer) # 当前经验
    actualExchangeExp = min(curTotalExp, exchangeExp)
    GameWorld.DebugLog("兑换大师等级经验ExchangeExp=%s" % actualExchangeExp, curPlayer.GetPlayerID())
    if actualExchangeExp <= 0:
        return
    updTotalExp = curTotalExp - actualExchangeExp
    PlayerControl.SetPlayerTotalExp(curPlayer, updTotalExp)
    AddGreatMasterExp(curPlayer, actualExchangeExp)
    curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_TalentPoint, GetGreatMasterFreeSkillPoint(curPlayer), False)
    return
@@ -321,172 +116,173 @@
#  @param tick: 时间戳
#  @return: None
def OnAddMasterSkillPoint(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    needAddSkillPointList = clientData.AddSkillPointList
    if not needAddSkillPointList:
        return
    reqTotalPointSkillDict = ReadChConfig.GetEvalChConfig("ReqTotalPointSkill")
    greatMasterSkillDict = ReadChConfig.GetEvalChConfig("GreatMasterSkill")
    jobType = ChConfig.JOB_TYPE_DICT[curPlayer.GetJob()]
    if jobType not in greatMasterSkillDict:
        return
    jobMasterSkillDict = greatMasterSkillDict[jobType] # 本职业天赋系对应技能
    reqTotalPointSkillList = reqTotalPointSkillDict.get(jobType, []) # 本职业需求总天赋点技能
    skillTypeSeriesDict = {} # 技能对应天赋系
    skillTypeLVDict = {} # 技能对应等级
    seriesTotalPointDict = {} # 天赋系对应总技能点
    allSeriesTotalPoint = 0 # 所有天赋系总点数
    # 汇总天赋技能所属天赋系
    for seriesType, skillTypeIDList in jobMasterSkillDict.items():
        for sTypeID in skillTypeIDList:
            skillTypeSeriesDict[sTypeID] = seriesType
    skillManager = curPlayer.GetSkillManager()
    # 获取玩家目前所有技能
    for i in range(skillManager.GetSkillCount()):
        playerSkill = skillManager.GetSkillByIndex(i)
        if playerSkill == None:
            continue
        playerSkillTypeID = playerSkill.GetSkillTypeID()
        for seriesType, skillTypeIDList in jobMasterSkillDict.items():
            if playerSkillTypeID not in skillTypeIDList:
                continue
            skillLV = playerSkill.GetSkillLV()
            skillTypeLVDict[playerSkillTypeID] = skillLV
            seriesTotalPointDict[seriesType] = seriesTotalPointDict.get(seriesType, 0) + skillLV
            allSeriesTotalPoint += skillLV
            break
    isAddSkill = True
    isRefreshAttr = False
    buffType = IPY_GameWorld.btPassiveBuf
    addPointDict = {} # 请求加点技能已执行加点数
    GameWorld.DebugLog("【天赋加点】jobType=%s,技能对应等级=%s,天赋系对应总技能点=%s,总点数=%s"
                       % (jobType, skillTypeLVDict, seriesTotalPointDict, allSeriesTotalPoint))
    while isAddSkill:
        # 每次循环重置状态,直到无法再加技能才跳出
        isAddSkill = False
        for addSkill in needAddSkillPointList:
            skillTypeID = addSkill.SkillID
            totalAddPoint = addSkill.AddPoint
            freeSkillPoint = GetGreatMasterFreeSkillPoint(curPlayer)
            if freeSkillPoint <= 0:
                GameWorld.DebugLog("    当前无剩余天赋点!")
                break
            if skillTypeID not in skillTypeSeriesDict:
                GameWorld.ErrLog("技能不在合法天赋系里!skillTypeID=%s" % skillTypeID)
                continue
            curSeriesType = skillTypeSeriesDict[skillTypeID]
            addPoint = addPointDict.get(skillTypeID, 0) # 该技能已执行加点数
            # 已经达到请求加的点数,不再处理
            if addPoint >= totalAddPoint:
                #GameWorld.DebugLog("    已经加到请求加的点数,不再处理!skillTypeID=%s,addPoint=%s" % (skillTypeID, addPoint))
                continue
            curSkill = skillManager.FindSkillBySkillTypeID(skillTypeID)
            # δѧϰ
            if not curSkill:
                learnSkillLV = 1
            # 已学习
            else:
                curSkillLV = curSkill.GetSkillLV()
                curSkillMaxLV = curSkill.GetSkillMaxLV()
                if curSkillLV >= curSkillMaxLV:
                    GameWorld.DebugLog("    技能已满级!skillTypeID=%s" % (skillTypeID))
                    continue
                learnSkillLV = curSkillLV + 1
            learnSkillData = GameWorld.GetGameData().FindSkillByType(skillTypeID, learnSkillLV)
            if not learnSkillData:
                GameWorld.ErrLog("找不到学习技能数据:skillTypeID=%s,skillLV=%s" % (skillTypeID, learnSkillLV))
                continue
            learnSkillID = learnSkillData.GetSkillID()
            skillLearnReq = learnSkillData.GetLearnSkillReq()
            skillLearnReqLV = learnSkillData.GetLearnSkillLV()
            skillLearnSeriesPointReq = learnSkillData.GetLearnSkillPointReq()
            # 前置技能点数需求
            reqSkillLV = skillTypeLVDict.get(skillLearnReq, 0)
            if skillLearnReq > 0 and skillTypeLVDict.get(skillLearnReq, 0) < skillLearnReqLV:
                #GameWorld.DebugLog("    前置技能加点未满足!learnSkillID=%s,[前置技能%s 当前%s点 需%s点]"
                #                   % (learnSkillID, skillLearnReq, reqSkillLV, skillLearnReqLV))
                continue
            # 天赋系点数需求
            if skillLearnSeriesPointReq > 0:
                isReqAllPoint = skillTypeID in reqTotalPointSkillList # 是否需求所有系总点数
                # 已加总天赋点数不足
                if isReqAllPoint and allSeriesTotalPoint < skillLearnSeriesPointReq:
                    #GameWorld.DebugLog("    总天赋点数不足!learnSkillID=%s,curPoint=%s,reqPoint=%s"
                    #                   % (learnSkillID, allSeriesTotalPoint, skillLearnSeriesPointReq))
                    continue
                # 已加本系天赋点数不足
                curSeriesTotalPoint = seriesTotalPointDict.get(curSeriesType, 0)
                if not isReqAllPoint and curSeriesTotalPoint < skillLearnSeriesPointReq:
                    #GameWorld.DebugLog("    本系天赋点数不足!learnSkillID=%s,curSeriesType=%s,curPoint=%s,reqPoint=%s"
                    #                   % (learnSkillID, curSeriesType, curSeriesTotalPoint, skillLearnSeriesPointReq))
                    continue
            # 可加点, 下面执行该技能加点
            skillManager.LVUpSkillBySkillTypeID(skillTypeID)
            DataRecordPack.DR_LearnORUPSkill(curPlayer, skillTypeID, learnSkillLV)
            # 是被动技能要重刷属性
            #if SkillCommon.isPassiveBuffSkill(learnSkillData):
            #    BuffSkill.AddBuffNoRefreshState(curPlayer, buffType, learnSkillData, tick, [], curPlayer)
            #    isRefreshAttr = True
            isAddSkill = True
            addPointDict[skillTypeID] = addPoint + 1
            skillTypeLVDict[skillTypeID] = learnSkillLV
            seriesTotalPointDict[curSeriesType] = seriesTotalPointDict.get(curSeriesType, 0) + 1
            allSeriesTotalPoint += 1
            SetGreatMasterFreeSkillPoint(curPlayer, freeSkillPoint - 1)
            # 成就
            #successKey = ChConfig.Def_PDict_Success_CntValue%(ShareDefine.SuccType_TalentPoint, 0)
            #curSuccess = PlayerSuccess.GetPDictValue(curPlayer, successKey)
            #if curSuccess < allSeriesTotalPoint:
            #    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_TalentPoint, 1)
            #GameWorld.DebugLog("    加天赋技能 learnSkillID=%s,skillTypeID=%s,skillLV=%s,doCnt=%s,needCnt=%s"
            #                   % (learnSkillID, skillTypeID, learnSkillLV, addPoint + 1, totalAddPoint))
        #GameWorld.DebugLog("    isAddSkill=%s" % isAddSkill)
    if isRefreshAttr:
        curControl = PlayerControl.PlayerControl(curPlayer)
        #curControl.CalcPassiveBuffAttr()
        curControl.RefreshPlayerAttrByBuff()
    PlayerControl.NotifyCode(curPlayer, "GeRen_liubo_224510")
    Sync_GreatMasterFreeSkillPoint(curPlayer)
    return
    return #现版本加点方式不同 使用03 04 玩家学习技能#tagCAddSkillPoint,此处先屏蔽
#    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
#
#    needAddSkillPointList = clientData.AddSkillPointList
#
#    if not needAddSkillPointList:
#        return
#
#    reqTotalPointSkillDict = ReadChConfig.GetEvalChConfig("ReqTotalPointSkill")
#    greatMasterSkillDict = ReadChConfig.GetEvalChConfig("GreatMasterSkill")
#    jobType = ChConfig.JOB_TYPE_DICT[curPlayer.GetJob()]
#
#    if jobType not in greatMasterSkillDict:
#        return
#
#    jobMasterSkillDict = greatMasterSkillDict[jobType] # 本职业天赋系对应技能
#    reqTotalPointSkillList = reqTotalPointSkillDict.get(jobType, []) # 本职业需求总天赋点技能
#
#    skillTypeSeriesDict = {} # 技能对应天赋系
#    skillTypeLVDict = {} # 技能对应等级
#    seriesTotalPointDict = {} # 天赋系对应总技能点
#    allSeriesTotalPoint = 0 # 所有天赋系总点数
#
#    # 汇总天赋技能所属天赋系
#    for seriesType, skillTypeIDList in jobMasterSkillDict.items():
#        for sTypeID in skillTypeIDList:
#            skillTypeSeriesDict[sTypeID] = seriesType
#
#    skillManager = curPlayer.GetSkillManager()
#
#    # 获取玩家目前所有技能
#    for i in range(skillManager.GetSkillCount()):
#        playerSkill = skillManager.GetSkillByIndex(i)
#        if playerSkill == None:
#            continue
#
#        playerSkillTypeID = playerSkill.GetSkillTypeID()
#
#        for seriesType, skillTypeIDList in jobMasterSkillDict.items():
#            if playerSkillTypeID not in skillTypeIDList:
#                continue
#
#            skillLV = playerSkill.GetSkillLV()
#            skillTypeLVDict[playerSkillTypeID] = skillLV
#            seriesTotalPointDict[seriesType] = seriesTotalPointDict.get(seriesType, 0) + skillLV
#            allSeriesTotalPoint += skillLV
#            break
#
#    isAddSkill = True
#    isRefreshAttr = False
#    buffType = IPY_GameWorld.btPassiveBuf
#    addPointDict = {} # 请求加点技能已执行加点数
#
#    GameWorld.DebugLog("【天赋加点】jobType=%s,技能对应等级=%s,天赋系对应总技能点=%s,总点数=%s"
#                       % (jobType, skillTypeLVDict, seriesTotalPointDict, allSeriesTotalPoint))
#
#    while isAddSkill:
#        # 每次循环重置状态,直到无法再加技能才跳出
#        isAddSkill = False
#
#        for addSkill in needAddSkillPointList:
#            skillTypeID = addSkill.SkillID
#            totalAddPoint = addSkill.AddPoint
#
#            freeSkillPoint = GetGreatMasterFreeSkillPoint(curPlayer)
#            if freeSkillPoint <= 0:
#                GameWorld.DebugLog("    当前无剩余天赋点!")
#                break
#
#            if skillTypeID not in skillTypeSeriesDict:
#                GameWorld.ErrLog("技能不在合法天赋系里!skillTypeID=%s" % skillTypeID)
#                continue
#
#            curSeriesType = skillTypeSeriesDict[skillTypeID]
#
#            addPoint = addPointDict.get(skillTypeID, 0) # 该技能已执行加点数
#
#            # 已经达到请求加的点数,不再处理
#            if addPoint >= totalAddPoint:
#                #GameWorld.DebugLog("    已经加到请求加的点数,不再处理!skillTypeID=%s,addPoint=%s" % (skillTypeID, addPoint))
#                continue
#
#            curSkill = skillManager.FindSkillBySkillTypeID(skillTypeID)
#
#            # δѧϰ
#            if not curSkill:
#                learnSkillLV = 1
#            # 已学习
#            else:
#                curSkillLV = curSkill.GetSkillLV()
#                curSkillMaxLV = curSkill.GetSkillMaxLV()
#                if curSkillLV >= curSkillMaxLV:
#                    GameWorld.DebugLog("    技能已满级!skillTypeID=%s" % (skillTypeID))
#                    continue
#
#                learnSkillLV = curSkillLV + 1
#
#            learnSkillData = GameWorld.GetGameData().FindSkillByType(skillTypeID, learnSkillLV)
#
#            if not learnSkillData:
#                GameWorld.ErrLog("找不到学习技能数据:skillTypeID=%s,skillLV=%s" % (skillTypeID, learnSkillLV))
#                continue
#
#            learnSkillID = learnSkillData.GetSkillID()
#            skillLearnReq = learnSkillData.GetLearnSkillReq()
#            skillLearnReqLV = learnSkillData.GetLearnSkillLV()
#            skillLearnSeriesPointReq = learnSkillData.GetLearnSkillPointReq()
#
#            # 前置技能点数需求
#            reqSkillLV = skillTypeLVDict.get(skillLearnReq, 0)
#            if skillLearnReq > 0 and skillTypeLVDict.get(skillLearnReq, 0) < skillLearnReqLV:
#                #GameWorld.DebugLog("    前置技能加点未满足!learnSkillID=%s,[前置技能%s 当前%s点 需%s点]"
#                #                   % (learnSkillID, skillLearnReq, reqSkillLV, skillLearnReqLV))
#                continue
#
#            # 天赋系点数需求
#            if skillLearnSeriesPointReq > 0:
#                isReqAllPoint = skillTypeID in reqTotalPointSkillList # 是否需求所有系总点数
#
#                # 已加总天赋点数不足
#                if isReqAllPoint and allSeriesTotalPoint < skillLearnSeriesPointReq:
#                    #GameWorld.DebugLog("    总天赋点数不足!learnSkillID=%s,curPoint=%s,reqPoint=%s"
#                    #                   % (learnSkillID, allSeriesTotalPoint, skillLearnSeriesPointReq))
#                    continue
#
#                # 已加本系天赋点数不足
#                curSeriesTotalPoint = seriesTotalPointDict.get(curSeriesType, 0)
#                if not isReqAllPoint and curSeriesTotalPoint < skillLearnSeriesPointReq:
#                    #GameWorld.DebugLog("    本系天赋点数不足!learnSkillID=%s,curSeriesType=%s,curPoint=%s,reqPoint=%s"
#                    #                   % (learnSkillID, curSeriesType, curSeriesTotalPoint, skillLearnSeriesPointReq))
#                    continue
#
#            # 可加点, 下面执行该技能加点
#            skillManager.LVUpSkillBySkillTypeID(skillTypeID)
#            DataRecordPack.DR_LearnORUPSkill(curPlayer, skillTypeID, learnSkillLV)
#
#            # 是被动技能要重刷属性
#            #if SkillCommon.isPassiveBuffSkill(learnSkillData):
#            #    BuffSkill.AddBuffNoRefreshState(curPlayer, buffType, learnSkillData, tick, [], curPlayer)
#            #    isRefreshAttr = True
#
#            isAddSkill = True
#
#            addPointDict[skillTypeID] = addPoint + 1
#            skillTypeLVDict[skillTypeID] = learnSkillLV
#            seriesTotalPointDict[curSeriesType] = seriesTotalPointDict.get(curSeriesType, 0) + 1
#            allSeriesTotalPoint += 1
#            SetGreatMasterFreeSkillPoint(curPlayer, freeSkillPoint - 1)
#            # 成就
#            #successKey = ChConfig.Def_PDict_Success_CntValue%(ShareDefine.SuccType_TalentPoint, 0)
#            #curSuccess = PlayerSuccess.GetPDictValue(curPlayer, successKey)
#            #if curSuccess < allSeriesTotalPoint:
#            #    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_TalentPoint, 1)
#
#            #GameWorld.DebugLog("    加天赋技能 learnSkillID=%s,skillTypeID=%s,skillLV=%s,doCnt=%s,needCnt=%s"
#            #                   % (learnSkillID, skillTypeID, learnSkillLV, addPoint + 1, totalAddPoint))
#
#        #GameWorld.DebugLog("    isAddSkill=%s" % isAddSkill)
#
#    if isRefreshAttr:
#        curControl = PlayerControl.PlayerControl(curPlayer)
#        #curControl.CalcPassiveBuffAttr()
#        curControl.RefreshPlayerAttrByBuff()
#
#    PlayerControl.NotifyCode(curPlayer, "GeRen_liubo_224510")
#    Sync_GreatMasterFreeSkillPoint(curPlayer)
#    return
#// A5 50 重置大师天赋技能 #tagCMResetMasterSkill
@@ -502,57 +298,51 @@
#  @return: None
def OnResetMasterSkill(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    ResetMasterSkillCost = ReadChConfig.GetEvalChConfig("ResetMasterSkillCost")
    needItemID = IpyGameDataPY.GetFuncCfg('TalentResetBook')
    costMoney = IpyGameDataPY.GetFuncCfg('TalentResetBook', 2)
    moneyType = IPY_GameWorld.TYPE_Price_Gold_Money
    if not PlayerControl.HaveMoney(curPlayer, moneyType, ResetMasterSkillCost):
        return
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    hasEnough, itemList = ItemCommon.GetItem_FromPack_ByID(needItemID, itemPack, 1)
    if not hasEnough:
        #道具不足,扣钱
        if not PlayerControl.HaveMoney(curPlayer, moneyType, costMoney):
            return
    
    if not DoResetMasterSkillPoint(curPlayer):
        return
    # 扣除消耗
    PlayerControl.PayMoney(curPlayer, moneyType, ResetMasterSkillCost, ChConfig.Def_Cost_ResetGreatMasterSkill)
    if hasEnough:
        ItemCommon.ReduceItem(curPlayer, itemPack, itemList, 1, False)
    else:
        PlayerControl.PayMoney(curPlayer, moneyType, costMoney, ChConfig.Def_Cost_ResetGreatMasterSkill)
    return
## 重置大师天赋技能
#  @param curPlayer
#  @return: 是否成功
def DoResetMasterSkillPoint(curPlayer):
    greatMasterSkillDict = ReadChConfig.GetEvalChConfig("GreatMasterSkill")
    jobType = ChConfig.JOB_TYPE_DICT[curPlayer.GetJob()]
    if jobType not in greatMasterSkillDict:
        return False
    jobMasterSkillDict = greatMasterSkillDict[jobType] # 本职业天赋系对应技能
    freeSkillPoint = GetGreatMasterFreeSkillPoint(curPlayer)
    resetPoint = 0
    
    skillManager = curPlayer.GetSkillManager()
    
    isRefreshAttr = False
    # 汇总天赋技能所属天赋系
    for skillTypeIDList in jobMasterSkillDict.values():
    delCnt = 0
    for i in range(0, skillManager.GetSkillCount()):
        dataIndex = i-delCnt
        skill = skillManager.GetSkillByIndex(dataIndex)
        if skill == None:
            continue
        skillTypeID = skill.GetSkillTypeID()
        if not IpyGameDataPY.GetIpyGameDataNotLog('TalentSkill', skillTypeID):
            continue
        curSkillLV = skill.GetSkillLV()
        # 被动技能刷属性
        if SkillCommon.isPassiveSkill(skill):
            isRefreshAttr = True
        
        for skillTypeID in skillTypeIDList:
            curSkill = skillManager.FindSkillBySkillTypeID(skillTypeID)
            if not curSkill:
                continue
            curSkillLV = curSkill.GetSkillLV()
            # 被动技能刷属性
            if SkillCommon.isPassiveSkill(curSkill):
                isRefreshAttr = True
            resetPoint += curSkillLV
            skillManager.DeleteSkillBySkillTypeID(skillTypeID)
        resetPoint += curSkillLV
        skillManager.DeleteSkillBySkillTypeID(skillTypeID)
        delCnt +=1
            
    if resetPoint <= 0:
        GameWorld.DebugLog("不需要重置技能天赋!")
@@ -561,9 +351,16 @@
    SetGreatMasterFreeSkillPoint(curPlayer, freeSkillPoint + resetPoint)
    Sync_GreatMasterFreeSkillPoint(curPlayer)
    
    # 重新刷新被动技能
    passiveEff = PassiveBuffEffMng.GetPassiveEffManager().InitObjPassiveEff(curPlayer)
    passiveEff.RefreshPassiveSkill()
    DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_ResetTalent, {'resetPoint':resetPoint})
    if isRefreshAttr:
        curControl = PlayerControl.PlayerControl(curPlayer)
        #curControl.CalcPassiveBuffAttr()
        curControl.RefreshPlayerAttrByBuff()
        # 重刷被动技能
        PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer)
    # 重刷技能战力
    curControl = PlayerControl.PlayerControl(curPlayer)
    curControl.RefreshAllSkill()
    curControl.RefreshPlayerAttrState()
    return True