hxp
2018-10-30 5ab23bf8c2f16b2ac19d76282ad9528fcb247005
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package Event.EventSrc.Operate_EquipPlus
#
# @todo:²¿Î»ÐǼ¶¹«¹²Ä£Ê½Ç¿»¯
# @author hxp
# @date 2015-12-15
# @version 1.2
#
# ÏêϸÃèÊö: ²¿Î»ÐǼ¶¹«¹²Ä£Ê½Ç¿»¯
#
# @change: "2016-06-30 21:30" hxp Ç¿»¯´ïÈË¿ª·þ»î¶¯
# @change: "2016-10-08 18:00" hxp ×Ô¶¯¹ºÂòÎïÆ·¼Û¸ñͳһȡÉ̳ÇÎïÆ·¼Û¸ñ
#
#---------------------------------------------------------------------
#"""Version = 2016-10-08 18:00"""
#---------------------------------------------------------------------
import ItemCommon
import ShareDefine
import PlayerControl
import IPY_GameWorld
import OpenServerCampaign
import DataRecordPack
import PlayerActivity
import PlayerSuccess
import IpyGameDataPY
import GameWorld
import ChConfig
import ChEquip
import EventShell
#-------------------------------------------------------------------------------------------
 
#===============================================================================
# //A3 01 ×°±¸Ç¿»¯ #tagEquipPlus
# struct    tagEquipPlus
# {
#    tagHead        Head;
#    BYTE        PackType;        //±³°üÀàÐÍ:rptItem, rptEquip, rptPetEquip1~5
#    WORD        ItemIndex;        //ÎïÆ·ÔÚ±³°üÖÐË÷Òý
# };
#===============================================================================
## ×°±¸Ç¿»¯
#  @param playerIndex: Íæ¼Ò
#  @param clientData: ·â°ü
#  @param tick: µ±Ç°Ê±¼ä
#  @return None
def OnEquipMayaPlus(playerIndex, clientData, tick):    
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    playerID = curPlayer.GetPlayerID()
    
    packType = clientData.PackType
    index = clientData.ItemIndex
    
    # ÅжϠ1.×°±¸  2.×î¸ßÇ¿»¯µÈ¼¶£¬ 3.Í­Ç®Êý
    if packType not in ChConfig.Pack_EquipPart_CanPlusStar:
        GameWorld.DebugLog("packType not in ChConfig.Pack_EquipPart_CanPlusStar", playerID)
        return
    
    indexList = ChConfig.Pack_EquipPart_CanPlusStar[packType]
    if index not in indexList:
        GameWorld.Log("    index not in ChConfig.Pack_EquipPart_CanPlusStar", playerID)
        return
    
    # Ôݲ»ÅжϿªÆôµÈ¼¶Óɿͻ§¶Ë´¦Àí   
    # µ±Ç°×°±¸µÈ¼¶ÊÇ·ñµ½´ï×î¸ßµÈ¼¶
    curPack = curPlayer.GetItemManager().GetPack(packType)
    curEquip = curPack.GetAt(index)
    if not curEquip or curEquip.IsEmpty():
        GameWorld.DebugLog("OnEquipMayaPlus() equip is empty")
        return
    
    maxStarLV = ItemCommon.GetItemMaxStarLV(curEquip)
    curPartStarLV = ChEquip.GetEquipPartStarLV(curPlayer, packType, index)
    if curPartStarLV >= maxStarLV:
        GameWorld.Log("OnEquipMayaPlus:curPartStarLV(%s) >= maxStarLV(%s)" % (curPartStarLV, maxStarLV), playerID)
        return
 
    # Ç¿»¯´¦Àí
    result = DoLogic_EquipMayaPlus(curPlayer, curEquip, packType, index)
    
    updPartStarLV = ChEquip.GetEquipPartStarLV(curPlayer, packType, index)
    #GameWorld.Log("    result=%s,curStarLV=%s,updStarLV=%s" % (result, curPartStarLV, updPartStarLV), playerID)
    if result == ChConfig.Def_ComposeState_None:
        return
    
    #===========================================================================
    # curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitEquipMayaPlus, result)
    
    # Ã¿Èջ
    PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_EquipPlus)
    #===========================================================================
    
 
    # ÐǼ¶±ä¸üʱ´¦Àí
    if curPartStarLV != updPartStarLV:
        DoLogic_OnEquipPartStarLVChange(curPlayer, packType)
        # Ôö¼ÓÇ¿»¯³É¾Í
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_EquipPlus, 1)
        EventShell.EventRespons_EquipPlus(curPlayer)
    return
 
     
 
## ¿ªÊ¼×°±¸Ç¿»¯
#  @param index Îª×°±¸Î»
#  @return 
def DoLogic_EquipMayaPlus(curPlayer, curEquip, packType, index):
    result = ChConfig.Def_ComposeState_None
 
    findType = ChEquip.GetEquipPlusType(curEquip)
    if findType == -1:
        return result
    
    curPartStarLV = ChEquip.GetEquipPartStarLV(curPlayer, packType, index)
    ipyData = IpyGameDataPY.GetIpyGameData("ItemPlus", findType, curPartStarLV)
    if not ipyData:
        return
    costSilver = ipyData.GetCostCount()
 
    if not PlayerControl.HaveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, costSilver):
        # ½ð±Ò²»×㣬·µ»Ø
        return result
 
    totalExp = ipyData.GetTotalExp()
    curExp = ChEquip.GetEquipPartProficiency(curPlayer, packType, index) + ipyData.GetAddExp()
 
    if curExp >= totalExp:
        #Éý¼¶
        curPartStarLV = __EquipMayaPlusChange(curPlayer, packType, curEquip, index)
        curExp = curExp - totalExp
        
    ChEquip.SetEquipPartProficiency(curPlayer, packType, index, curExp)
    ChEquip.NotifyEquipPartStarLV(curPlayer, packType, index)
    # Ö§¸¶½ð±Ò
    PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, costSilver, isNotify=False)
 
    DataRecordPack.DR_UpStarLVSuccess(curPlayer, curExp, curPartStarLV)
    return ChConfig.Def_ComposeState_Sucess
 
 
 
## ÂêÑżÓÇ¿µÈ¼¶¸Ä±ä
#  @param curPlayer: Íæ¼Ò
#  @param packType: ±³°üÀàÐÍ
#  @param curEquip: µ±Ç°×°±¸
#  @param succeedRate: ³É¹¦ÂÊ
#  @param failStarLV: Ê§°ÜʱµÄÐǼ¶Êý
#  @return 
def __EquipMayaPlusChange(curPlayer, packType, curEquip, index):
    curPlusLV = ChEquip.GetEquipPartStarLV(curPlayer, packType, index)
    updPlusLV = curPlusLV + 1
    ChEquip.SetEquipPartStarLV(curPlayer, packType, index, curEquip, updPlusLV)
    
    broadCastLVList = IpyGameDataPY.GetFuncEvalCfg("StrengthenLevelBroadCast", 1)
    #GameWorld.DebugLog("PlusLVChange index=%s,updPlusLV=%s,broadCastLVList=%s" % (index, updPlusLV, broadCastLVList))
    if updPlusLV in broadCastLVList:
        msgParamList = [curPlayer.GetPlayerName()] + ItemCommon.GetNotifySuperItemInfo(curPlayer, curEquip, index) + [updPlusLV]
        PlayerControl.WorldNotify(0, "StrengthenCongratulation", msgParamList)
        
    # ³É¾Í
    #PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_EquipPlusLV, 1, [updPlusLV])
    
    
                    
    #ÈÎÎñ´¥·¢
    #EventShell.EventRespons_OnEquipPartStarUp(curPlayer, setLV)
    # ¿ª·þ»î¶¯Êý¾Ý
    OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_PlusLV, ChEquip.GetTotalPlusLV(curPlayer))
    return updPlusLV
 
 
def DoLogic_OnEquipPartStarLVChange(curPlayer, packType):
    #ÏÈË¢×°±¸BUFF ÔÙ¼ÆËãÊôÐÔ
    curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrActivatyNotify, ChConfig.Def_AttrActivatyNotify_Plus)
    ChEquip.RefreshPlayerEquipAttribute(curPlayer)
    
    #Ë¢ÐÂËùÓÐÊôÐÔ
    playControl = PlayerControl.PlayerControl(curPlayer)
    playControl.RefreshPlayerAttrState()
    return
 
 
## È«Éí12²¿Î»Ç¿»¯µÈ¼¶×îµÍµÄÒ»¼þÇ¿»¯µÈ¼¶
#def GetMinPlusLV(curPlayer):
#    packType = IPY_GameWorld.rptEquip
#    minPlusLV = GetMaxEquipPartStarLV()
#    equipPartIndexList = ChConfig.Pack_EquipPart_CanPlusStar.get(packType, [])
#    for i in equipPartIndexList:
#        partStarLV = ChEquip.GetEquipPartStarLV(curPlayer, packType, i)
#        if partStarLV < minPlusLV:
#            minPlusLV = partStarLV
#    return minPlusLV