From 6fcf3513ccde191e067c8dfd8279cccedf95eb77 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 17 五月 2019 19:22:25 +0800
Subject: [PATCH] 6603 【后端】【2.0】增加新版的sp和被动技能 - 新版

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_EquipStone.py |  169 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 87 insertions(+), 82 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_EquipStone.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_EquipStone.py
index 45952d1..e34e150 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_EquipStone.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_EquipStone.py
@@ -30,14 +30,15 @@
 import PlayerSuccess
 import PlayerWeekParty
 import ShareDefine
-import EquipZhuXian
+import EventShell
+#import EquipZhuXian
 
 g_stoneCanPlaceList = [] #可镶嵌的位置
 
-def OnLogin(curPlayer):
-    ###登录发包同步客户端宝石信息
-    Sycn_StoneHoleInfo(curPlayer)
-    return
+#def OnLogin(curPlayer):
+#    ###登录发包同步客户端宝石信息
+#    Sycn_StoneHoleInfo(curPlayer)
+#    return
 
 def GetAllStoneEquipIndexList():
     ###得到所有可镶嵌宝石装备位列表
@@ -95,8 +96,31 @@
 
 def SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, changeStoneID, isBind):
     ### 保存装备位孔位宝石ID和绑定信息
+    befStoneID, befIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)
+    if befStoneID == changeStoneID and befIsBind == isBind:
+        return
+    
+    isBind = 0 #现绑定无用,默认存0
     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartStoneID % (equipIndex, holeIndex),
-                                       changeStoneID * ChConfig.Def_Stone_SaveStoneInfoXNumber + isBind) 
+                                       changeStoneID * ChConfig.Def_Stone_SaveStoneInfoXNumber + isBind)
+    
+    # 同步更新宝石总等级
+    gameData = GameWorld.GetGameData()
+    befStoneLV = 0
+    if befStoneID:
+        befGem = gameData.GetItemByTypeID(befStoneID)
+        befStoneLV = 0 if not befGem else befGem.GetEffectByIndex(0).GetEffectValue(1)
+        
+    aftStoneLV = 0
+    if changeStoneID:
+        aftGem = gameData.GetItemByTypeID(changeStoneID)
+        aftStoneLV = 0 if not aftGem else aftGem.GetEffectByIndex(0).GetEffectValue(1)
+        
+    befTotalStoneLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalStoneLV)
+    updTotalStoneLV = max(0, befTotalStoneLV + aftStoneLV - befStoneLV)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalStoneLV, updTotalStoneLV)
+    GameWorld.DebugLog("设置宝石等级: equipIndex=%s,holeIndex=%s,befStoneLV=%s,aftStoneLV=%s,befTotalStoneLV=%s,updTotalStoneLV=%s" 
+                       % (equipIndex, holeIndex, befStoneLV, aftStoneLV, befTotalStoneLV, updTotalStoneLV))
     return
 
 def GetPackTypeByEquipPlace(equipPlace):
@@ -124,12 +148,12 @@
     playerID = curPlayer.GetPlayerID()
     
     # 验证背包类型合法性
-    equipPlace = clientData.EquipIndex
+    equipPackIndex = clientData.EquipIndex
     stoneIndex = clientData.StoneIndex
     holeIndex = clientData.HoleIndex
     
-    GameWorld.DebugLog("宝石镶嵌: equipPlace=%s,stoneIndex=%s,holeIndex=%s" % (equipPlace, stoneIndex, holeIndex), playerID)
-    equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPlace)
+    GameWorld.DebugLog("宝石镶嵌: equipPackIndex=%s,stoneIndex=%s,holeIndex=%s" % (equipPackIndex, stoneIndex, holeIndex), playerID)
+    equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex)
     
     #获得装备位装备实例
     equipPack = curPlayer.GetItemManager().GetPack(equipPackType)
@@ -143,7 +167,7 @@
     itemPack = curPlayer.GetItemManager().GetPack(stonePackType)
     curStone = itemPack.GetAt(stoneIndex)
     
-    if not ItemCommon.CheckItemCanUse(curStone):
+    if not ItemCommon.CheckItemCanUse(curStone) or ItemControler.GetIsAuctionItem(curStone):
         GameWorld.Log("目标宝石为空或不可用,无法镶嵌!", playerID)
         return
     
@@ -158,35 +182,40 @@
     
     stoneEffType = curStoneEff.GetEffectValue(0)
     stoneCanPlaceList = IpyGameDataPY.GetFuncEvalCfg("GemType%s" % stoneEffType, 1)
-    
-    if equipPlace not in stoneCanPlaceList:
-        GameWorld.Log("该宝石不可镶嵌在该装备位!stoneItemID=%s,stoneEffType=%s,stoneCanPlaceList=%s,equipPlace=%s" 
-                      % (stoneItemID, stoneEffType, stoneCanPlaceList, equipPlace), playerID)
+    ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex':equipPackIndex})
+    if not ipyData:
+        return
+    classLV = ipyData.GetClassLV()
+    if ipyData.GetEquipPlace() not in stoneCanPlaceList:
+        GameWorld.Log("该宝石不可镶嵌在该装备位!stoneItemID=%s,stoneEffType=%s,stoneCanPlaceList=%s,equipPackIndex=%s" 
+                      % (stoneItemID, stoneEffType, stoneCanPlaceList, equipPackIndex), playerID)
         return
     
-    equipStar = ChEquip.GetEquipPartStar(curEquip)
+    equipStar = ChEquip.GetEquipPartStarByRank(curPlayer, placeIndex, curEquip)
     if not __CheckStoneHoleCanUse(curPlayer, equipStar, holeIndex, equipPackType):
         return
     
     # 扣除宝石
-    ItemCommon.DelItem(curPlayer, curStone, 1, True, ChConfig.ItemDel_EquipEnchase, {"EquipPlace":equipPlace, "HoleIndex":holeIndex})
+    ItemCommon.DelItem(curPlayer, curStone, 1, True, ChConfig.ItemDel_EquipEnchase, {"equipPackIndex":equipPackIndex, "HoleIndex":holeIndex})
     
     isBind = 1 if isBind else 0
     
     # 变更宝石孔宝石信息
-    __DoChangeEquipHoleStone(curPlayer, equipPlace, holeIndex, stoneItemID, isBind, "EquipStone", True)
+    __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, stoneItemID, isBind, "EquipStone", True)
     
 #    #镶嵌成功
 #    if not curEquip.GetIsBind():
 #        ItemControler.SetItemIsBind(curEquip, True)
     
     # 刷新属性
-    RefreshAttrByStoneAction(curPlayer, equipPackType, True)
+    RefreshAttrByStoneAction(curPlayer, equipPackType, True, classLV)
     
     #同步客户端
-    Sycn_StoneHoleInfo(curPlayer, [equipPlace])
+    Sycn_StoneHoleInfo(curPlayer, [equipPackIndex])
     #成就
     DoStoneSuccess(curPlayer)
+    
+    EventShell.EventRespons_InlayStone(curPlayer)
     return
 
 def DoStoneSuccess(curPlayer):
@@ -235,11 +264,11 @@
     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
     playerID = curPlayer.GetPlayerID()
     # 验证背包类型合法性
-    equipPlace = clientData.EquipIndex
+    equipPackIndex = clientData.EquipIndex
     holeIndex = clientData.HoleIndex
-    GameWorld.DebugLog("宝石摘除: equipPlace=%s,holeIndex=%s" % (equipPlace, holeIndex), playerID)
+    GameWorld.DebugLog("宝石摘除: equipPackIndex=%s,holeIndex=%s" % (equipPackIndex, holeIndex), playerID)
     
-    equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPlace)
+    equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex)
     #获得装备位装备实例
     equipPack = curPlayer.GetItemManager().GetPack(equipPackType)
     curEquip = equipPack.GetAt(placeIndex)
@@ -253,19 +282,24 @@
         return
     
     # 验证宝石
-    stoneID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPlace, holeIndex)[0]
+    stoneID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex)[0]
     
     if not stoneID:
         GameWorld.DebugLog("孔为空或不存在宝石!")
         return
     
-    __DoChangeEquipHoleStone(curPlayer, equipPlace, holeIndex, 0, 0, "StonePick", True)
+    ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex':equipPackIndex})
+    if not ipyData:
+        return
+    classLV = ipyData.GetClassLV()
+    
+    __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, 0, 0, "StonePick", True)
     
     # 刷新属性
-    RefreshAttrByStoneAction(curPlayer, equipPackType, False)
+    RefreshAttrByStoneAction(curPlayer, equipPackType, False, classLV)
     
     #同步客户端
-    Sycn_StoneHoleInfo(curPlayer, [equipPlace])
+    Sycn_StoneHoleInfo(curPlayer, [equipPackIndex])
     
     totalStoneLV = GetTotalStoneLV(curPlayer)
     # 记录开服活动宝石总等级
@@ -275,23 +309,7 @@
 
 def GetTotalStoneLV(curPlayer):
     ##宝石总等级
-    totalStoneLV = 0
-    holeIndexList = GetAllEquipPlaceHoleIndex()
-    gameData = GameWorld.GetGameData()
-    playerEquip = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
-    for equipIndex in xrange(playerEquip.GetCount()):
-        if equipIndex not in ShareDefine.RoleEquipType :
-            continue
-        for holeIndex in holeIndexList:
-            curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]
-            if curGemID == 0:
-                continue
-            curGem = gameData.GetItemByTypeID(curGemID)
-            if not curGem:
-                continue
-            gemLV = curGem.GetEffectByIndex(0).GetEffectValue(1)
-            totalStoneLV += gemLV
-    return totalStoneLV
+    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalStoneLV)
 
 #// A3 06 宝石升级 #tagCMEquipStoneUpgrade
 #struct    tagCMEquipStoneUpgrade
@@ -306,11 +324,11 @@
     playerID = curPlayer.GetPlayerID()
     
     # 验证背包类型合法性
-    equipPlace = clientData.EquipIndex
+    equipPackIndex = clientData.EquipIndex
     holeIndex = clientData.HoleIndex
     upWay = clientData.UpWay
-    GameWorld.DebugLog("宝石升级: equipPlace=%s,holeIndex=%s" % (equipPlace, holeIndex), playerID)
-    equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPlace)
+    GameWorld.DebugLog("宝石升级: equipPackIndex=%s,holeIndex=%s" % (equipPackIndex, holeIndex), playerID)
+    equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex)
     #获得装备位装备实例
     equipPack = curPlayer.GetItemManager().GetPack(equipPackType)
     curEquip = equipPack.GetAt(placeIndex)
@@ -320,7 +338,7 @@
         return
         
     #升级宝石ID
-    stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPlace, holeIndex)
+    stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex)
     if stoneID == 0:
         GameWorld.DebugLog("孔为空或不存在宝石!")      
         return      
@@ -345,6 +363,10 @@
     needCount = IpyGameDataPY.GetFuncCfg("GemUpCostFormula", 2) # 合成下一级所需宝石个数
     if not needCount:
         return
+    ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex':equipPackIndex})
+    if not ipyData:
+        return
+    classLV = ipyData.GetClassLV()
     if upWay == 0: #仙玉
         stoneTypeItemIDDict = IpyGameDataPY.GetFuncEvalCfg("GemUpCostFormula", 1)
         if stoneEffType not in stoneTypeItemIDDict:
@@ -373,18 +395,18 @@
             costIndexList = (costItemIndexList[1]+costItemIndexList[0])[:2]
         itemPack = curPlayer.GetItemManager().GetPack(stonePackType)
         hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, costIndexList, needCount-1, False, ChConfig.ItemDel_StoneUpgrade, 
-                                        {"EquipPlace":equipPlace, "HoleIndex":holeIndex})
+                                        {"equipPackIndex":equipPackIndex, "HoleIndex":holeIndex})
         if hasBind:
             stoneIsBind = True
         
     
-    __DoChangeEquipHoleStone(curPlayer, equipPlace, holeIndex, upgradeStoneID, stoneIsBind, "StoneUpgrade", False)
+    __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, upgradeStoneID, stoneIsBind, "StoneUpgrade", False)
     
     # 刷新属性
-    RefreshAttrByStoneAction(curPlayer, equipPackType, False)
+    RefreshAttrByStoneAction(curPlayer, equipPackType, False, classLV)
     
     #同步客户端
-    Sycn_StoneHoleInfo(curPlayer, [equipPlace])
+    Sycn_StoneHoleInfo(curPlayer, [equipPackIndex])
     
     DoStoneSuccess(curPlayer)
     return
@@ -436,43 +458,43 @@
     
     return True
 
-def __DoChangeEquipHoleStone(curPlayer, equipPlace, holeIndex, changeStoneID, isBind, eventName, isPickoff):
+def __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, changeStoneID, isBind, eventName, isPickoff):
     ## 变更玩家装备孔宝石
     
     #获得装备位孔索引宝石存储信息
-    stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPlace, holeIndex)
+    stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex)
     #保存装备位孔位上宝石ID和绑定状态
-    SetEquipIndexStoneIDAndIsBand(curPlayer, equipPlace, holeIndex, changeStoneID, isBind)
+    SetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex, changeStoneID, isBind)
     
     if isPickoff and stoneID:
-        equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPlace)
+        equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex)
         itemCount = 1
         # 摘除的宝石都绑定
         if ItemCommon.CheckPackHasSpace(curPlayer, stonePackType):
-            ItemControler.GivePlayerItem(curPlayer, stoneID, itemCount, True if stoneIsBind else False,
+            ItemControler.GivePlayerItem(curPlayer, stoneID, itemCount, 0,
                                          [stonePackType], 
-                                         event=[ChConfig.ItemGive_StonePickoff, False, {"EquipPlace":equipPlace, "HoleIndex":holeIndex}])
+                                         event=[ChConfig.ItemGive_StonePickoff, False, {"equipPackIndex":equipPackIndex, "HoleIndex":holeIndex}])
         else:
             PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], [[stoneID, 1, stoneIsBind]])
             
-    DataRecordPack.DR_StoneItemChange(curPlayer, eventName, {'equipPlace':equipPlace,"holeIndex":holeIndex, "stoneID":stoneID, 'changeStoneID':changeStoneID})    
+    DataRecordPack.DR_StoneItemChange(curPlayer, eventName, {'equipPackIndex':equipPackIndex,"holeIndex":holeIndex, "stoneID":stoneID, 'changeStoneID':changeStoneID})    
     return
 
 
-def RefreshAttrByStoneAction(curPlayer, packType, isNeedNotify):
+def RefreshAttrByStoneAction(curPlayer, packType, isNeedNotify, classLV):
     ## 宝石刷新属性
     # 装备等级改变,判断是否为玩家身上的装备,如果是的话刷新玩家属性
     if packType in [IPY_GameWorld.rptEquip]:
         #先刷装备BUFF 再计算属性
         if isNeedNotify:
             curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrActivatyNotify, ChConfig.Def_AttrActivatyNotify_Stone)
-        ChEquip.RefreshPlayerEquipAttribute(curPlayer)
+        ChEquip.RefreshPlayerEquipAttribute(curPlayer, classLV)
         
         #刷新所有属性
         playControl = PlayerControl.PlayerControl(curPlayer)
         playControl.RefreshPlayerAttrState()
-    elif packType == ShareDefine.rptZhuXianEquip:
-        EquipZhuXian.RefreshZhuXianAttr(curPlayer)
+    #elif packType == ShareDefine.rptZhuXianEquip:
+    #    EquipZhuXian.RefreshZhuXianAttr(curPlayer)
     return
 
 
@@ -525,24 +547,6 @@
 def OnVIPTimeOut(curPlayer):
     ## VIP到期处理
     #过期一样有效,屏蔽该逻辑
-    #===============================================================================================
-    # #获得vip等级孔信息
-    # gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)
-    # maxVipHoleCnt = len(gemOpenVipList)# 最大Vip开放孔数
-    # 
-    # #获得所有可镶嵌宝石装备位
-    # stoneCanPlaceList = GetAllStoneEquipIndexList()
-    # #需要拆卸宝石的孔列表
-    # pickoffHoleList = []
-    # for equipIndex in stoneCanPlaceList:
-    #    for holeIndex in xrange(ChConfig.Def_Stone_VipHole, ChConfig.Def_Stone_VipHole + maxVipHoleCnt):
-    #        stoneInfo = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)
-    #        if not stoneInfo[0]:
-    #            continue
-    #        pickoffHoleList.append([equipIndex, holeIndex])
-    #        
-    # __DoSysPickoffEquipStone(curPlayer, pickoffHoleList, "VIPChange", True)
-    #===============================================================================================
     return  
 
 def __DoSysPickoffEquipStone(curPlayer, equipPackType, stonePackType, pickoffHoleList, eventName, isRefreshAttr):
@@ -573,8 +577,9 @@
                 equipIndexList.append(equipIndex)
         PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], mailItemInfoList)
         
-    if isRefreshAttr:
-        RefreshAttrByStoneAction(curPlayer, equipPackType, False)
+    #目前只有脱装备会触发,暂时屏蔽,由脱装备触发刷属性
+    #if isRefreshAttr:
+    #    RefreshAttrByStoneAction(curPlayer, equipPackType, False)
     
     if equipIndexList:
         Sycn_StoneHoleInfo(curPlayer, equipIndexList)

--
Gitblit v1.8.0