hch
2024-10-08 b2e6e02a9b7e3ca95047bbdefce5261edb23658f
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
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package PlayerFamilyTech
# @todo: ¼Ò×å¿Æ¼¼
#
# @author: panwei
# @date 2011-06-17
# @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 PlayerFamily
#import PlayerFamilyAction
#import DataRecordPack
#import IPY_GameServer
#import PlayerControl
#import ShareDefine
#import ChConfig
#---------------------------------------------------------------------
 
(
Def_TechLVUP_NeedBoomValue, # ÏûºÄÕ½ÃË·±ÈÙ
Def_TechLVUP_NeedMoney, # ÏûºÄÕ½Ã˽ðÇ®
Def_TechLVUP_NeedHornor, # ÏûºÄÕ½ÃË×êʯ
Def_TechLVUP_NeedContribution, # ¸öÈËÉý¼¶ÐèÒªÏûºÄ¹±Ï×¶È
) = range(4)
 
#---------------------------------------------------------------------
##Íæ¼ÒµÇ½, ¼Ò×å¿Æ¼¼Âß¼­´¦Àí
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return None
# @remarks 
def OnLogin(curPlayer, tick):
    curFamily = curPlayer.GetFamily()
    if not curFamily:
        #Íæ¼ÒÎÞ¼Ò×å
        return
    
    if not GameWorld.GetFamilyTechManager().GetFamilyTechByFamilyID(curFamily.GetID()):
        return
 
    #֪ͨ¿Í»§¶Ë¼Ò×å¿Æ¼¼ÐÅÏ¢
    curPlayer.Sync_FamilyTechInfo()
    return
 
#===============================================================================
# //0F 16 °ï»á¿Æ¼¼Éý¼¶#tagCFamilyTecLvUP
# struct       tagCFamilyTecLvUP
# {
#         tagHead            Head;
#         DWORD  TecID; //¿Æ¼¼ID 
#         BYTE  IsUseKey; //ÊÇ·ñʹÓÃÍ»·ÉÁî 
# };
#===============================================================================
##°ï»á¿Æ¼¼Éý¼¶»òÈ¡Ïû
# @param index Íæ¼ÒË÷Òý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks ¿Í»§¶Ë·â°üÏìÓ¦ °ï»á¿Æ¼¼Éý¼¶#tagCFamilyTecLvUP
def CChangeFamilyTech(index, tick):
    #¸ÄΪµØÍ¼Ö±½Ó´¦Àí£¬ÔÝÆÁ±Î
#    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
#    curFamily = curPlayer.GetFamily()
#    
#    if not curFamily:
#        return
#    
#    clientPack = IPY_GameServer.IPY_CFamilyTecLvUP()
#    techID = clientPack.GetTecID()
#
#    #Ñé֤ȨÏÞ
#    if not PlayerFamily.GetPlayerHasFamilyPow(curPlayer, ChConfig.Def_PurviewDictKey_CanLvUpTech):
#        GameWorld.DebugLog("ûÓÐÉý¼¶Õ½Ã˿Ƽ¼È¨ÏÞ!")
#        return
#    
#    FamilyTechIDList = ReadChConfig.GetEvalChConfig("FamilyTechID")
#    if techID not in FamilyTechIDList:
#        GameWorld.DebugLog("Õ½Ã˿Ƽ¼²»´æÔÚ, techID=%s not in FamilyTechID.txt!" % techID)
#        return
#    
#    curFamilyID = curFamily.GetID()
#    curFamilyLv = curFamily.GetLV()
#    FamilyTechMaxLVDict = ReadChConfig.GetEvalChConfig("FamilyTechMaxLV")
#    if not FamilyTechMaxLVDict:
#        return
#    maxConfFamilyLV = max(FamilyTechMaxLVDict)
#    getLV = maxConfFamilyLV if curFamilyLv > maxConfFamilyLV else curFamilyLv
#    maxTechLV = FamilyTechMaxLVDict.get(getLV)
#    if not maxTechLV:
#        GameWorld.DebugLog("Õ½Ã˵ȼ¶=%s, ¶ÔÓ¦µÄÕ½Ã˿Ƽ¼×î´óµÈ¼¶²»´æÔÚ! ¼ì²é FamilyTechMaxLV.txt!" % (getLV))        
#        return
#    
#    familyTechMgr = GameWorld.GetFamilyTechManager()
#    learnTech = familyTechMgr.FindFamilyTechData(curFamilyID, techID)
#    curTechLV = 0 if not learnTech else learnTech.GetTechCurLV()
#    if curTechLV >= maxTechLV:
#        GameWorld.DebugLog("µ±Ç°Õ½Ã˿Ƽ¼ÒÑ´ï×î´óµÈ¼¶! curTechLV=%s,curFamilyLv=%s,maxTechLV=%s!" % (curTechLV, curFamilyLv, maxTechLV))        
#        return
#    
#    lvUPTechLV = curTechLV + 1
#    FamilyTechLVUPDict = ReadChConfig.GetEvalChConfig("FamilyTechLVUP")
#    techLVUPInfo = FamilyTechLVUPDict.get(lvUPTechLV)
#    if not techLVUPInfo:
#        GameWorld.ErrLog("Õ½Ã˿Ƽ¼µÈ¼¶(%s) not in FamilyTechLVUP.txt!" % lvUPTechLV)
#        return
#    
#    needBoomValue = techLVUPInfo[Def_TechLVUP_NeedBoomValue]
#    needMoney = techLVUPInfo[Def_TechLVUP_NeedMoney]
#    needHornor = techLVUPInfo[Def_TechLVUP_NeedHornor]
#    
#    if curFamily.GetBoomValue() < needBoomValue:
#        GameWorld.DebugLog("Õ½ÃË·±ÈÙ»îÔ¾¶È²»×ã! needBoomValue=%s" % (needBoomValue))
#        return
#    if curFamily.GetMoney() < needMoney:
#        GameWorld.DebugLog("Õ½ÃË×ʽð²»×ã! needMoney=%s" % (needMoney))
#        return
#    if curFamily.GetHornor() < needHornor:
#        GameWorld.DebugLog("Õ½ÃË×êʯ²»×ã! needHornor=%s" % (needHornor))
#        return
#    
#    if learnTech == None:
#        learnTech = familyTechMgr.AddFamilyTechData(curFamilyID, techID)
#        if learnTech == None:
#            GameWorld.ErrLog('curFamilyID = %s, Éý¼¶ techID = %s Òì³£' % (curFamilyID, techID))
#            return
#        #ÉèÖÿƼ¼¼Ò×åID
#        learnTech.SetFamilyID(curFamilyID)
#        
#    #---¿ªÊ¼Éý¼¶---
#    curFamily.SetBoomValue(curFamily.GetBoomValue() - needBoomValue)
#    curFamily.SetMoney(curFamily.GetMoney() - needMoney)
#    curFamily.SetHornor(curFamily.GetHornor() - needHornor)
#    
#    learnTech.SetTechCurLV(lvUPTechLV)
#    
#    #¿Æ¼¼Éý¼¶Á÷Ïò
#    dataDict = {"familyID":curFamilyID, "techID":techID, "lvUPTechLV":lvUPTechLV, "needBoomValue":needBoomValue, 
#                "needMoney":needMoney, "needHornor":needHornor}
#    DataRecordPack.SendEventPack("FamilyTechLVUP", dataDict)
#
#    #¼Ç¼Éý¼¶ÐÅÏ¢
#    PlayerFamilyAction.AddFamilyActionNote(curPlayer.GetName(), curFamilyID, ShareDefine.Def_ActionType_FamilyEvent, 
#                                           [ShareDefine.Def_FamilyActionEvent_Tech, techID, lvUPTechLV], tick)
#    
#    #֪ͨ¿Í»§¶Ë¼Ò×åÊôÐÔ±ä¸ü
#    curFamily.Broadcast_FamilyChange()
#    #֪ͨµØÍ¼·þÎñÆ÷ˢмÒ×åÊôÐÔ
#    PlayerFamily.SendPack_MapServer_PlayerFamilyRefresh(curFamily)
#
#    #֪ͨ¼Ò×å¿Æ¼¼±ä¸ü
#    NotifyFamilyTechInfoChange(curFamily)
#
#    #¿Æ¼¼Éý¼¶³É¹¦
#    PlayerControl.FamilyNotify(curFamilyID, "jiazu_liubo_318691", [techID, lvUPTechLV])
#    GameWorld.Log('¿Æ¼¼Éý¼¶³É¹¦ familyID=%s,techID=%s,lvUPTechLV=%s' % (curFamilyID, techID, lvUPTechLV))
    return
 
#---------------------------------------------------------------------
##֪ͨ¼Ò×å¿Æ¼¼±ä¸ü
# @param curFamily ¼Ò×åʵÀý
# @param sendMPack ·¢°üµØÍ¼·þÎñÆ÷
# @return None
# @remarks 
def NotifyFamilyTechInfoChange(curFamily):
    
    #֪ͨËùÓÐÔÚÏßÍæ¼Ò, ¼Ò×å¿Æ¼¼±ä¸ü
    for i in range(0, curFamily.GetCount()):
        curMember = curFamily.GetAt(i)
        curPlayer = curMember.GetPlayer()
        if curPlayer == None:
            continue
        curPlayer.Sync_FamilyTechInfo()
 
    return
 
#---------------------------------------------------------------------
##ɾ³ýÕ½Ã˿Ƽ¼
# @param familyID ¼Ò×åID
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks 
def DelFamilyTechData(familyID):
    familyTechMgr = GameWorld.GetFamilyTechManager()
    playerFamilyTech = familyTechMgr.GetFamilyTechByFamilyID(familyID)
    
    if not playerFamilyTech:
        #ÎÞ¼Ò×å¿Æ¼¼ÐÅÏ¢
        return
    
    #---ɾ³ý¼Ò×å¿Æ¼¼ÐÅÏ¢---
    familyTechIDList = []
    
    for familyTechIndex in range(0, playerFamilyTech.GetCount()):
        familyTechData = playerFamilyTech.GetAt(familyTechIndex)
        familyTechIDList.append(familyTechData.GetTechID())
    
    for techID in familyTechIDList:
        #Çå³ýÕâ¸ö¼Ò×åµÄ°ï»áÊôÐÔ
        familyTechMgr.DeleteFamilyTechData(familyID, techID);
        GameWorld.Log("DelFamilyTechData familyID=%s, techID=%s" % (familyID, techID))
    
    return
 
 
## Íæ¼ÒÇëÇóÕ½Ã˿Ƽ¼Éý¼¶
#  @param curPlayer Íæ¼ÒʵÀý
#  @return 
def OnQuery_PlayerFamilyTechLVUP(curPlayer, infoList):
    techID, curPlayerTechLV = infoList
    
    curFamily = curPlayer.GetFamily()
    
    if not curFamily:
        return []
    
    familyTech = GameWorld.GetFamilyTechManager().FindFamilyTechData(curFamily.GetID(), techID)
    familyTechLV = 0 if not familyTech else familyTech.GetTechCurLV()
    if curPlayerTechLV >= familyTechLV:
        GameWorld.DebugLog("Íæ¼Òµ±Ç°¿Æ¼¼µÈ¼¶³¬¹ý¸ÃÕ½Ã˵ĿƼ¼µÈ¼¶, ²»¿ÉÉý¼¶!techID=%s,curPlayerTechLV=%s,familyTechLV=%s" 
                           % (techID, curPlayerTechLV, familyTechLV))
        return []
    
    tagTechLV = curPlayerTechLV + 1
    FamilyTechLVUPDict = ReadChConfig.GetEvalChConfig("FamilyTechLVUP")
    techLVUPInfo = FamilyTechLVUPDict.get(tagTechLV)
    if not techLVUPInfo:
        GameWorld.ErrLog("¼Ò×å¿Æ¼¼µÈ¼¶(%s) not in FamilyTechLVUP.txt!" % tagTechLV)
        return []
    
    needContribution = techLVUPInfo[Def_TechLVUP_NeedContribution]
    return [techID, curPlayerTechLV, needContribution]