hxp
2020-03-11 eda67261f401cc667834c73bdffec1e11319f47a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Event.EventSrc.Operate_EquipEvolve
#
# @todo:×°±¸Éñ×°½ø½×
# @author hxp
# @date 2019-10-07
# @version 1.0
#
# ÏêϸÃèÊö: ×°±¸Éñ×°½ø½×
#
#-------------------------------------------------------------------------------
#"""Version = 2019-10-07 19:00"""
#-------------------------------------------------------------------------------
 
import GameWorld
import ItemCommon
import IPY_GameWorld
import PlayerControl
import IpyGameDataPY
import ItemControler
import ShareDefine
import ChConfig
import ChEquip
 
 
#// A3 30 ×°±¸Éñ×°½ø½× #tagCMEquipEvolve
#
#struct    tagCMEquipEvolve
#{
#    tagHead        Head;
#    BYTE        EquipIndex;    // Òª½ø½×µÄ×°±¸ÔÚ×°±¸±³°üÖÐË÷Òý
#    BYTE        NeedEquipIDIndex;        // ËùÐè¹Ì¶¨×°±¸BÔÚ±³°üÖÐË÷Òý
#    BYTE        NeedItemIDIndexCnt;    // ¸½¼Ó²ÄÁÏÔÚ±³°üÖÐË÷Òý¸öÊý
#    BYTE        NeedItemIDIndex[NeedItemIDIndexCnt];    // ¸½¼Ó²ÄÁÏÔÚ±³°üµÄË÷ÒýÁбí
#    BYTE        NeedSuitIndexCnt;    // ËùÐèÌ××°²ÄÁÏÔÚ±³°üÖÐË÷Òý¸öÊý
#    BYTE        NeedSuitIndex[NeedSuitIndexCnt];    // ËùÐèÌ××°²ÄÁÏÔÚ±³°üµÄË÷ÒýÁбí
#};
def OnEquipWashEvolve(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    equipIndex = clientData.EquipIndex
    needEquipIDIndex = clientData.NeedEquipIDIndex
    needItemIDIndexList = clientData.NeedItemIDIndex
    needSuitIndexList = clientData.NeedSuitIndex
    
    equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    curEquip = equipPack.GetAt(equipIndex)
    if not ItemCommon.CheckItemCanUse(curEquip):
        return
    equipItemID = curEquip.GetItemTypeID()
    equipClassLV = ItemCommon.GetItemClassLV(curEquip)
    ipyData = IpyGameDataPY.GetIpyGameData("EquipShenEvolve", equipItemID)
    if not ipyData:
        return
    evolveEquipID = ipyData.GetEvolveEquipID()
    needItemIDInfo = ipyData.GetEvolveNeedItemIDInfo()
    needSuitCount = ipyData.GetEvolveNeedSuitCount()
    needEquipID = ipyData.GetEvolveNeedEquipID()
    
    evolveEquipItemData = GameWorld.GetGameData().GetItemByTypeID(evolveEquipID)
    if not evolveEquipItemData:
        return
    
    # ÑéÖ¤ËùÐè²ÄÁÏ
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    needItemCount = 0
    if needItemIDInfo:
        needItemCount = __CheckNeedItem(curPlayer, needItemIDInfo, needItemIDIndexList, itemPack)
        if needItemCount == None:
            return
        
    if needSuitCount:
        if not __CheckNeedSuitEquip(curPlayer, needSuitCount, equipClassLV, needSuitIndexList, itemPack):
            return
        
    if needEquipID:
        if not __CheckNeedEquipID(curPlayer, needEquipID, needEquipIDIndex, itemPack):
            return
        
    drDict = {"equipItemID":equipItemID, "evolveEquipID":evolveEquipID}
    # ¿Û³ý²ÄÁÏ
    if needItemCount:
        ItemCommon.ReduceItem(curPlayer, itemPack, needItemIDIndexList, needItemCount, 
                              False, ChConfig.ItemDel_EquipEvolve, drDict)
    
    if needSuitCount:
        ItemCommon.ReduceItem(curPlayer, itemPack, needSuitIndexList, needSuitCount, 
                              False, ChConfig.ItemDel_EquipEvolve, drDict)
        
    if needEquipID:
        ItemCommon.ReduceItem(curPlayer, itemPack, [needEquipIDIndex], 1, 
                              False, ChConfig.ItemDel_EquipEvolve, drDict)
        
    # Ô­×°±¸Ìæ»»³É½ø½××°±¸
    evolveEquip = ItemControler.GetOutPutItemObj(evolveEquipID, curPlayer=curPlayer)
    if not evolveEquip:
        return
    curEquip.AssignItem(evolveEquip)
    curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitEquipEvolve, ChConfig.Def_ComposeState_Sucess)
    GameWorld.DebugLog("½ø½×Éñ×°³É¹¦! equipItemID=%s,evolveEquipID=%s" % (equipItemID, evolveEquipID), playerID)
    
    #Ë¢ÐÂÊôÐÔ
    ChEquip.RefreshPlayerEquipAttribute(curPlayer, equipClassLV)
    playControl = PlayerControl.PlayerControl(curPlayer)
    playControl.RefreshPlayerAttrState()
    return
 
def __CheckNeedItem(curPlayer, needItemIDInfo, needItemIDIndexList, itemPack):
    ## ¼ì²éËùÐè¶îÍâ²ÄÁÏÎïÆ·
    
    playerID = curPlayer.GetPlayerID()
    needItemID, needItemCount = needItemIDInfo
    maxPackCount = itemPack.GetCount()
    totalCount = 0
    for index in needItemIDIndexList:
        if index >= maxPackCount:
            GameWorld.DebugLog("¸ÃÎïÆ·²ÄÁϸñ×ÓË÷Òý²»´æÔÚ!ÎÞ·¨½ø½×£¡index=%s,maxPackCount=%s" 
                               % (index, maxPackCount), playerID)
            return
        curItem = itemPack.GetAt(index)
        if not ItemCommon.CheckItemCanUse(curItem):
            GameWorld.DebugLog("¸ÃÎïÆ·²ÄÁϲ»¿ÉʹÓÃ!ÎÞ·¨½ø½×! index=%s" % (index), playerID)
            return
        itemID = curItem.GetItemTypeID()
        if itemID != needItemID:
            GameWorld.DebugLog("¸ÃÎïÆ·²ÄÁϲ»¿ÉÓÃÓÚ½ø½×!index=%s,itemID=%s != needItemID=%s" 
                               % (index, itemID, needItemID), playerID)
            return
        totalCount += curItem.GetCount()
        
    if totalCount < needItemCount:
        GameWorld.DebugLog("ËùÐè¶îÍâ²ÄÁϸöÊý²»×㣬ÎÞ·¨½ø½×! needItemIDIndexList=%s,totalCount=%s < needItemCount=%s" 
                               % (needItemIDIndexList, totalCount, needItemCount), playerID)
        return
    
    return needItemCount
 
 
def __CheckNeedSuitEquip(curPlayer, needSuitCount, equipClassLV, needSuitIndexList, itemPack):
    ## ¼ì²éËùÐèÌ××°²ÄÁÏ
    
    playerID = curPlayer.GetPlayerID()
    maxPackCount = itemPack.GetCount()
    totalCount = 0
    for index in needSuitIndexList:
        if index >= maxPackCount:
            GameWorld.DebugLog("¸ÃÌ××°¸ñ×ÓË÷Òý²»´æÔÚ!ÎÞ·¨½ø½×£¡index=%s,maxPackCount=%s" 
                               % (index, maxPackCount), playerID)
            return
        curItem = itemPack.GetAt(index)
        if not ItemCommon.CheckItemCanUse(curItem):
            GameWorld.DebugLog("¸ÃÌ××°²»¿ÉʹÓÃ!ÎÞ·¨½ø½×! index=%s" % (index), playerID)
            return
        classLV = ItemCommon.GetItemClassLV(curItem)
        if classLV != equipClassLV:
            GameWorld.DebugLog("¸ÃÌ××°²ÄÁϽײ»Ïàͬ£¬²»¿ÉÓÃÓÚ½ø½×!index=%s,classLV=%s != equipClassLV=%s" 
                               % (index, classLV, equipClassLV), playerID)
            return
        color = curItem.GetItemColor()
        if color != ChConfig.Def_Quality_Orange:
            GameWorld.DebugLog("¸ÃÌ××°²ÄÁϷdzÈ×°£¬²»¿ÉÓÃÓÚ½ø½×!index=%s,color=%s" % (index, color), playerID)
            return
        suieID = curItem.GetSuiteID()
        if not suieID:
            GameWorld.DebugLog("¸ÃÌ××°²ÄÁÏ·ÇÌ××°×°±¸£¬²»¿ÉÓÃÓÚ½ø½×!index=%s,suieID=%s" % (index, suieID), playerID)
            return
        if not ItemCommon.CheckJob(curPlayer, curItem):
            GameWorld.DebugLog("¸ÃÌ××°²ÄÁϷDZ¾Ö°Òµ£¬²»¿ÉÓÃÓÚ½ø½×!index=%s" % (index), playerID)
            return
        totalCount += 1
        
    if totalCount < needSuitCount:
        GameWorld.DebugLog("ËùÐèÌ××°¸öÊý²»×㣬ÎÞ·¨½ø½×! needSuitIndexList=%s,totalCount=%s < needSuitCount=%s" 
                               % (needSuitIndexList, totalCount, needSuitCount), playerID)
        return
    
    return True
 
def __CheckNeedEquipID(curPlayer, needEquipID, needEquipIDIndex, itemPack):
    ## ¼ì²éËùÐè¶îÍâ×°±¸
    
    playerID = curPlayer.GetPlayerID()
    maxPackCount = itemPack.GetCount()
    if needEquipIDIndex >= maxPackCount:
        GameWorld.DebugLog("¸Ã¶îÍâ×°±¸Ë÷Òý²»´æÔÚ!ÎÞ·¨½ø½×£¡needEquipIDIndex=%s,maxPackCount=%s" 
                           % (needEquipIDIndex, maxPackCount), playerID)
        return
    curItem = itemPack.GetAt(needEquipIDIndex)
    if not ItemCommon.CheckItemCanUse(curItem):
        GameWorld.DebugLog("¸Ã¶îÍâ×°±¸²»¿ÉʹÓÃ!ÎÞ·¨½ø½×! needEquipIDIndex=%s" % (needEquipIDIndex), playerID)
        return
    itemID = curItem.GetItemTypeID()
    if itemID != needEquipID:
        GameWorld.DebugLog("¸Ã¶îÍâ×°±¸ID´íÎ󣬲»¿ÉÓÃÓÚ½ø½×!needEquipIDIndex=%s,itemID=%s != needEquipID=%s" 
                           % (needEquipIDIndex, itemID, needEquipID), playerID)
        return
    
    return True