xdh
2018-08-14 d1ad5d9c180f06127775498044c239d980689dbd
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package Player.PlayerGodWeapon
#
# @todo:Éñ±ø
# @author alee
# @date 2017-07-20
# @version 1.0
#
# ÏêϸÃèÊö: Éñ±ø
#
#---------------------------------------------------------------------
#"""Version = 2017-07-20 16:00"""
#---------------------------------------------------------------------
 
import GameWorld
import EventShell
import ChConfig
import PlayerControl
import ItemCommon
import IPY_GameWorld
import ChPyNetSendPack
import NetPackCommon
import PlayerSuccess
import ShareDefine
import SkillShell
import DataRecordPack
import GameFuncComm
import SkillCommon
import BuffSkill
import ItemControler
#import EventReport
import IpyGameDataPY
import PassiveBuffEffMng
 
import random
 
## ÉñÆ÷¹¦ÄܵǼ´¦Àí
#  @param curPlayer Íæ¼Ò
#  @return None
def OnLogin(curPlayer):
    if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_GodWeapon):
        return
    Sync_GodWeaponLVInfo(curPlayer)
    return
 
 
## ÉñÆ÷¿ªÆô
#  @return: ÊÇ·ñ¼¤»î³É¹¦
def DoGodWeaponOpen(curPlayer):
    # Ä¬Èϼ¤»î1¼¶µÄÀàÐÍ
    for i in IpyGameDataPY.GetFuncEvalCfg('GodWeaponActive'):
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodWeaponLV % i, 1)
        PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_GodWeapon, 1, [i])
    Sync_GodWeaponLVInfo(curPlayer)
    return True
 
 
## Ë¢ÐÂÉñ±øÊôÐÔ
def RefreshGodWeaponAttr(curPlayer):
    CalcGodWeaponAttr(curPlayer)
    # ²»Á¢¼´Ë¢ÐÂ
    PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
    return
 
## ¼ÆËãÊôÐÔ
#  @param curPlayer Íæ¼Ò
#  @param allAttrList ÊôÐÔÁбí
#  @return None
def CalcGodWeaponAttr(curPlayer):
    if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_GodWeapon):
        return
    
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    maxType = ipyDataMgr.GetGodWeaponByIndex(ipyDataMgr.GetGodWeaponCount()-1).GetType()
 
    allAttrList = [{} for i in range(4)]
    for gwType in xrange(1, maxType + 1):
        attrLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % gwType)
        godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', gwType, attrLV)
        if not godWeaponData:
            continue
        attrTypeList, attrValueList =  godWeaponData.GetAttrType(), godWeaponData.GetAttrNum()
        for i, attrID in enumerate(attrTypeList):
            PlayerControl.CalcAttrDict_Type(attrID, attrValueList[i], allAttrList)
        
    # ±£´æ¼ÆËãÖµ
    PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_GodWeapon, allAttrList)   
    return
 
#---------------------------------------------------------------------------------------------------
#===============================================================================
# // A5 55 Éñ±øÉý¼¶ #tagCMGodWeaponPlus
# struct    tagCMGodWeaponPlus
# {
#    tagHead        Head;
#    DWORD        WeaponType;    // Éñ±øÀàÐÍ
#    DWORD        ItemID;        //ÏûºÄµÄÎïÆ·ID
# };
#===============================================================================
def OnPlusGodWeapon(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    weaponType = clientData.WeaponType
    useItemID = clientData.ItemID
    
    if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_GodWeapon):
        #µÈ¼¶²»×ã
        return
    
    #1.ÅжϱíÖÐÓÐû´ËÀàÐÍ£¬2.ÊÇ·ñÂú¼¶£¬3.ÅжÏÊÇ·ñÓÐÎïÆ·
    attrLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % weaponType)
    beforeAttrLV = attrLV   # ÓÃÓÚÌáʾ
    godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', weaponType, attrLV)
    if not godWeaponData:
        GameWorld.DebugLog('Éñ±øÉý¼¶ÕÒ²»µ½Êý¾Ý %s-%s'%(weaponType, attrLV))
        return
    
    totalExp = godWeaponData.GetExp()
    if totalExp == 0:
        #Âú¼¶
        return
    
    #ÑéÖ¤ÊÇ·ñÖ¸¶¨µÄÎïÆ·ID
    if useItemID not in IpyGameDataPY.GetFuncEvalCfg("GodWeapon%s"%weaponType):
        return
    
    curItem = ItemCommon.FindItemInPackByItemID(curPlayer, useItemID, IPY_GameWorld.rptItem)
    if not curItem:
        GameWorld.DebugLog('###Éñ±ø¼Ù°ü£¬Ã»ÓÐÎïÆ·ID=%s'%useItemID)
        return
 
    effect = ItemCommon.GetItemEffectByEffectID(curItem, ChConfig.Def_Item_Eff_GodWeaponExp)
    if not effect:
        GameWorld.DebugLog('###Éñ±ø¼Ù°ü£¬ÎïÆ·ID=%sûÓо­ÑéÖµ'%useItemID)
        return
    addExp = effect.GetEffectValue(0)
    if not addExp:
        GameWorld.DebugLog('###Éñ±ø¼Ù°ü£¬ÎïÆ·ID=%sûÓо­ÑéÖµ'%useItemID)
        return
    
    delCnt = 1
    ItemCommon.DelItem(curPlayer, curItem, delCnt, False, ChConfig.ItemDel_GodWeapon)
    
    curExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponExp % weaponType)
    curExp = curExp + addExp
    
    isLVUP = False
    
    # °²È«ÎªÖ÷²»ÓÃwhile
    for i in xrange(100):
        if curExp < totalExp:
            break
        godWeaponData = IpyGameDataPY.GetIpyGameData('GodWeapon', weaponType, attrLV+1)
        if not godWeaponData:
            GameWorld.DebugLog('Éñ±øÉý¼¶ÕÒ²»µ½Êý¾Ý %s-%s'%(weaponType, attrLV))
            break
        
        curExp = curExp - totalExp
        attrLV += 1
        isLVUP = True
        GodWeaponLVUP(curPlayer, godWeaponData)
        
        totalExp = godWeaponData.GetExp()
        if totalExp == 0:
            curExp = 0
            #Âú¼¶
            break
        
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodWeaponLV % weaponType, attrLV)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GodWeaponExp % weaponType, curExp)
    
    if isLVUP:
        RefreshGodWeaponAttr(curPlayer)
        #xÉñÆ÷´ïµ½X¼¶³É¾Í
        PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_GodWeapon, attrLV, [weaponType])
        if beforeAttrLV == 0:
            # ½â·â֪ͨ
            PlayerControl.WorldNotify(0, 'GetGodWeapon', [curPlayer.GetName(), weaponType])
            
        #{1:[100,200,300,400],2:[100,200,300,400],3:[100,200,300,400]}
        notifyDict = IpyGameDataPY.GetFuncEvalCfg('GodLv', 1, {})
        if weaponType in notifyDict:
            for notifyLV in notifyDict[weaponType]:
                if beforeAttrLV < notifyLV and attrLV >= notifyLV:
                    PlayerControl.WorldNotify(0, 'GodWeaponLv', [curPlayer.GetName(), weaponType, notifyLV])
        
    Sync_GodWeaponLVInfo(curPlayer, weaponType)
    #ÈÎÎñ
    EventShell.EventRespons_PlusGodWeapon(curPlayer)
    return
 
#Éñ±øÉý¼¶´¥·¢ÆäËû¹¦ÄÜ£º¼¼ÄÜ
def GodWeaponLVUP(curPlayer, godWeaponData):
    skillID = godWeaponData.GetSkillID()
    if skillID:
        __GiveGodWeaponSkill(curPlayer, skillID)
 
 
 
## Í¬²½ÉñÆ÷µÈ¼¶
#  @param curPlayer
#  @param godWeaponId ÉñÆ÷ID
#  @return None
def Sync_GodWeaponLVInfo(curPlayer, godWeaponID=0):
    sendPack = ChPyNetSendPack.tagMCGodWeaponLVList()
    sendPack.Clear()
        
    sendPack.WeaponInfoList = []
 
    if godWeaponID <= 0:
#        weaponStateStr = bin(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponState))[::-1][:-2]
#        for i in range(0, len(weaponStateStr)):
#            if weaponStateStr[i] == '0':
#                #ÕÒ³ö¼¤»îµÄÉñ±ø
#                continue
        ipyDataMgr = IpyGameDataPY.IPY_Data()
        maxType = ipyDataMgr.GetGodWeaponByIndex(ipyDataMgr.GetGodWeaponCount()-1).GetType()
        for i in xrange(1, maxType + 1):
            weaponInfo = ChPyNetSendPack.tagMCGodWeaponLVInfo()
            weaponInfo.Clear()
            weaponInfo.WeaponType = i
            weaponInfo.WeaponLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % i)
            weaponInfo.WeaponExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponExp % i)
            sendPack.WeaponInfoList.append(weaponInfo)
    else:
        weaponInfo = ChPyNetSendPack.tagMCGodWeaponLVInfo()
        weaponInfo.Clear()
        weaponInfo.WeaponType = godWeaponID
        weaponInfo.WeaponLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % godWeaponID)
        weaponInfo.WeaponExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponExp % godWeaponID)
        sendPack.WeaponInfoList.append(weaponInfo)
    
    sendPack.WeaponNum = len(sendPack.WeaponInfoList)
    NetPackCommon.SendFakePack(curPlayer, sendPack)  
    return
 
 
 
def __GiveGodWeaponSkill(curPlayer, skillResId):
    # ÉñÆ÷ѧϰ¼¼ÄÜ
    skillManager = curPlayer.GetSkillManager()
    if skillManager.FindSkillBySkillTypeID(skillResId):
        GameWorld.DebugLog("godSkill() have learned skill(%s)" % skillResId)
        return
    
    skillData = GameWorld.GetGameData().FindSkillByType(skillResId, 1)
    if skillData == None:
        GameWorld.DebugLog("godSkill() hasn't find skill(%s)" % skillResId)
        return
    if not SkillShell.CheckLearnSkillCondition(curPlayer, skillData):
        GameWorld.DebugLog("godSkill() learn skill(%s) condition isn't enough" % skillResId)
        return
    
    skillManager.LVUpSkillBySkillTypeID(skillResId)
    #PlayerControl.NotifyCode(curPlayer, "Skill_andyshao_31379", [skillResId])
    GameWorld.DebugLog("godSkill() skill(%s) success!" % skillResId)
    DataRecordPack.DR_LearnORUPSkill(curPlayer, skillResId, 0)
    
    #if SkillCommon.isPassiveSkill(skillData):
    #    buffType = SkillCommon.GetBuffType(skillData)
    #    BuffSkill.DoAddBuff(curPlayer, buffType, skillData, GameWorld.GetGameWorld().GetTick(), [], curPlayer)
    PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer, skillResId)
    PlayerControl.PlayerControl(curPlayer).RefreshSkillFightPowerEx(skillResId, 0)
    return