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
#!/usr/bin/python
# -*- coding: GBK -*-
#
# @todo: µ±Ç°ÉñÊÞ£¨°üÀ¨×°±¸£©ÊôÐÔÏÈçÉúÃü£©+xx%£¬¿É¶àÅä
#
# @author: Alee
# @date 2018-1-20 ÏÂÎç02:50:26
# @version 1.0
#
# @note: 
#
#---------------------------------------------------------------------
#µ¼Èë
import ChConfig
import PlayerControl
import ShareDefine
import IpyGameDataPY
import PlayerDogz
import ChEquip
#---------------------------------------------------------------------
 
## buffÏßÐÔÔö¼ÓÊôÐÔ
#  @param defender Buff³ÐÊÜÕß
#  @param curEffect ¼¼ÄÜЧ¹û
#  @param calcDict ¼¼ÄÜЧ¹ûÀÛ¼Ó×ܱí
#  @return None
def OnCalcBuffEx(defender, curEffect, calcDict, curBuff):
    attrType = curEffect.GetEffectValue(1)
    attrList = GetTheDogzAttr(defender, curEffect.GetEffectValue(2))
    value = int(attrList[2].get(attrType, 0)*curEffect.GetEffectValue(0)*1.0/ChConfig.Def_MaxRateValue)
    
    calcDict[attrType] = calcDict.get(attrType, 0) + value
    
    return
 
 
## ·µ»ØbuffÀàÐÍ£¬ÏßÐÔÓë·ñ
#  @param 
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.  
def GetCalcType():
    return ChConfig.TYPE_Linear
 
# Ö¸¶¨ÉñÊÞÊôÐÔ
def GetTheDogzAttr(curPlayer, dogzID):
    allAttrList = [{} for _ in range(4)]
    
    dogzEquipPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptDogzEquip)
    equipPackCount = dogzEquipPack.GetCount()
    ipyData = IpyGameDataPY.GetIpyGameData("Dogz", dogzID)
    if not ipyData:
        return allAttrList
    
    # 1. »ù´¡ÊôÐÔ
    attrTypeList = ipyData.GetBaseAttrTypes()
    attrValueList = ipyData.GetBaseAttrValues()
    if attrTypeList and len(attrTypeList) == len(attrValueList):
        for attrIndex, baseAttrID in enumerate(attrTypeList):
            baseAttrValue = attrValueList[attrIndex]
            PlayerControl.CalcAttrDict_Type(baseAttrID, baseAttrValue, allAttrList)
            #GameWorld.DebugLog("    »ù´¡ÊôÐÔ: baseAttrID=%s,baseAttrValue=%s, %s" % (baseAttrID, baseAttrValue, allAttrList))
            
    # 2. ×°±¸ÊôÐÔ
    startIndex = (dogzID - 1) * PlayerDogz.DogzEquipCount
    for equipIndex in range(startIndex, startIndex + PlayerDogz.DogzEquipCount):
        if equipIndex < 0 or equipIndex >= equipPackCount:
            break
        curEquip = dogzEquipPack.GetAt(equipIndex)            
        if curEquip.IsEmpty():
            continue
        
        #itemID = curEquip.GetItemTypeID()
        # ×°±¸»ù´¡ÊôÐÔ
        for effIndex in xrange(curEquip.GetEffectCount()):
            curEffect = curEquip.GetEffectByIndex(effIndex)
            if not curEffect or not curEffect.GetEffectID():
                break
            effID = curEffect.GetEffectID()
            if not effID or effID == ChConfig.Def_Effect_DogzEquipPlusExp:
                continue
            effValue = curEffect.GetEffectValue(0)
            PlayerControl.CalcAttrDict_Type(effID, effValue, allAttrList)
            #GameWorld.DebugLog("    ×°±¸»ù´¡: itemID=%s,effID=%s,effValue=%s, %s" % (itemID, effID, effValue, allAttrList))
            
        # Ç¿»¯ÊôÐÔ
        curPlusLV = curEquip.GetUserAttrByIndex(ShareDefine.Def_IudetDogzEquipPlus, 0)
        plusIpyData = IpyGameDataPY.GetIpyGameData("DogzEquipPlus", curEquip.GetEquipPlace(), curPlusLV)
        if plusIpyData:
            plusAttrTypeList = plusIpyData.GetPlusAttrTypes()
            plusAttrValueList = plusIpyData.GetPlusAttrValues()
            if plusAttrTypeList and len(plusAttrTypeList) == len(plusAttrValueList):
                for plusIndex, plusAttrID in enumerate(plusAttrTypeList):
                    plusAttrValue = plusAttrValueList[plusIndex]
                    PlayerControl.CalcAttrDict_Type(plusAttrID, plusAttrValue, allAttrList)
                    #GameWorld.DebugLog("    ×°±¸Ç¿»¯: itemID=%s,plusAttrID=%s, plusAttrValue=%s, %s" % (itemID, plusAttrID, plusAttrValue, allAttrList))
                    
        # ´«ÆæÊôÐÔ
        ChEquip.CalcAttr_LegendAttr(curPlayer, curEquip, allAttrList)
 
    return allAttrList