From 297de92ab4234a2ec6c84a0b93861a41bc71d1b3 Mon Sep 17 00:00:00 2001
From: xdh <xiefantasy@qq.com>
Date: 星期一, 12 十一月 2018 17:07:58 +0800
Subject: [PATCH] 4631 【后端】【1.3.0】上古战场增加机器人投放、分线逻辑优化

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMagicWeapon.py |  147 +++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 119 insertions(+), 28 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 d4e1e9b..3912890 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMagicWeapon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerMagicWeapon.py
@@ -36,6 +36,8 @@
 import ChEquip
 import PlayerVip
 
+import random
+
 g_succInfoDict = {}
 g_potentialsSkillDict = {}
 ##登录处理
@@ -157,6 +159,11 @@
     elif activeMWID:
         DoActiveMW(curPlayer, activeMWID)
     
+    #激活魂
+    activeSoulID = upIpyData.GetActiveSoulID()
+    if activeSoulID:
+        __DoActiveMWSoul(curPlayer, activeSoulID, False)
+    
     CalcMagicWeaponAttr(curPlayer)
     PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
     
@@ -220,9 +227,10 @@
             activeCnt += 1
     return activeCnt
 
-def GetPotentialsNextSkillID(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()
@@ -230,10 +238,31 @@
             ipyData = ipyDataMgr.GetTreasureByIndex(i)
             mwID = ipyData.GetID()
             skillIDList = ipyData.GetPotentials()
-            for i, curSkillID in enumerate(skillIDList):
-                nextSkillID = skillIDList[i+1] if i+1 < len(skillIDList) else 0
-                g_potentialsSkillDict[curSkillID] = nextSkillID
-    return g_potentialsSkillDict.get(skillID, 0)
+            addPowerList = ipyData.GetSkillPower()
+            lastSkillUseType = 0
+            for curSkillID in skillIDList:
+                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
@@ -360,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
@@ -385,22 +426,25 @@
                     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())
-    
-    #通知技能已升级成功
-    nextSkillID = GetPotentialsNextSkillID(skillTypeID)
-    if nextSkillID:
-        nextSkill = GameWorld.GetGameData().FindSkillByType(nextSkillID, 1)
-        if nextSkill and nextSkill.GetLearnSkillReq() == skillTypeID and upSkillLv == nextSkill.GetLearnSkillLV():
-            PlayerControl.WorldNotify(0, 'SkillPotential1', [curPlayer.GetName(), skillTypeID, upSkillLv, nextSkillID])
-                
-    maxLV = upSkill.GetSkillMaxLV()
-    if upSkillLv == maxLV:
-        PlayerControl.WorldNotify(0, 'SkillPotential3', [curPlayer.GetName(), skillTypeID, maxLV])
     
     #获得技能等级
     #curSkillLV = curSkill.GetSkillLV()
@@ -409,12 +453,21 @@
     
     curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitMagicWeaponSkillUp, 1)
     
-    SetMWPrivilegeData(curPlayer, ChConfig.MWPrivilege_MWSkillUp, 1, True)
+    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):
     #通知法宝信息
@@ -447,7 +500,7 @@
     allAttrList1 = [{} for _ in range(4)] #人族法宝
     allAttrList2 = [{} for _ in range(4)] #魔族法宝
     allAttrList3 = [{} for _ in range(4)] #仙族法宝
-    
+
     signDayMWID = IpyGameDataPY.GetFuncCfg('MWSignDayAttr', 2)
     ipyDataMgr = IpyGameDataPY.IPY_Data()
     for i in xrange(ipyDataMgr.GetTreasureCount()):
@@ -465,7 +518,7 @@
         #    attrDict = refineipyData.GetTreasureAttr()
         #    GameWorld.AddDictValue(allAttrDict, attrDict)
         #=======================================================================
-            
+        treasureType = treasureIpyData.GetTreasureType()
         #等级属性
         curMWLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponLV % magicWeaponID)
         for lv in xrange(curMWLV+1):
@@ -473,6 +526,7 @@
             if upIpyData:
                 attrDict = upIpyData.GetAddAttr()
                 GameWorld.AddDictValue(allAttrDict, attrDict)
+                
         if magicWeaponID == signDayMWID:
             #签到属性
             totalSignNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalSignNum) # 总签到天数
@@ -481,7 +535,7 @@
                 addAttr[int(attid)] = attnum * totalSignNum
             GameWorld.AddDictValue(allAttrDict, addAttr)
         
-        treasureType = treasureIpyData.GetTreasureType()
+        
         for effID, value in allAttrDict.items():
             if treasureType == 1:
                 PlayerControl.CalcAttrDict_Type(effID, value, allAttrList1)
@@ -492,9 +546,27 @@
             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)
+    #技能解锁战力
+    nextSkillDict = GetPotentialsSkillInfo(curPlayer)
+    addPowerDict = {}
+    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
@@ -668,6 +740,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():
@@ -675,7 +748,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
@@ -745,7 +822,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()
@@ -862,6 +939,9 @@
         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
@@ -893,14 +973,19 @@
         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)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MWSoulGotValue % privilege, min(maxValue, gotValue+canGetCnt*singleValue))
         CalcMagicWeaponSoulAttr(curPlayer)
         PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
         
@@ -999,17 +1084,23 @@
             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)
-    PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
+    if isRefreshAttr:
+        PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
     
     #通知
     Sycn_MWPrivilegeData(curPlayer, soulID)
     return
 
+
 def GetIsActiveMWSoul(curPlayer, soulID):
     #获取法宝之魂是否已激活
     return GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_MWSoulActiveState, soulID)

--
Gitblit v1.8.0