xdh
2019-05-31 a69e35d211da29d739187385383741ba34202c08
7034 【后端】【2.0】宝石合成
1个文件已修改
89 ■■■■ 已修改文件
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_EquipStone.py 89 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Event/EventSrc/Operate_EquipStone.py
@@ -31,9 +31,11 @@
import PlayerWeekParty
import ShareDefine
import EventShell
#import EquipZhuXian
g_stoneCanPlaceList = [] #可镶嵌的位置
#def OnLogin(curPlayer):
#    ###登录发包同步客户端宝石信息
@@ -62,6 +64,7 @@
                    g_stoneCanPlaceList.append(gridIndex)
    return g_stoneCanPlaceList
def GetAllEquipPlaceHoleIndex():
    ### 得到装备位所有孔位
    gemOpenNeedStarList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1)
@@ -72,6 +75,7 @@
    
    return range(maxEquipHoleCnt) + range(ChConfig.Def_Stone_VipHole, ChConfig.Def_Stone_VipHole + maxHoleVipCnt)
def GetEquipIndexStoneIDList(curPlayer, equipIndex):
    ### 装备位孔位宝石ID列表
    
@@ -81,6 +85,7 @@
        stoneID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex) [0]
        holeStoneIDList.append(stoneID)
    return holeStoneIDList
def GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex):
    '''获得装备位孔位宝石ID和绑定信息
@@ -93,6 +98,7 @@
    #获取装备位孔位上宝石是否绑定状态
    stoneIsBind = stoneInfo % ChConfig.Def_Stone_SaveStoneInfoXNumber   
    return stoneID, stoneIsBind
def SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, changeStoneID, isBind):
    ### 保存装备位孔位宝石ID和绑定信息
@@ -119,9 +125,11 @@
    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"
    GameWorld.DebugLog(
        "设置宝石等级: equipIndex=%s,holeIndex=%s,befStoneLV=%s,aftStoneLV=%s,befTotalStoneLV=%s,updTotalStoneLV=%s"
                       % (equipIndex, holeIndex, befStoneLV, aftStoneLV, befTotalStoneLV, updTotalStoneLV))
    return
def GetPackTypeByEquipPlace(equipPlace):
    ##目前支持镶嵌普通装备、诛仙装备
@@ -134,6 +142,7 @@
    stonePackType = IPY_GameWorld.rptItem
    placeIndex = equipPlace
    return equipPackType, stonePackType, placeIndex
#//A3 04 宝石镶嵌或替换 #tagCMEquipEnchase
#struct    tagCMEquipEnchase
@@ -152,7 +161,8 @@
    stoneIndex = clientData.StoneIndex
    holeIndex = clientData.HoleIndex
    
    GameWorld.DebugLog("宝石镶嵌: equipPackIndex=%s,stoneIndex=%s,holeIndex=%s" % (equipPackIndex, stoneIndex, holeIndex), playerID)
    GameWorld.DebugLog("宝石镶嵌: equipPackIndex=%s,stoneIndex=%s,holeIndex=%s" % (equipPackIndex, stoneIndex, holeIndex),
                       playerID)
    equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex)
    
    #获得装备位装备实例
@@ -196,7 +206,8 @@
        return
    
    # 扣除宝石
    ItemCommon.DelItem(curPlayer, curStone, 1, True, ChConfig.ItemDel_EquipEnchase, {"equipPackIndex":equipPackIndex, "HoleIndex":holeIndex})
    ItemCommon.DelItem(curPlayer, curStone, 1, True, ChConfig.ItemDel_EquipEnchase,
                       {"equipPackIndex": equipPackIndex, "HoleIndex": holeIndex})
    
    isBind = 1 if isBind else 0
    
@@ -217,6 +228,7 @@
    
    EventShell.EventRespons_InlayStone(curPlayer)
    return
def DoStoneSuccess(curPlayer):
    PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayStone1)
@@ -252,6 +264,7 @@
    PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_StoneTotalLV, totalStoneLV)
    PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Stone, totalStoneLV, False, True)
    return
#//A3 05 宝石摘取 #tagCMEquipStonePick
#struct    tagCMEquipStonePick
@@ -307,9 +320,11 @@
    PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Stone, totalStoneLV, False, True)
    return
def GetTotalStoneLV(curPlayer):
    ##宝石总等级
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalStoneLV)
def GetStoneCntByLV(curPlayer, stoneLV):
    ##指定等级的宝石数量
@@ -329,6 +344,7 @@
            if gemLV >= stoneLV:
                cnt += 1
    return cnt
#// A3 06 宝石升级 #tagCMEquipStoneUpgrade
#struct    tagCMEquipStoneUpgrade
@@ -385,6 +401,8 @@
    ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex':equipPackIndex})
    if not ipyData:
        return
    # 额外材料
    extraItemInfoDict = IpyGameDataPY.GetFuncEvalCfg("GemUpCostFormula", 3, {})
    classLV = ipyData.GetClassLV()
    if upWay == 0: #仙玉
        stoneTypeItemIDDict = IpyGameDataPY.GetFuncEvalCfg("GemUpCostFormula", 1)
@@ -396,30 +414,49 @@
            return
        costCount = pow(needCount, level - 1) * (needCount - 1)
        costGold = costCount * unitPrice
        # 额外材料
        costExtraItemDict = {}
        i, cnt =0, 1
        for lv in xrange(level+1, 1, -1):
            cnt =1 if i is 0 else pow(needCount, i-1)
            i+=1
            extraItemInfo = extraItemInfoDict.get(str(lv))
            if extraItemInfo:
                extraItemID, extraItemCnt = extraItemInfo
                extraItemPrice = ItemCommon.GetShopItemPrice(extraItemID, IPY_GameWorld.TYPE_Price_Gold_Money)
                if not extraItemPrice:
                    return
                costGold += extraItemPrice * extraItemCnt * cnt
                costExtraItemDict[extraItemID] = costExtraItemDict.get(extraItemID, 0) + extraItemCnt * cnt
        if costGold <= 0:
            return
        infoDict = {"StoneItemID":stoneItemID, "CurStoneIDLV":level, "UpgradeStoneID":upgradeStoneID, "CostCount":costCount, "UnitPrice":unitPrice}
        if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold, ChConfig.Def_Cost_EquipStone, infoDict):
        infoDict = {"StoneItemID": stoneItemID, "CurStoneIDLV": level, "UpgradeStoneID": upgradeStoneID,
                    "CostCount": costCount, "UnitPrice": unitPrice, 'costExtraItemDict':costExtraItemDict}
        if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold,
                                      ChConfig.Def_Cost_EquipStone, infoDict):
            GameWorld.DebugLog("仙玉不足!costGold=%s" % costGold)
            return
    else:
        #同级宝石
        costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, stoneItemID, packType=stonePackType)
        if bindCnt + unBindCnt < needCount-1:
            GameWorld.DebugLog("同级宝石不足 %s!" % (needCount-1))
            return
        if stoneIsBind:
            costIndexList = (costItemIndexList[0]+costItemIndexList[1])[:2]
        else:
            costIndexList = (costItemIndexList[1]+costItemIndexList[0])[:2]
        costItemDict = {stoneItemID:needCount - 1}
        if str(level + 1) in extraItemInfoDict:
            extraItemID, extraItemCnt = extraItemInfoDict[str(level + 1)]
            costItemDict[extraItemID] = extraItemCnt
        itemPack = curPlayer.GetItemManager().GetPack(stonePackType)
        hasBind = ItemCommon.ReduceItem(curPlayer, itemPack, costIndexList, needCount-1, False, ChConfig.ItemDel_StoneUpgrade,
        delItemList = []
        for itemID, itemCnt in costItemDict.items():
            hasEnough, itemIndexList = ItemCommon.GetItem_FromPack_ByID(itemID, itemPack, itemCnt)
            if not hasEnough:
                GameWorld.DebugLog("材料不足 itemID=%s!,needCnt=%s" % (itemID, itemCnt))
                return
            delItemList.append([itemIndexList, itemCnt])
        for delItemIndexList, delCnt in delItemList:
            ItemCommon.ReduceItem(curPlayer, itemPack, delItemIndexList, delCnt, False,
                                  ChConfig.ItemDel_StoneUpgrade,
                                        {"equipPackIndex":equipPackIndex, "HoleIndex":holeIndex})
        if hasBind:
            stoneIsBind = True
        
    
    __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, upgradeStoneID, stoneIsBind, "StoneUpgrade", False)
    __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, upgradeStoneID, False, "StoneUpgrade", False)
    
    # 刷新属性
    RefreshAttrByStoneAction(curPlayer, equipPackType, False, classLV)
@@ -477,6 +514,7 @@
    
    return True
def __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, changeStoneID, isBind, eventName, isPickoff):
    ## 变更玩家装备孔宝石
    
@@ -492,11 +530,14 @@
        if ItemCommon.CheckPackHasSpace(curPlayer, stonePackType):
            ItemControler.GivePlayerItem(curPlayer, stoneID, itemCount, 0,
                                         [stonePackType], 
                                         event=[ChConfig.ItemGive_StonePickoff, False, {"equipPackIndex":equipPackIndex, "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, {'equipPackIndex':equipPackIndex,"holeIndex":holeIndex, "stoneID":stoneID, 'changeStoneID':changeStoneID})
    DataRecordPack.DR_StoneItemChange(curPlayer, eventName,
                                      {'equipPackIndex': equipPackIndex, "holeIndex": holeIndex, "stoneID": stoneID,
                                       'changeStoneID': changeStoneID})
    EventShell.EventRespons_StoneChange(curPlayer)
    return
@@ -564,10 +605,12 @@
    __DoSysPickoffEquipStone(curPlayer, equipPackType, stonePackType, pickoffHoleList, "EquipChange", False)
    return
def OnVIPTimeOut(curPlayer):
    ## VIP到期处理
    #过期一样有效,屏蔽该逻辑
    return  
def __DoSysPickoffEquipStone(curPlayer, equipPackType, stonePackType, pickoffHoleList, eventName, isRefreshAttr):
    ## 系统摘除宝石
@@ -592,7 +635,9 @@
            stoneInfo = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)
            mailItemInfoList.append([stoneInfo[0], 1, stoneInfo[1]])
            SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, 0, 0)
            DataRecordPack.DR_StoneItemChange(curPlayer, eventName, {'changeStoneID':0,'equipIndex':equipIndex,"holeIndex":holeIndex, "stoneID":stoneInfo[0]})
            DataRecordPack.DR_StoneItemChange(curPlayer, eventName,
                                              {'changeStoneID': 0, 'equipIndex': equipIndex, "holeIndex": holeIndex,
                                               "stoneID": stoneInfo[0]})
            if equipIndex not in equipIndexList:
                equipIndexList.append(equipIndex)
        PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], mailItemInfoList)
@@ -604,6 +649,7 @@
    if equipIndexList:
        Sycn_StoneHoleInfo(curPlayer, equipIndexList)
    return
def Sycn_StoneHoleInfo(curPlayer, equipIndexList=[]):
    ###同步客户端宝石信息
@@ -629,4 +675,3 @@
    sendPack.EquipCount = len(sendPack.InfoList)  
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    return