hxp
2021-02-20 71a5b8c236d7538053a3a893adccaa0d59798521
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
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package PlayerFamilyTech
# @todo: Íæ¼Ò¼Ò×å¿Æ¼¼
#
# @author: panwei
# @date 2011-06-16
# @version 1.2
#
# @change: "2016-06-08 16:00" hxp ÓÀºãÕ½Ã˿Ƽ¼°æ±¾
# @change: "2016-10-31 16:00" hxp ¸ÄΪ´¿µØÍ¼´¦Àíģʽ
#---------------------------------------------------------------------
#"""Version = 2016-10-31 16:00"""
#---------------------------------------------------------------------
import GameWorld
#import ReadChConfig
import GameFuncComm
import ChPyNetSendPack
import PlayerControl
import NetPackCommon
import ShareDefine
import ChConfig
import IpyGameDataPY
import PlayerSuccess
#---------------------------------------------------------------------
def __GetTechIpyData(techID, lv=1):
    keyStr = techID*1000+lv
    return IpyGameDataPY.GetIpyGameData('FamilyTech', keyStr)
 
#// A6 07  ×ÔÉí¼Ò×å¿Æ¼¼µÈ¼¶ÌáÉý #tagCMFamilyTechLVUP
#
#struct     tagCMFamilyTechLVUP
#{
#    tagHead        Head;
#    DWORD        TechID;    // ¿Æ¼¼ID
#};
def OnPlayerFamilyTechLVUP(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    techID = clientData.TechID
    
    familyID = curPlayer.GetFamilyID()
    if familyID <= 0:
        GameWorld.DebugLog("ûÓÐÕ½ÃË, ÎÞ·¨Éý¼¶Õ½Ã˿Ƽ¼!")
        return
    if curPlayer.GetFamilyLV() < IpyGameDataPY.GetFuncCfg('TechFamilyLV'):
        return
    curTechLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTechLV % techID)
    tagTechLV = curTechLV + 1
    ipyData = __GetTechIpyData(techID, tagTechLV)
    if not ipyData:
        GameWorld.DebugLog("Õ½Ã˿Ƽ¼ID²»´æÔÚ»òÒÑÂú¼¶! techID=%s, tagTechLV=%s" % (techID, tagTechLV))
        return
   
    
    needContribution = ipyData.GetContribution()
    if not needContribution:
        GameWorld.DebugLog("ÕÒ²»µ½Éý¼¶¿Æ¼¼µÈ¼¶¶ÔÓ¦ÏûºÄ techID=%s,tagTechLV=%s" % (techID, tagTechLV)) 
        return
 
    #dataDict = {"techID":techID, "curTechLV":curTechLV, "tagTechLV":tagTechLV}
    isPayOK = PlayerControl.PayMoney(curPlayer, ShareDefine.TYPE_Price_Family_Contribution, needContribution)
     
    if not isPayOK:
        GameWorld.DebugLog("Íæ¼Òµ±Ç°¹±Ï׶Ȳ»×㣬ÎÞ·¨Éý¼¶Õ½Ã˿Ƽ¼£¡needContribution=%s" % (needContribution))
        return
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTechLV % techID, tagTechLV)
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_FamilyTechLV, 1, [techID])
    PlayerControl.NotifyCode(curPlayer, "GeRen_liubo_660051", [techID, tagTechLV])
    Sync_PlayerFamilyTechLV(curPlayer)
    #Ë¢ÐÂËùÓÐÊôÐÔ
    CalcFamilyTechAttr(curPlayer)
    PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
    return
 
#    if curPlayer.GetDictByKey(ChConfig.Def_PDict_QueryTechLVUPState):
#        #ÒѾ­ÔÚ²éѯÖÐ
#        GameWorld.DebugLog("OnPlayerFamilyTechLVUP ÒѾ­ÔÚ²éѯÖÐ...")
#        return
#    
#    if techID not in ReadChConfig.GetEvalChConfig("FamilyTechAttr"):
#        GameWorld.DebugLog("Õ½Ã˿Ƽ¼ID²»´æÔÚ! techID=%s" % techID)
#        return
#    
#    curPlayer.SetDict(ChConfig.Def_PDict_QueryTechLVUPState, 1)
#    curTechLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTechLV % techID)
#    cmdStr = str([techID, curTechLV])
#    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetPlayerID(), 0, 0, 'PlayerFamilyTechLVUP', cmdStr, len(cmdStr))
#    GameWorld.DebugLog("Query PlayerFamilyTechLVUP cmdStr=%s" % cmdStr)
    return
 
## Ö´ÐÐÍæ¼ÒÕ½Ã˿Ƽ¼Éý¼¶
def DoPlayerFamilyTechLVUP(curPlayer, resultList):
    # [techID, curPlayerTechLV, needContribution]
    if not resultList or len(resultList) < 3:
        return
        
    techID = resultList[0]
    curPlayerTechLV = resultList[1]
    needContribution = resultList[2]
    
    curTechLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTechLV % techID)
    if curTechLV != curPlayerTechLV:
        return
    
    updTechLV = curTechLV + 1
    #dataDict = {"techID":techID, "curTechLV":curTechLV, "updTechLV":updTechLV}
    isPayOK = PlayerControl.PayMoney(curPlayer, ShareDefine.TYPE_Price_Family_Contribution, needContribution)
    if not isPayOK:
        GameWorld.DebugLog("Íæ¼Òµ±Ç°¹±Ï׶Ȳ»×㣬ÎÞ·¨Éý¼¶Õ½Ã˿Ƽ¼£¡needContribution=%s" % (needContribution))
        return
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyTechLV % techID, updTechLV)
    PlayerControl.NotifyCode(curPlayer, "GeRen_liubo_660051", [techID, updTechLV])
    Sync_PlayerFamilyTechLV(curPlayer)
    #Ë¢ÐÂËùÓÐÊôÐÔ
    CalcFamilyTechAttr(curPlayer)
    PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
    return
 
## ¼ÆËãÕ½Ã˿Ƽ¼¸½¼ÓÊôÐÔ
def CalcFamilyTechAttr(curPlayer):
    
    allAttrList = [{} for _ in range(4)]
    skillFPEx = 0 #¶îÍâÕ½Á¦
    if GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Family):
        techNeedLVDict = IpyGameDataPY.GetFuncEvalCfg('FamilyTechNeedLV', 1, {})
        techIDList = techNeedLVDict.keys()
        
        #GameWorld.DebugLog("CalcFamilyTechAttr...techIDList=%s" % techIDList)
        
        # ¼ÆËã×ÔÉíÊôÐÔ
        for techID in techIDList:
            techID = int(techID)
            techLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTechLV % techID)
            if not techLV:
                continue
            ipyData = __GetTechIpyData(techID, techLV)
            if not ipyData:
                continue
            attrID = ipyData.GetAttrType()
            addValue = ipyData.GetAttrValue()
            skillFPEx += ipyData.GetPowerEx()
            #GameWorld.DebugLog("    techID=%s,lv=%s,attrID=%s,addValue=%s" % (techID, techLV, attrID, addValue))
            PlayerControl.CalcAttrDict_Type(attrID, addValue, allAttrList)
            
    #GameWorld.DebugLog("ÏÉÃËÐÄ·¨ÊôÐÔ: %s" % allAttrList)
    # ±£´æ¼ÆËãÖµ
    PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_FamilyTech, allAttrList)
    
    curPlayer.SetDict(ChConfig.Def_PlayerKey_MFPEx % ShareDefine.Def_MFPType_Other, skillFPEx)
    return
 
 
## Í¬²½Íæ¼ÒÕ½Ã˿Ƽ¼µÈ¼¶
def Sync_PlayerFamilyTechLV(curPlayer):
    techInfoPack = ChPyNetSendPack.tagMCPlayerTechInfo()
    techInfoPack.Clear()
    techInfoPack.TechInfoList = []
    techNeedLVDict = IpyGameDataPY.GetFuncEvalCfg('FamilyTechNeedLV', 1, {})
    techIDList = techNeedLVDict.keys()
    for techID in techIDList:
        techInfo = ChPyNetSendPack.tagMCPlayerTech()
        techInfo.Clear()
        techInfo.TechID = techID
        techInfo.TechLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTechLV % techID)
        techInfoPack.TechInfoList.append(techInfo)
    techInfoPack.TechCnt = len(techInfoPack.TechInfoList)
    NetPackCommon.SendFakePack(curPlayer, techInfoPack)
    return