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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
##@package ChEquip
# ×°±¸Âß¼­´¦Àí
#
# @author alee
# @date 2017-07-29 00:30
# @version 1.0
#
# ÐÞ¸Äʱ¼ä ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
#------------------------------------------------------------------------------ 
#"""Version = 2017-07-29 00:30"""
#------------------------------------------------------------------------------ 
import IPY_GameWorld
import GameWorld
import ChConfig
import ShareDefine
import IpyGameDataPY
import PlayerOnline
 
def RefreshRoleEquipAttr(curPlayer):
    ## Ë¢ÐÂÖ÷¹«×°±¸ÊôÐÔ
    CalcRoleEquipAttr(curPlayer)
    PlayerOnline.GetOnlinePlayer(curPlayer).RefreshRoleAttr()
    return
 
def CalcRoleEquipAttr(curPlayer):
    ## ¼ÆËãÖ÷¹«×°±¸ÊôÐÔ
    playerID = curPlayer.GetPlayerID()
    mainEquipAttrDict = {}
    
    packType = IPY_GameWorld.rptEquip
    equipPack = curPlayer.GetItemManager().GetPack(packType)
    
    # Ö÷×°±¸
    for equipPlace in ChConfig.Def_MainEquipPlaces:
        equipIndex = equipPlace - 1
        if equipIndex < 0 or equipIndex >= equipPack.GetCount():
            continue
        curEquip = equipPack.GetAt(equipIndex)
        if not curEquip or curEquip.IsEmpty():
            continue
        #itemColor = curEquip.GetItemColor()
        
        baseAttrIDCnt = curEquip.GetUserAttrCount(ShareDefine.Def_IudetBaseAttrID)
        baseAttrValueCnt = curEquip.GetUserAttrCount(ShareDefine.Def_IudetBaseAttrValue)
        if baseAttrIDCnt == baseAttrValueCnt:
            for i in xrange(baseAttrIDCnt):
                attrID = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetBaseAttrID, i)
                attrValue = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetBaseAttrValue, i)
                mainEquipAttrDict[attrID] = mainEquipAttrDict.get(attrID, 0) + attrValue
                
        legendAttrIDCnt = curEquip.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrID)
        legendAttrValueCnt = curEquip.GetUserAttrCount(ShareDefine.Def_IudetLegendAttrValue)
        if legendAttrIDCnt == legendAttrValueCnt:
            for i in xrange(legendAttrIDCnt):
                attrID = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrID, i)
                attrValue = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetLegendAttrValue, i)
                mainEquipAttrDict[attrID] = mainEquipAttrDict.get(attrID, 0) + attrValue
                
    GameWorld.DebugLog("Ö÷Ïß×°±¸ÊôÐÔ: %s" % mainEquipAttrDict, playerID)
    PlayerOnline.GetOnlinePlayer(curPlayer).SetCalcAttr(ChConfig.Def_CalcAttr_MainEquip, mainEquipAttrDict)
    return
 
#// A3 18 ÁéÆ÷Í»ÆÆ #tagCMLingQiEquipBreak
#
#struct    tagCMLingQiEquipBreak
#{
#    tagHead        Head;
#    DWORD        ItemID;  //Í»ÆÆµÄÎïÆ·ID
#}; 
def OnLingQiEquipBreak(index, clientData, tick):
    return
 
#// A3 27 ÁéÆ÷ÅàÑø #tagCMLingQiTrain
#
#struct    tagCMLingQiTrain
#{
#    tagHead        Head;
#    BYTE        EquipPlace;        //ÁéÆ÷×°±¸Î»
#    BYTE        TrainType;        //ÅàÑøÀàÐÍ£º 1-»ù´¡ÅàÑø£¬2-ÌØÊâÅàÑø£¬3-°Ù·Ö±ÈÅàÑø
#    WORD        UseItemCnt;        //ÏûºÄ²ÄÁϸöÊý
#};
def OnLingQiTrain(index, clientData, tick):
    return
 
def RefreshPlayerLingQiEquipAttr(curPlayer):
    ''' Ë¢ÐÂÍæ¼ÒÁéÆ÷×°±¸ÊôÐÔ
    '''
    return
 
def CalcAttr_LegendAttr(curPlayer, curEquip, allAttrListEquip, legendAttrDict={}):
    ## ¼ÆËã´«ÆæÊôÐÔ
    return
 
#// A5 C6 ×°±¸²¿Î»ÐǼ¶Ì××°¼¤»î #tagCMEquipPartSuiteActivate
#
#struct    tagCMEquipPartSuiteActivate
#{
#    tagHead        Head;
#    BYTE    ClassLV;    // ËùÊô×°±¸½×
#    WORD    SuiteID;    // Ì××°ID
#    BYTE    SuiteCount;    // ¼þÊý
#    BYTE    Star;    // ÐÇÊý
#};
def OnEquipPartSuiteActivate(index, clientData, tick):
    return
 
def ChangeEquipfacadeByHorsePetSkin(curPlayer, skinType, skinIndex):
    ##Æï³è¾õÐÑÍâ¹Û±ä¸ü  Áé³èÍâ¹ÛË÷Òý*10000000+×øÆïÍâ¹ÛË÷Òý*1000000+Áé¸ùÌØÐ§±íkey * 1000+µÚ¼¸Ì×*10+ÊÇ·ñÓÐÌ××°
    oldEquipShowSwitch = curPlayer.GetEquipShowSwitch()
    if skinType == 1:
        updEquipShowSwitch = GameWorld.ChangeDataByDigitPlace(oldEquipShowSwitch, 7, skinIndex)
    else:
        updEquipShowSwitch = GameWorld.ChangeDataByDigitPlace(oldEquipShowSwitch, 8, skinIndex)
        
    if oldEquipShowSwitch == updEquipShowSwitch:
        return
    curPlayer.SetEquipShowSwitch(updEquipShowSwitch)
    return
 
def GetPlayerMaxEquipClassLV(curPlayer):
    ## »ñÈ¡Íæ¼Òµ±Ç°½âËøµÄ×°±¸½×
    key = "RealmEquipClassLVMap"
    RealmEquipClassLVMap = IpyGameDataPY.GetConfigEx(key)
    if not RealmEquipClassLVMap:
        RealmEquipClassLVMap = {}
        infoDict = {}
        ipyDataMgr = IpyGameDataPY.IPY_Data()
        for index in xrange(ipyDataMgr.GetEquipControlCount()):
            ipyData = ipyDataMgr.GetEquipControlByIndex(index)
            infoDict[ipyData.GetNeedRealmLV()] = ipyData.GetClassLV()
        needReamlLVList = infoDict.keys()
        needReamlLVList.sort() # ÉýÐòÅÅ
        for i, realmLV in enumerate(needReamlLVList):
            classLV = infoDict[realmLV]
            if i == len(needReamlLVList) - 1:
                RealmEquipClassLVMap[realmLV] = classLV
            if i == 0:
                continue
            else:
                preRealmLV = needReamlLVList[i - 1]
                preClassLV = infoDict[preRealmLV]
                for pRealmLV in range(preRealmLV, realmLV):
                    RealmEquipClassLVMap[pRealmLV] = preClassLV
        GameWorld.DebugLog("¼ÓÔØ¾³½ç¶ÔÓ¦¿ª·Å×î´ó×°±¸½×ÉèÖÃ: %s" % RealmEquipClassLVMap)
        IpyGameDataPY.SetConfigEx(key, RealmEquipClassLVMap)
        
    playerRealmLV = curPlayer.GetOfficialRank()
    if playerRealmLV in RealmEquipClassLVMap:
        return RealmEquipClassLVMap[playerRealmLV]
    
    maxRealmLV = max(RealmEquipClassLVMap)
    if playerRealmLV >= maxRealmLV:
        return RealmEquipClassLVMap[maxRealmLV]
    
    return 0
 
#  »ñÈ¡ÂúÌ××°»¯µÄ×îµÍ½×Êý£¬Èç5¼þÌ×£¬4¼þ5¼¶£¬1¼þ3¼¶£¬Ôò·µ»Ø3
def GetEquipSuitsLVByType(curPlayer, suitType, groupType):
    return 0