#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # ##@package Player.PlayerGreatMaster # # @todo:Ì츳ϵͳ # @author xdh # @date 2018-9-26 # @version 1.0 # # # ÏêϸÃèÊö: Ì츳ϵͳ # #--------------------------------------------------------------------- #"""Version = 2018-9-26 20:00""" import GameWorld import PlayerControl import IPY_GameWorld import DataRecordPack import SkillCommon import ShareDefine import ChConfig import GameFuncComm import IpyGameDataPY import ItemCommon import PassiveBuffEffMng ## ´óʦ¹¦ÄÜÊÇ·ñ¿ªÆô # @param curPlayer # @return def IsGreatMasterOpen(curPlayer): if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Talent): return False return True 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) if setTalentPoint != curFreeSkillPoint: SetGreatMasterFreeSkillPoint(curPlayer, setTalentPoint) Sync_GreatMasterFreeSkillPoint(curPlayer) GameWorld.Log(' Ì츳¹¦ÄÜ¿ªÆô´¦ÀíÌ츳µã beforeTalentPoint=%s,setTalentPoint=%s, curLV=%s'%(curFreeSkillPoint, setTalentPoint, curLV), curPlayer.GetID()) return ## µÇ¼´¦Àí # @param curPlayer # @return def MasterOnLogin(curPlayer): if not IsGreatMasterOpen(curPlayer): return Sync_GreatMasterFreeSkillPoint(curPlayer) return ## Ôö¼Ó´óʦÌ츳µã # @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 GetGreatMasterFreeSkillPoint(curPlayer): return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Master_FreeSkillPoint, 0, ChConfig.Def_PDictType_GreatMaster) ## ÉèÖõ±Ç°Ê£Óà´óʦ¼¼Äܵã def SetGreatMasterFreeSkillPoint(curPlayer, value): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Master_FreeSkillPoint, value, ChConfig.Def_PDictType_GreatMaster) return ## ͬ²½´óʦʣÓàÌ츳µã # @param curPlayer # @return def Sync_GreatMasterFreeSkillPoint(curPlayer): PlayerControl.SendPropertyRefresh(curPlayer, ShareDefine.CDBPlayerRefresh_TalentPoint, GetGreatMasterFreeSkillPoint(curPlayer)) return #// A5 49 ´óʦÌ츳¼¼Äܼӵã #tagCMAddMasterSkillPoint # #struct tagCMMasterSkillPoint #{ # tagHead Head; # DWORD SkillID; // Ì츳¼¼ÄÜID # BYTE AddPoint; // ¼ÓµÄµãÊý #}; # #struct tagCMAddMasterSkillPoint #{ # tagHead Head; # BYTE SkillCnt; // ±ä¸ü¼¼ÄܸöÊý # tagCMMasterSkillPoint AddSkillPointList[SkillCnt]; // ¼ÓµÄ¼¼ÄܵãÊýÁбí #}; ## ´óʦÌ츳¼¼Äܼӵã # @param index: Íæ¼ÒË÷Òý # @param clientData: ·â°ü½á¹¹Ìå # @param tick: ʱ¼ä´Á # @return: None def OnAddMasterSkillPoint(index, clientData, tick): 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) # # # ÊDZ»¶¯¼¼ÄÜÒªÖØË¢ÊôÐÔ # #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 # #struct tagCMResetMasterSkill #{ # tagHead Head; #}; ## ÖØÖôóʦÌ츳¼¼ÄÜ # @param index: Íæ¼ÒË÷Òý # @param clientData: ·â°ü½á¹¹Ìå # @param tick: ʱ¼ä´Á # @return: None def OnResetMasterSkill(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) needItemID = IpyGameDataPY.GetFuncCfg('TalentResetBook') costMoney = IpyGameDataPY.GetFuncCfg('TalentResetBook', 2) moneyType = IPY_GameWorld.TYPE_Price_Gold_Money 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 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): freeSkillPoint = GetGreatMasterFreeSkillPoint(curPlayer) resetPoint = 0 skillManager = curPlayer.GetSkillManager() isRefreshAttr = False 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 resetPoint += curSkillLV skillManager.DeleteSkillBySkillTypeID(skillTypeID) delCnt +=1 if resetPoint <= 0: GameWorld.DebugLog("²»ÐèÒªÖØÖü¼ÄÜÌ츳£¡") return False 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: # ÖØË¢±»¶¯¼¼ÄÜ PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer) # ÖØË¢¼¼ÄÜÕ½Á¦ curControl = PlayerControl.PlayerControl(curPlayer) curControl.RefreshAllSkill() curControl.RefreshPlayerAttrState() return True