From 1ea73e1885835466265ce788d93556b7030ee0e8 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期日, 30 十二月 2018 18:42:00 +0800
Subject: [PATCH] 5424 【后端】【1.4】跨服竞技场开发(GM工具增加子服服务器维护,文字翻译版)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMagicWeapon.py |  382 ++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 322 insertions(+), 60 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMagicWeapon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMagicWeapon.py
index cf603ef..83f6c91 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMagicWeapon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMagicWeapon.py
@@ -31,11 +31,12 @@
 import PlayerSuccess
 import EventShell
 import PassiveBuffEffMng
-import OpenServerCampaign
 import ItemControler
 import PlayerActivity
 import ChEquip
 import PlayerVip
+
+import random
 
 g_succInfoDict = {}
 g_potentialsSkillDict = {}
@@ -122,7 +123,8 @@
         if mwID in IpyGameDataPY.GetFuncEvalCfg('UnblockTreasure'):
             PlayerControl.NotifyCode(curPlayer, 'UnblockTreasure', [curPlayer.GetName(), mwID])
         else:
-            PlayerControl.WorldNotify(0, 'UnblockTreasure', [curPlayer.GetName(), mwID])
+            sysMark = IpyGameDataPY.GetFuncEvalCfg('UnblockTreasure', 2, {}).get(mwID, 'UnblockTreasure')
+            PlayerControl.WorldNotify(0, sysMark, [curPlayer.GetName(), mwID])
         
         #任务
         EventShell.EventRespons_OnActiveMagicWeapon(curPlayer, mwID)
@@ -136,13 +138,31 @@
 
     #解锁技能
     upIpyData = IpyGameDataPY.GetIpyGameData('TreasureUp', mwID, mwLV)
-    if upIpyData:
-        skillIDList = upIpyData.GetUnLockSkill()
-        for skillID in skillIDList:
-            GiveSkill(curPlayer, skillID, GameWorld.GetGameWorld().GetTick())
-        if upIpyData.GetPrivilegeID():
-            PlayerControl.WorldNotify(0, 'TreasureSoulWakeUp', [curPlayer.GetName(), upIpyData.GetPrivilegeID()])
+    if not upIpyData:
+        return
+    skillIDList = upIpyData.GetUnLockSkill()
+    for skillID in skillIDList:
+        GiveSkill(curPlayer, skillID, GameWorld.GetGameWorld().GetTick())
+    #物品奖励
+    itemAward = upIpyData.GetItemAward()
+    if itemAward:
+        itemID, itemCnt, isBind = itemAward
+        packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, 1)
+        if 1 > packSpace:
+            PlayerControl.SendMailByKey('TreasureWakeUp', [curPlayer.GetID()], [itemAward])
+        else:
+            ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, isBind,
+                                             [IPY_GameWorld.rptItem], True, showSysInfo=True, event=["MWAward", False, {"mwID":mwID}])
+    activeMWID = upIpyData.GetActiveMWID()
+    if activeMWID == mwID:
+        GameWorld.ErrLog('    TreasureUp.txt 配置异常 不可激活自身法宝 mwID=%s'%mwID)
+    elif activeMWID:
+        DoActiveMW(curPlayer, activeMWID)
     
+    #激活魂
+    activeSoulID = upIpyData.GetActiveSoulID()
+    if activeSoulID:
+        __DoActiveMWSoul(curPlayer, activeSoulID, False)
     
     CalcMagicWeaponAttr(curPlayer)
     PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
@@ -207,9 +227,10 @@
             activeCnt += 1
     return activeCnt
 
-def GetMWIDByPotentialsSkillID(skillID):
-    #通过潜力技能ID获取对应的法宝ID
+def GetPotentialsSkillInfo(curPlayer):
+    #通过潜力技能ID获取对应的下一个技能ID {skillUseType:{skillid:[skilllv,nextSkillid,addPower,]}}
     global g_potentialsSkillDict
+
     if not g_potentialsSkillDict:
         g_potentialsSkillDict = {}
         ipyDataMgr = IpyGameDataPY.IPY_Data()
@@ -217,9 +238,31 @@
             ipyData = ipyDataMgr.GetTreasureByIndex(i)
             mwID = ipyData.GetID()
             skillIDList = ipyData.GetPotentials()
+            addPowerList = ipyData.GetSkillPower()
+            lastSkillUseType = 0
             for curSkillID in skillIDList:
-                g_potentialsSkillDict[curSkillID] = mwID  
-    return g_potentialsSkillDict.get(skillID, 0)
+                skillData = GameWorld.GetGameData().FindSkillByType(curSkillID, 1)
+                if skillData == None:
+                    GameWorld.DebugLog("GetPotentialsSkillInfo() hasn't find skill(%s)" % curSkillID)
+                    continue
+                if lastSkillUseType != skillData.GetUseType():
+                    index = 0
+                else:
+                    index +=1
+                lastSkillUseType = skillData.GetUseType()
+                addPower = addPowerList[index]
+
+                preSkillID = skillData.GetLearnSkillReq()
+                if not preSkillID:
+                    continue
+                skillUseType = skillData.GetUseType()
+                preSkilllv = skillData.GetLearnSkillLV()
+                if skillUseType not in g_potentialsSkillDict:
+                    g_potentialsSkillDict[skillUseType] = {}
+                g_potentialsSkillDict[skillUseType][preSkillID] = [preSkilllv, curSkillID, addPower]
+    curskillUseType = pow(2, curPlayer.GetJob())
+    
+    return g_potentialsSkillDict.get(curskillUseType, {})
 
 ## 给技能
 #  @param curPlayer
@@ -346,8 +389,20 @@
     #infoDict = {"SkillID":skillTypeID, "SkillLV":upSkillLv, ChConfig.Def_Cost_Reason_SonKey:upSkill.GetSkillName()}
     if not PlayerControl.PlayerLostZhenQi(curPlayer, needSP):
         return
-    
-    if not GameWorld.CanHappen(initRate):
+    playerID = curPlayer.GetPlayerID()
+    maxRateValue = ShareDefine.Def_MaxRateValue
+    randValue = random.randint(0, maxRateValue-1)
+    canHappen = randValue < initRate
+    GameWorld.DebugLog("canHappen=%s,randValue=%s,initRate=%s,maxRateValue=%s" 
+                       % (canHappen, randValue, initRate, maxRateValue), playerID)
+    # 不是百分百成功的记录合成流向
+    if initRate != maxRateValue:
+        drDict = {"PlayerID":playerID, "AccID":curPlayer.GetAccID(), "skillTypeID":skillTypeID, "IsSuccess":canHappen,
+                  "initRate":initRate, "randValue":randValue, "maxRateValue":maxRateValue}
+
+        DataRecordPack.SendEventPack("MagicWeaponSkillUp", drDict, curPlayer)
+
+    if not canHappen:
         GameWorld.DebugLog("法宝技能升级,curSkillID=%s, maxRate=%s 升级失败" % (curSkillID, initRate))
         curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitMagicWeaponSkillUp, 0)
         return
@@ -364,21 +419,32 @@
                 if newSkill:
                     skillManager.LVUPSkillByID(newSkillID)
                     GameWorld.DebugLog('    法宝技能升级 skillTypeID=%s, upSkillLv=%s, 触发学习技能%s' % (skillTypeID, upSkillLv, newSkillID))
-                    curControl.RefreshSkillFightPowerEx(newSkillID, beforeFightPower)
+                    curControl.RefreshSkillFightPowerEx(newSkillID, 0)
                     PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer, newSkillID)
                     if SkillCommon.isPassiveAttr(newSkill):
                         newSkillIsPassive = True
+                    PlayerControl.WorldNotify(0, 'SkillPotential2', [curPlayer.GetName(), skillTypeID, upSkillLv, newSkillID])
             
     
-    if SkillCommon.isPassiveAttr(upSkill) or newSkillIsPassive:
+    #通知技能已升级成功
+    hasUnlockSkill = False
+    nextSkillDict = GetPotentialsSkillInfo(curPlayer)
+    if skillTypeID in nextSkillDict:
+        needSkilllv,nextSkillID = nextSkillDict[skillTypeID][:2]
+        if upSkillLv == needSkilllv:
+            PlayerControl.WorldNotify(0, 'SkillPotential1', [curPlayer.GetName(), skillTypeID, upSkillLv, nextSkillID])
+            CalcMagicWeaponAttr(curPlayer)
+            hasUnlockSkill = True
+            
+    maxLV = upSkill.GetSkillMaxLV()
+    if upSkillLv == maxLV:
+        PlayerControl.WorldNotify(0, 'SkillPotential3', [curPlayer.GetName(), skillTypeID, maxLV])
+    
+    if SkillCommon.isPassiveAttr(upSkill) or newSkillIsPassive or hasUnlockSkill:
         curControl.RefreshPlayerAttrState()
         
     curControl.RefreshSkillFightPowerEx(upSkill.GetSkillID(), beforeFightPower)
     PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer, upSkill.GetSkillID())
-    
-    #通知技能已升级成功 GeRen_admin_31379
-    #<n color="255,255,0" BKCOLOR="0,0,0">恭喜您将</n><n color="0,190,255" BKCOLOR="0,0,0"><Info Type="Skill" Name="Name" ID="{%S1%}"/></n><n color="255,255,0" BKCOLOR="0,0,0">升至</n><n color="0,190,255" BKCOLOR="0,0,0">{%S2%}</n><n color="255,255,0" BKCOLOR="0,0,0">级!</n>
-    #PlayerControl.NotifyCode(curPlayer, "GeRen_admin_31379", [skillTypeID, upSkillLv])
     
     #获得技能等级
     #curSkillLV = curSkill.GetSkillLV()
@@ -387,12 +453,21 @@
     
     curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitMagicWeaponSkillUp, 1)
     
-
+    SetMWPrivilegeData(curPlayer, ChConfig.MWPrivilege_MWSkillUp, GetSPSkillTotalLV(curPlayer))
     PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_MWSkillUp, 1, [skillTypeID])
     EventShell.EventRespons_MWSkillUp(curPlayer)
     return
 
-
+def GetSPSkillTotalLV(curPlayer):
+    #潜力技能总等级
+    totalLV = 0
+    skillManager = curPlayer.GetSkillManager()
+    for i in xrange(skillManager.GetSkillCount()):
+        curSkill = skillManager.GetSkillByIndex(i)
+        if curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_FbSPSkill:
+            continue
+        totalLV += curSkill.GetSkillLV()
+    return totalLV
 
 def NotifyMagicWeapon(curPlayer, isLogin=False):
     #通知法宝信息
@@ -422,17 +497,23 @@
 
 def CalcMagicWeaponAttr(curPlayer):
     ## 计算法宝属性
-    
     allAttrList1 = [{} for _ in range(4)] #人族法宝
     allAttrList2 = [{} for _ in range(4)] #魔族法宝
     allAttrList3 = [{} for _ in range(4)] #仙族法宝
+    allAttrList4 = [{} for _ in range(4)] #王者法宝
+    mwTypeMfpTypeDict = {1:ShareDefine.Def_MFPType_MagicWeapon1,
+                         2:ShareDefine.Def_MFPType_MagicWeapon2,
+                         3:ShareDefine.Def_MFPType_MagicWeapon3,
+                         4:ShareDefine.Def_MFPType_MagicWeapon4}
+    addPowerDict = {} #额外战力
+    signDayMWID = IpyGameDataPY.GetFuncCfg('MWSignDayAttr', 2)
     ipyDataMgr = IpyGameDataPY.IPY_Data()
     for i in xrange(ipyDataMgr.GetTreasureCount()):
         treasureIpyData = ipyDataMgr.GetTreasureByIndex(i)
         magicWeaponID = treasureIpyData.GetID()
         isActive = GetIsActiveMagicWeapon(curPlayer, magicWeaponID)
-        if not isActive:
-            continue
+#        if not isActive:
+#            continue
         allAttrDict = {}
         #=======================================================================
         # #铸炼属性
@@ -442,22 +523,51 @@
         #    attrDict = refineipyData.GetTreasureAttr()
         #    GameWorld.AddDictValue(allAttrDict, attrDict)
         #=======================================================================
-            
-        #等级属性
-        curMWLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponLV % magicWeaponID)
-        for lv in xrange(curMWLV+1):
-            upIpyData = IpyGameDataPY.GetIpyGameDataNotLog('TreasureUp', magicWeaponID, lv)
-            if upIpyData:
-                attrDict = upIpyData.GetAddAttr()
-                GameWorld.AddDictValue(allAttrDict, attrDict)
-
-                privilegeID = upIpyData.GetPrivilegeID()
-                if privilegeID:
-                    # 法宝之魂
-                    attrDict = GetMagicWeaponPrivilegeAttr(curPlayer, privilegeID)
-                    GameWorld.AddDictValue(allAttrDict, attrDict)
-        
         treasureType = treasureIpyData.GetTreasureType()
+        if isActive:
+            mfpType = mwTypeMfpTypeDict.get(treasureType, ShareDefine.Def_MFPType_Role)
+            #等级属性
+            curMWLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponLV % magicWeaponID)
+            for lv in xrange(curMWLV+1):
+                upIpyData = IpyGameDataPY.GetIpyGameDataNotLog('TreasureUp', magicWeaponID, lv)
+                if upIpyData:
+                    attrDict = upIpyData.GetAddAttr()
+                    GameWorld.AddDictValue(allAttrDict, attrDict)
+                    addPowerDict[mfpType] = addPowerDict.get(mfpType, 0) + upIpyData.GetPowerEx()
+                    
+            if magicWeaponID == signDayMWID:
+                #签到属性
+                totalSignNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalSignNum) # 总签到天数
+                addAttr = {}
+                for attid, attnum in IpyGameDataPY.GetFuncEvalCfg('MWSignDayAttr', 1, {}).items():
+                    addAttr[int(attid)] = attnum * totalSignNum
+                GameWorld.AddDictValue(allAttrDict, addAttr)
+            #王者法宝属性
+            seasonID = IpyGameDataPY.GetFuncEvalCfg('MagicWeaponOfKing', 1, {}).get(magicWeaponID, 0)
+            kingAwardLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonAwardLV % seasonID)
+            kingMWIpyData = IpyGameDataPY.GetIpyGameDataNotLog('MagicWeaponOfKing', magicWeaponID, kingAwardLV)
+            if kingMWIpyData and GetIsWearMagicWeapon(curPlayer, magicWeaponID):
+                attrDict = kingMWIpyData.GetAddAttr()
+                GameWorld.AddDictValue(allAttrDict, attrDict)
+        
+        fbpasslv = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWFBPassLevel % magicWeaponID)
+        #老号已激活的魔族法宝没有关卡属性,直接设置满关卡
+        if isActive and not fbpasslv:
+            ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('MagicWeaponFB', {'MWID':magicWeaponID}, True, False)
+            if ipyDataList:
+                maxLevel = ipyDataList[-1].GetLevel()
+                fbpasslv = maxLevel
+                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MWFBPassLevel % magicWeaponID, maxLevel)
+                GameWorld.Log('老号已激活的魔族法宝没有关卡属性,直接设置满关卡 magicWeaponID=%s,maxLevel=%s'%(magicWeaponID, maxLevel), curPlayer.GetID())
+        if fbpasslv: #副本关卡属性
+            fbipyData = IpyGameDataPY.GetIpyGameData('MagicWeaponFB', magicWeaponID, fbpasslv)
+            if fbipyData:
+                attrDict = fbipyData.GetAttrDict()
+                for effID, value in attrDict.items():
+                    effID = int(effID)
+                    allAttrDict[effID] = allAttrDict.get(effID, 0) + value
+                
+                
         for effID, value in allAttrDict.items():
             if treasureType == 1:
                 PlayerControl.CalcAttrDict_Type(effID, value, allAttrList1)
@@ -465,12 +575,32 @@
                 PlayerControl.CalcAttrDict_Type(effID, value, allAttrList2)
             elif treasureType == 3:
                 PlayerControl.CalcAttrDict_Type(effID, value, allAttrList3)
+            elif treasureType == 4:
+                PlayerControl.CalcAttrDict_Type(effID, value, allAttrList4)
             else:
                 GameWorld.ErrLog("未知法宝属性, magicWeaponID=%s,treasureType=%s,effID=%s,value=%s" 
                                  % (magicWeaponID, treasureType, effID, value), curPlayer.GetPlayerID())
+    
     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_MagicWeapon1, allAttrList1)
     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_MagicWeapon2, allAttrList2)
     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_MagicWeapon3, allAttrList3)
+    PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_MagicWeapon4, allAttrList4)
+    #技能解锁战力
+    nextSkillDict = GetPotentialsSkillInfo(curPlayer)
+    for skillID, info in nextSkillDict.items():
+        needSkilllv, nextSkillID, addPower = info
+        skillManager = curPlayer.GetSkillManager()
+        curSkill = skillManager.FindSkillBySkillTypeID(skillID)
+        if not curSkill:
+            continue
+        curSkillLV = curSkill.GetSkillLV()
+        if curSkillLV < needSkilllv:
+            continue
+        mfpType = ChConfig.Def_SkillFuncType_MFPType.get(curSkill.GetFuncType(), ShareDefine.Def_MFPType_Role)
+        addPowerDict[mfpType] = addPowerDict.get(mfpType, 0) + addPower
+    
+    for mfpType, addPower in addPowerDict.items():
+        curPlayer.SetDict(ChConfig.Def_PlayerKey_MFPEx % mfpType, addPower)
     return
 
 #// A5 77 玩家精炼法宝 #tagCMMWRefine
@@ -644,6 +774,7 @@
     elif curType == 2:
         #穿戴三阶橙色1星或四阶紫色1星以上头盔
         playerEquip = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
+        SamboSpecialUnlock = IpyGameDataPY.GetFuncEvalCfg('SamboSpecialUnlock')
         for equipIndex in xrange(playerEquip.GetCount()):
             curEquip = playerEquip.GetAt(equipIndex)
             if curEquip.IsEmpty():
@@ -651,7 +782,11 @@
             curClassLV = ItemCommon.GetItemClassLV(curEquip)
             itemColor = curEquip.GetItemColor()
             itemQuality = curEquip.GetItemQuality()
+            itemID = curEquip.GetItemTypeID()
             for classlv, color, star, place in conditionList:
+                if equipIndex is place and itemID in SamboSpecialUnlock:
+                    cnt = 1
+                    break
                 if equipIndex is place and curClassLV >= classlv and itemColor >= color and itemQuality >= star:
                     cnt = 1
                     break
@@ -721,7 +856,7 @@
         succCnt = ipyDataMgr.GetXBXZCount()
         if not succCnt:
             return
-        maxSuccid = ipyDataMgr.GetSuccessByIndex(succCnt-1).GetID()
+        maxSuccid = ipyDataMgr.GetXBXZByIndex(succCnt-1).GetID()
         recordIndexList = range(maxSuccid / 31+1)
             
     succFARPack = ChPyNetSendPack.tagMCXBXZAwardRecordList()
@@ -767,8 +902,6 @@
     
     DoActiveMW(curPlayer, mwID, nextMWLV)
     
-    # 每日活动
-    PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_MagicWeapon)
     return
 
 def AddMagicWeaponUpExp(curPlayer, mwID, addExp):
@@ -777,17 +910,24 @@
     curUpExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponUpExp % mwID)
     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MagicWeaponUpExp % mwID, curUpExp+addExp)
     Sycn_MagicWeaponLV(curPlayer, mwID)
+    # 每日活动
+    ipyData = GetWMIpyData(mwID)
+    mwType = ipyData.GetTreasureType() if ipyData else 0
+    if mwType == 1:
+        PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_MagicWeapon)
     return
 
 def Sycn_MagicWeaponLV(curPlayer, mwID= -1):
     #通知法宝等级信息
     if mwID == -1:
+        isAll = True
         needCalList = []
         ipyDataMgr = IpyGameDataPY.IPY_Data()
         for i in xrange(ipyDataMgr.GetTreasureCount()):
             ipyData = ipyDataMgr.GetTreasureByIndex(i)
             needCalList.append(ipyData.GetID())
     else:
+        isAll = False
         needCalList = [mwID]
     sendPack = ChPyNetSendPack.tagMCMagicWeaponLVInfo()
     sendPack.InfoList = []
@@ -795,13 +935,17 @@
         mwLv = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponLV % mwID)
         curUpExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponUpExp % mwID)
         state = GetIsClickMagicWeapon(curPlayer, mwID)
-        if not mwLv and not curUpExp and not state:
+        FBPassLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWFBPassLevel % mwID)
+        isWear = GetIsWearMagicWeapon(curPlayer, mwID)
+        if isAll and not mwLv and not curUpExp and not state and not FBPassLV and not isWear:
             continue
         pack = ChPyNetSendPack.tagMCMagicWeaponInfo()
         pack.MWID = mwID
         pack.LV = mwLv
         pack.Exp = curUpExp
         pack.State = state
+        pack.FBPassLV = FBPassLV
+        pack.IsWear = isWear
         sendPack.InfoList.append(pack)
     sendPack.Count = len(sendPack.InfoList)
     if sendPack.Count:
@@ -810,14 +954,7 @@
 
 def GetMagicWeaponPrivilege(curPlayer, privilege):
     #法宝等级权限
-    ipyData = IpyGameDataPY.GetIpyGameDataByCondition('TreasureUp', {'PrivilegeID':privilege}, False, False)
-    if not ipyData:
-        return 0
-
-    mwID = ipyData.GetMWID()
-    mwLV = ipyData.GetLV()
-    curMWLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponLV % mwID)
-    if curMWLV < mwLV:
+    if not GetIsActiveMWSoul(curPlayer, privilege):
         return 0
     privilegeIpyData = IpyGameDataPY.GetIpyGameDataNotLog('TreasurePrivilege', privilege)
     if not privilegeIpyData:
@@ -835,17 +972,16 @@
         attrInfo = {}
     singleValue = privilegeIpyData.GetSingleValue()
     
-    if privilege == ChConfig.MWPrivilege_SignDayAddAttr:
-        totalSignNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalSignNum) # 总签到天数
-        for attid, attnum in attrInfo.items():
-            addAttr[int(attid)] = attnum * totalSignNum
-    elif privilege == ChConfig.MWPrivilege_EquipPlus:
+    if privilege == ChConfig.MWPrivilege_EquipPlus:
         #强化加成
         addAttr = ChEquip.CalcAllEquipAllPlusLVAttr(curPlayer)
     else: 
         multiple = 1 #倍数
         if singleValue:
             gotValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulGotValue % privilege)
+            maxValue = privilegeIpyData.GetMaxValue()
+            if maxValue:
+                gotValue = min(maxValue, gotValue)
             multiple = gotValue/singleValue
         for attid, attnum in attrInfo.items():
             addAttr[int(attid)] = attnum * multiple
@@ -858,6 +994,13 @@
     privilegeIpyData = IpyGameDataPY.GetIpyGameDataNotLog('TreasurePrivilege', privilege)
     if not privilegeIpyData:
         return
+    curGotValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulGotValue % privilege)
+    singleValue = privilegeIpyData.GetSingleValue()
+    if singleValue and curGotValue % singleValue:
+        fixGotValue = curGotValue/singleValue*singleValue
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MWSoulGotValue % privilege, fixGotValue)
+        GameWorld.Log('玩家法宝之魂已领的数据不是单次进度的倍数,修复! privilege=%s,curGotValue=%s, fixGotValue=%s'%(privilege, curGotValue, fixGotValue))
+    
     curValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulCurValue % privilege)
     newData = curValue + data if isAdd else data
     maxValue = privilegeIpyData.GetMaxValue()
@@ -877,15 +1020,21 @@
         GameWorld.DebugLog('领取法宝之魂奖励,对应法宝之魂未激活,或未配置 privilege=%s'%privilege)
         return
     singleValue = ipyData.GetSingleValue()
+    maxValue = ipyData.GetMaxValue()
     if singleValue:
         #达到进度则可领取属性
         curValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulCurValue % privilege)
         gotValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulGotValue % privilege)
+        if gotValue >= curValue:
+            return
         canGetCnt = (curValue - gotValue) / singleValue
+        if canGetCnt <= 0 and maxValue and curValue >= maxValue:
+            canGetCnt = 1 #已达到次数上限,最后一次不管是否满足都让领(一般是因为配置错误或者变更导致)
         if canGetCnt <= 0:
             return
-        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MWSoulGotValue % privilege, gotValue+canGetCnt*singleValue)
-        CalcMagicWeaponAttr(curPlayer)
+        updGotCnt = min(maxValue, gotValue+canGetCnt*singleValue) if maxValue else gotValue+canGetCnt*singleValue
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MWSoulGotValue % privilege, updGotCnt)
+        CalcMagicWeaponSoulAttr(curPlayer)
         PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
         
         
@@ -922,7 +1071,8 @@
         pack.CurValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulCurValue % priID)
         pack.GotValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulGotValue % priID)
         pack.ItemAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulGotItemState % priID)
-        if not isForce and max([pack.CurValue, pack.GotValue, pack.ItemAwardState]) == 0:
+        pack.State = GetIsActiveMWSoul(curPlayer, priID)
+        if not isForce and max([pack.CurValue, pack.GotValue, pack.ItemAwardState, pack.State]) == 0:
             continue
         pack.PriID = priID
         sendPack.InfoList.append(pack)
@@ -955,4 +1105,116 @@
 def SetMagicWeaponClickState(curPlayer, mwID, state=1):
     #设置法宝是否点击认主状态
     GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_MagicWeaponIsClick, mwID % 100, state, True, [mwID / 100])
+    return
+
+#// A5 1D 法宝佩戴 #tagCMWearMagicWeapon
+#
+#struct    tagCMWearMagicWeapon
+#
+#{
+#    tagHead        Head;
+#    DWORD        MWID;    //法宝ID
+#    BYTE        State;        //0-卸下 1-佩戴
+#};
+def OnWearMagicWeapon(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    mwID = clientData.MWID
+    if not GetIsActiveMagicWeapon(curPlayer, mwID):
+        return
+    isWear = clientData.State
+    if isWear:
+        maxCnt = IpyGameDataPY.GetFuncCfg('MagicWeaponOfKing', 2)
+        hasWearCnt = 0
+        for mid in IpyGameDataPY.GetFuncEvalCfg('MagicWeaponOfKing', 1, {}):
+            if hasWearCnt >= maxCnt:
+                return
+            if GetIsWearMagicWeapon(curPlayer, mid):
+                hasWearCnt +=1
+                
+    SetMagicWeaponWearState(curPlayer, mwID, isWear)
+    CalcMagicWeaponAttr(curPlayer)
+    PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
+    Sycn_MagicWeaponLV(curPlayer, mwID)
+    return
+
+def GetIsWearMagicWeapon(curPlayer, mwID):
+    #获取法宝是否佩戴
+    return GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_MagicWeaponIsWear, mwID % 100, True, [mwID / 100])
+
+def SetMagicWeaponWearState(curPlayer, mwID, state):
+    #设置法宝是否佩戴
+    GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_MagicWeaponIsWear, mwID % 100, state, True, [mwID / 100])
+    return
+
+#// A5 12 激活法宝之魂 #tagCMActiveMWSoul
+#
+#struct    tagCMActiveMWSoul
+#
+#{
+#    tagHead        Head;
+#    BYTE        ID;    //编号
+#};
+def OnActiveMWSoul(index, clientData, tick):
+    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
+    soulID = clientData.ID
+    ipyData = IpyGameDataPY.GetIpyGameData('TreasurePrivilege', soulID)
+    if not ipyData:
+        return
+    if GetIsActiveMWSoul(curPlayer, soulID):
+        GameWorld.Log('    该法宝之魂已经激活!! soulID=%s'%soulID)
+        return
+    #检查成就
+    succList = ipyData.GetSuccessList()
+    for succID in succList:
+        if not PlayerSuccess.GetSuccHasGot(curPlayer, succID):
+            GameWorld.DebugLog('    激活法宝之魂 成就未完成  soulID=%s,succID=%s'%(soulID, succID))
+            return
+    
+    __DoActiveMWSoul(curPlayer, soulID)
+    return
+
+def __DoActiveMWSoul(curPlayer, soulID, isRefreshAttr=True):
+    GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_MWSoulActiveState, soulID, 1, True)
+    #任务
+    EventShell.EventRespons_MWSoulActive(curPlayer, soulID)
+    
+    CalcMagicWeaponSoulAttr(curPlayer)
+    if isRefreshAttr:
+        PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
+    
+    #通知
+    Sycn_MWPrivilegeData(curPlayer, soulID)
+    return
+
+
+def GetIsActiveMWSoul(curPlayer, soulID):
+    #获取法宝之魂是否已激活
+    return GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_MWSoulActiveState, soulID)
+
+def CalcMagicWeaponSoulAttr(curPlayer):
+    #法宝之魂属性刷新
+    allAttrList = [{} for _ in range(4)]
+    allAttrDict = {}
+    ipyMgr = IpyGameDataPY.IPY_Data()
+    for i in xrange(ipyMgr.GetTreasurePrivilegeCount()):
+        ipyData = ipyMgr.GetTreasurePrivilegeByIndex(i)
+        soulID = ipyData.GetPrivilegeID()
+        if not GetIsActiveMWSoul(curPlayer, soulID):
+            continue
+        attrDict = GetMagicWeaponPrivilegeAttr(curPlayer, soulID)
+        GameWorld.AddDictValue(allAttrDict, attrDict)
+        
+    for attrID, attrValue in allAttrDict.items():
+        PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
+    PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_MagicWeaponSoul, allAttrList)
+    return
+
+def UptateMWFBPasslv(curPlayer, mwID, passLV):
+    GameWorld.Log('更新关卡 mwID=%s,level=%s'%(mwID, passLV), curPlayer.GetID())
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MWFBPassLevel % mwID, passLV)
+    CalcMagicWeaponAttr(curPlayer)
+    PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
+    Sycn_MagicWeaponLV(curPlayer, mwID)
+    
+    EventShell.EventRespons_MagicWeaponFBPassLV(curPlayer, mwID, passLV)
     return
\ No newline at end of file

--
Gitblit v1.8.0