#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package Player.PlayerShentong # # @todo:Éñͨ # @author hxp # @date 2023-01-08 # @version 1.0 # # ÏêϸÃèÊö: Éñͨ # #------------------------------------------------------------------------------- #"""Version = 2023-01-08 18:00""" #------------------------------------------------------------------------------- import GameWorld import ShareDefine import PlayerControl import IpyGameDataPY import ChPyNetSendPack import IPY_GameWorld import NetPackCommon import PlayerGubao import ItemCommon import ChConfig import SkillCommon def GetShentongLVInfo(curPlayer, shentongID): lvInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShentongLVInfo % shentongID) classLV = lvInfo / 100 lv = lvInfo % 100 return classLV, lv def SetShentongLVInfo(curPlayer, shentongID, classLV, lv): PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShentongLVInfo % shentongID, classLV * 100 + lv) return def OnPlayerLogin(curPlayer): Sync_ShentongLVInfo(curPlayer) Sync_ShentongSkillInfo(curPlayer, True) return #// B2 19 ÉñͨÉý¼¶ #tagCMShentongLVUp # #struct tagCMShentongLVUp #{ # tagHead Head; # BYTE ShentongID; #}; def OnShentongLVUp(index, curPackData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) playerID = curPlayer.GetPlayerID() shentongID = curPackData.ShentongID ipyData = IpyGameDataPY.GetIpyGameData("Shentong", shentongID) if not ipyData: return needGubaoID = ipyData.GetNeedGubaoID() if needGubaoID and not PlayerGubao.GetGubaoLVInfo(curPlayer, needGubaoID)[1]: GameWorld.DebugLog("¹Å±¦Î´¼¤»î£¬ÎÞ·¨Éý¼¶Éñͨ! shentongID=%s,needGubaoID=%s" % (shentongID, needGubaoID), playerID) return classLV, lv = GetShentongLVInfo(curPlayer, shentongID) nextClassLV = classLV nextLV = lv + 1 lvIpyData = IpyGameDataPY.GetIpyGameDataNotLog("ShentongLV", shentongID, nextClassLV, nextLV) if not lvIpyData: nextClassLV = classLV + 1 nextLV = 1 lvIpyData = IpyGameDataPY.GetIpyGameDataNotLog("ShentongLV", shentongID, nextClassLV, nextLV) if not lvIpyData: GameWorld.ErrLog("ûÓÐÏÂÒ»¼¶ÉñͨÊý¾Ý£¬ÎÞ·¨Éý¼¶! shentongID=%s,classLV=%s,lv=%s" % (shentongID, classLV, lv), playerID) return needItemList = lvIpyData.GetLVLightNeedItem() if not needItemList: return itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem) lackItemDict, delInfoDict = ItemCommon.GetCostItemIndexList(needItemList, itemPack) if lackItemDict: GameWorld.DebugLog("ÉñͨÉý¼¶ËùÐèÎïÆ·²»×㣡 shentongID=%s,classLV(%s-%s),nextClassLV=(%s-%s),needItemList=%s,lackItemDict=%s" % (shentongID, classLV, lv, nextClassLV, nextLV, needItemList, lackItemDict), playerID) return #¿ÛÏûºÄ ItemCommon.DelCostItem(curPlayer, itemPack, delInfoDict, "Shentong") SetShentongLVInfo(curPlayer, shentongID, nextClassLV, nextLV) Sync_ShentongLVInfo(curPlayer, [shentongID]) LVSkillID = lvIpyData.GetLVSkillID() GameWorld.Log("ÉñͨÉý¼¶³É¹¦£¡ shentongID=%s,classLV(%s-%s),nextClassLV=(%s-%s),LVSkillID=%s" % (shentongID, classLV, lv, nextClassLV, nextLV, LVSkillID), playerID) if LVSkillID: lvSkillData = GameWorld.GetGameData().GetSkillBySkillID(LVSkillID) lvSkillTypeID = lvSkillData.GetSkillTypeID() if lvSkillData else 0 lvSkillLV = lvSkillData.GetSkillLV() if lvSkillData else 0 ShentongSkillCount = len(IpyGameDataPY.GetFuncEvalCfg("Shentong", 1)) skillIDList = [] for num in range(ShentongSkillCount): skillID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShentongSkillID % num) if not skillID: skillIDList.append(0) continue skillData = GameWorld.GetGameData().GetSkillBySkillID(skillID) if not skillData: continue skillTypeID = skillData.GetSkillTypeID() skillLV = skillData.GetSkillLV() if lvSkillTypeID == skillTypeID: if lvSkillLV > skillLV: # Éý¼¶ skillIDList.append(LVSkillID) else: skillIDList.append(0) # Ò»°ã²»¿ÉÄÜ£¬³öÏÖ¸ÃÇé¿öµÄ»°ÖÃ0ÖØÐÂÌí¼Ó else: skillIDList.append(skillID) # ÓпÕλĬÈÏÌí¼Óµ½¸Ã¿Õλ if LVSkillID not in skillIDList and 0 in skillIDList: skillIDList[skillIDList.index(0)] = LVSkillID if LVSkillID in skillIDList: GameWorld.DebugLog("×Ô¶¯³öÕ½/Ìæ»»Éñͨ¼¼ÄÜ: skillIDList=%s" % skillIDList, playerID) SetShentongSkill(curPlayer, skillIDList) RefreshShentongAttr(curPlayer) return #// B2 20 Éñͨ¼¼ÄÜÉèÖà #tagCMShentongSkillSet # #struct tagCMShentongSkillSet #{ # tagHead Head; # BYTE Count; # DWORD SkillIDList[Count]; #}; def OnShentongSkillSet(index, curPackData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) skillIDList = curPackData.SkillIDList SetShentongSkill(curPlayer, skillIDList) return def SetShentongSkill(curPlayer, setSkillIDList): # @param setSkillIDList: ÒòΪÊÇ·¢ËÍËùÓм¼ÄܲÛÉèÖõļ¼ÄÜ£¬ËùÒÔÔªËØÖпÉÄÜ´æÔÚ¼¼ÄÜ0 if not setSkillIDList: return needSkillCntList = IpyGameDataPY.GetFuncEvalCfg("Shentong", 1) ShentongSkillCountMax = len(needSkillCntList) if len(setSkillIDList) > ShentongSkillCountMax: return if len(setSkillIDList) < ShentongSkillCountMax: setSkillIDList += [0] * (ShentongSkillCountMax - len(setSkillIDList)) forbidSkillIDList = [] for skillID in setSkillIDList: if not skillID: continue if not GameWorld.GetGameData().GetSkillBySkillID(skillID): GameWorld.ErrLog("ÕÒ²»µ½¸ÃÉñͨ¼¼ÄÜÊý¾Ý! skillID=%s" % skillID) return forbidSkillIDList.append(skillID) setSkillCount = len(forbidSkillIDList) canUseSkillDict = {} # {skillTypeID:skillID, ...} ipyDataMgr = IpyGameDataPY.IPY_Data() for index in xrange(ipyDataMgr.GetShentongLVCount()): ipyData = ipyDataMgr.GetShentongLVByIndex(index) LVSkillID = ipyData.GetLVSkillID() if not LVSkillID: continue shentongID = ipyData.GetShentongID() shentongClassLV = ipyData.GetShentongClassLV() shentongLV = ipyData.GetShentongLV() classLV, lv = GetShentongLVInfo(curPlayer, shentongID) if classLV < shentongClassLV or (classLV == shentongClassLV and lv < shentongLV): #GameWorld.ErrLog("ÉñͨµÈ¼¶²»×㣬ÎÞ·¨Ê¹Óøü¼ÄÜ! LVSkillID=%s,shentongID=%s,needClassLV=(%s-%s),curClassLV=(%s-%s)" # % (LVSkillID, shentongID, shentongClassLV, shentongLV, classLV, lv), curPlayer.GetPlayerID()) continue skillData = GameWorld.GetGameData().GetSkillBySkillID(LVSkillID) if not skillData: continue skillTypeID = skillData.GetSkillTypeID() canUseSkillDict[skillTypeID] = LVSkillID if LVSkillID in forbidSkillIDList: forbidSkillIDList.remove(LVSkillID) if forbidSkillIDList: GameWorld.ErrLog("´æÔÚÎÞ·¨Ê¹ÓõÄÉñͨ¼¼ÄÜ£¬ÎÞ·¨ÉèÖÃ! setSkillIDList=%s,forbidSkillIDList=%s" % (setSkillIDList, forbidSkillIDList), curPlayer.GetPlayerID()) return if setSkillCount > 0: needCanUseSkillCnt = needSkillCntList[setSkillCount - 1] if needCanUseSkillCnt > len(canUseSkillDict): GameWorld.DebugLog("´æÔÚδ½âËøµÄÉñͨ¼¼Äܿף¬ÎÞ·¨ÉèÖÃ! setSkillIDList=%s,needCanUseSkillCnt=%s > canUseSkillCnt=%s(%s)" % (setSkillIDList, needCanUseSkillCnt, len(canUseSkillDict), canUseSkillDict), curPlayer.GetPlayerID()) return # ÒòΪ¿ÉÄܵ÷Õû˳Ðò£¬±ØÐëÏÈͳһɾ³ýÔÙͳһÌí¼Ó£¬²»È»¿ÉÄܵ¼Ö¼¼ÄÜ˳Ðòµ÷ÕûºóÏȱ»Ìí¼ÓºóÓÖ±»É¾³ý skillManager = curPlayer.GetSkillManager() playerCtl = PlayerControl.PlayerControl(curPlayer) for num in range(ShentongSkillCountMax): skillID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShentongSkillID % num) if skillID and skillManager.FindSkillBySkillID(skillID): skillManager.DeleteSkillBySkillID(skillID, True) playerCtl.RefreshSkillFightPowerByDel(skillID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShentongSkillID % num, 0) tick = GameWorld.GetGameWorld().GetTick() for num in range(ShentongSkillCountMax): setSkillID = setSkillIDList[num] if setSkillID: skillManager.LearnSkillByID(setSkillID, True) playerCtl.RefreshSkillFightPowerEx(setSkillID, 0) # ÖØÐÂÉèÖü¼ÄÜÇ¿ÖƽøÈëCD curSkill = skillManager.FindSkillBySkillID(setSkillID) if curSkill: SkillCommon.SetSkillRemainTime(curSkill, PlayerControl.GetReduceSkillCDPer(curPlayer), tick, curPlayer, True) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ShentongSkillID % num, setSkillID) Sync_ShentongSkillInfo(curPlayer) return def RefreshShentongAttr(curPlayer): CalcShentongAttr(curPlayer) PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState() return def CalcShentongAttr(curPlayer): customAttrDictShentong = {} fightPowerEx = 0 allAttrList = [{} for _ in range(4)] shentongSkillInfo = {} ipyDataMgr = IpyGameDataPY.IPY_Data() for index in xrange(ipyDataMgr.GetShentongCount()): ipyData = ipyDataMgr.GetShentongByIndex(index) shentongID = ipyData.GetShentongID() classLV, lv = GetShentongLVInfo(curPlayer, shentongID) if not classLV and not lv: continue lvIpyDataList = IpyGameDataPY.GetIpyGameDataByCondition("ShentongLV", {"ShentongID":shentongID}, True) if not lvIpyDataList: continue for lvIpyData in lvIpyDataList: shentongClassLV = lvIpyData.GetShentongClassLV() shentongLV = lvIpyData.GetShentongLV() if classLV < shentongClassLV or (classLV == shentongClassLV and lv < shentongLV): break LVAttrTypeList = lvIpyData.GetLVAttrTypeList() LVAttrValueList = lvIpyData.GetLVAttrValueList() for i, attrID in enumerate(LVAttrTypeList): attrValue = LVAttrValueList[i] PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList) if lvIpyData.GetFightPowerEx(): fightPowerEx += lvIpyData.GetFightPowerEx() LVSkillID = lvIpyData.GetLVSkillID() if LVSkillID: skillData = GameWorld.GetGameData().GetSkillBySkillID(LVSkillID) if skillData: skillTypeID = skillData.GetSkillTypeID() skillLV = skillData.GetSkillLV() shentongSkillInfo[skillTypeID] = skillLV customAttrDictShentong["shentongSkillInfo"] = shentongSkillInfo # ¸½¼ÓÕ½Á¦ curPlayer.SetDict(ChConfig.Def_PlayerKey_MFPEx % ShareDefine.Def_MFPType_Shentong, fightPowerEx) # ±£´æ¼ÆËãÖµ PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Shentong, allAttrList, customAttrDict=customAttrDictShentong) return def Sync_ShentongLVInfo(curPlayer, shentongIDList=None): if shentongIDList == None: syncIDList = [] ipyDataMgr = IpyGameDataPY.IPY_Data() for index in range(ipyDataMgr.GetShentongCount()): ipyData = ipyDataMgr.GetShentongByIndex(index) syncIDList.append(ipyData.GetShentongID()) else: syncIDList = shentongIDList shentongInfoList = [] for shentongID in syncIDList: classLV, lv = GetShentongLVInfo(curPlayer, shentongID) if not classLV and not lv and shentongIDList == None: # ûÓÐÖ¸¶¨Ê±Ö»Í¬²½¼¤»îµÄ continue shentong = ChPyNetSendPack.tagMCShentongLV() shentong.ShentongID = shentongID shentong.ClassLV = classLV shentong.LV = lv shentongInfoList.append(shentong) if not shentongInfoList: return clientPack = ChPyNetSendPack.tagMCShentongLVInfo() clientPack.ShentongLVList = shentongInfoList clientPack.Count = len(clientPack.ShentongLVList) NetPackCommon.SendFakePack(curPlayer, clientPack) return def Sync_ShentongSkillInfo(curPlayer, isLogin=False): skillIDList = [] ShentongSkillCountMax = len(IpyGameDataPY.GetFuncEvalCfg("Shentong", 1)) for num in range(ShentongSkillCountMax): skillIDList.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ShentongSkillID % num)) if skillIDList.count(0) == ShentongSkillCountMax and isLogin: return clientPack = ChPyNetSendPack.tagMCShentongSkillInfo() clientPack.SkillIDList = skillIDList clientPack.Count = len(clientPack.SkillIDList) NetPackCommon.SendFakePack(curPlayer, clientPack) return