提交 | 用户 | age
|
64bd5a
|
1 |
#!/usr/bin/python
|
H |
2 |
# -*- coding: GBK -*-
|
|
3 |
#-------------------------------------------------------------------------------
|
|
4 |
#
|
|
5 |
##@package Player.PlayerActGubao
|
|
6 |
#
|
|
7 |
# @todo:古宝养成活动
|
|
8 |
# @author hxp
|
|
9 |
# @date 2024-08-12
|
|
10 |
# @version 1.0
|
|
11 |
#
|
|
12 |
# 详细描述: 古宝养成活动
|
|
13 |
#
|
|
14 |
#-------------------------------------------------------------------------------
|
|
15 |
#"""Version = 2024-08-12 19:30"""
|
|
16 |
#-------------------------------------------------------------------------------
|
|
17 |
|
|
18 |
import PyGameData
|
|
19 |
import ShareDefine
|
|
20 |
import PlayerControl
|
|
21 |
import IpyGameDataPY
|
|
22 |
import CrossRealmPlayer
|
c7be7c
|
23 |
import FunctionNPCCommon
|
64bd5a
|
24 |
import PlayerBillboard
|
H |
25 |
import ChPyNetSendPack
|
8b266c
|
26 |
import PlayerZhanling
|
64bd5a
|
27 |
import NetPackCommon
|
H |
28 |
import GameWorld
|
|
29 |
import ChConfig
|
|
30 |
|
|
31 |
def OnMixFirstLogin(curPlayer):
|
|
32 |
|
|
33 |
for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_Gubao, {}).values():
|
|
34 |
actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
|
35 |
if not actInfo.get(ShareDefine.ActKey_State):
|
|
36 |
continue
|
|
37 |
score = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActGubaoScore % actNum)
|
|
38 |
if not score:
|
|
39 |
continue
|
|
40 |
GameWorld.Log("古宝养成合服首登同步积分榜单: actNum=%s,score=%s" % (actNum, score), curPlayer.GetPlayerID())
|
|
41 |
PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_GubaoScore, score, autoSort=True)
|
|
42 |
break
|
|
43 |
|
|
44 |
return
|
|
45 |
|
|
46 |
def OnPlayerLogin(curPlayer):
|
|
47 |
|
|
48 |
for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_Gubao, {}).values():
|
|
49 |
actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
|
50 |
isReset = __CheckPlayerGubaoAction(curPlayer, actNum)
|
|
51 |
if not isReset:
|
|
52 |
# 活动中同步活动信息
|
|
53 |
if actInfo.get(ShareDefine.ActKey_State):
|
|
54 |
Sync_GubaoActionInfo(curPlayer, actNum)
|
|
55 |
Sync_GubaoPlayerInfo(curPlayer, actNum)
|
|
56 |
|
|
57 |
if not __CheckPlayerCrossActGubao(curPlayer):
|
|
58 |
Sync_CrossActGubaoActionInfo(curPlayer)
|
|
59 |
|
|
60 |
return
|
|
61 |
|
|
62 |
def RefreshGubaoActionInfo(actNum):
|
|
63 |
## 收到GameServer同步的活动信息,刷新活动信息
|
|
64 |
playerManager = GameWorld.GetPlayerManager()
|
|
65 |
for index in xrange(playerManager.GetPlayerCount()):
|
|
66 |
curPlayer = playerManager.GetPlayerByIndex(index)
|
8f7a29
|
67 |
if not GameWorld.IsNormalPlayer(curPlayer):
|
64bd5a
|
68 |
continue
|
H |
69 |
__CheckPlayerGubaoAction(curPlayer, actNum)
|
|
70 |
return
|
|
71 |
|
|
72 |
def __CheckPlayerGubaoAction(curPlayer, actNum):
|
|
73 |
## 检查玩家活动数据信息
|
|
74 |
|
|
75 |
playerID = curPlayer.GetPlayerID()
|
|
76 |
actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_Gubao, actNum)
|
|
77 |
actID = actInfo.get(ShareDefine.ActKey_ID, 0)
|
|
78 |
state = actInfo.get(ShareDefine.ActKey_State, 0)
|
|
79 |
cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
|
80 |
|
|
81 |
playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActGubaoID % actNum) # 玩家身上的活动ID
|
|
82 |
|
|
83 |
# 活动ID 相同的话不处理
|
|
84 |
if actID == playerActID:
|
|
85 |
GameWorld.DebugLog("古宝养成活动ID不变,不处理!actNum=%s,actID=%s" % (actNum, actID), playerID)
|
|
86 |
return
|
|
87 |
|
|
88 |
GameWorld.DebugLog("古宝养成重置! actNum=%s,actID=%s,playerActID=%s,state=%s,cfgID=%s"
|
|
89 |
% (actNum, actID, playerActID, state, cfgID), playerID)
|
8b266c
|
90 |
score = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActGubaoScore % actNum)
|
H |
91 |
PlayerZhanling.ResetZhanling(curPlayer, PlayerZhanling.ZhanlingType_GubaoTrain, score)
|
64bd5a
|
92 |
|
H |
93 |
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActGubaoID % actNum, actID)
|
|
94 |
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActGubaoScore % actNum, 0)
|
|
95 |
|
|
96 |
if state:
|
c7be7c
|
97 |
cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
H |
98 |
ipyData = IpyGameDataPY.GetIpyGameData("ActGubao", cfgID)
|
|
99 |
if ipyData and ipyData.GetActShopType():
|
|
100 |
FunctionNPCCommon.ResetShopItemBuyCountByShopType(curPlayer, [ipyData.GetActShopType()])
|
64bd5a
|
101 |
Sync_GubaoActionInfo(curPlayer, actNum)
|
H |
102 |
Sync_GubaoPlayerInfo(curPlayer, actNum)
|
|
103 |
return True
|
|
104 |
|
|
105 |
def RefreshCrossActGubaoInfo():
|
|
106 |
## 收到GameServer同步的活动信息,刷新活动信息
|
|
107 |
playerManager = GameWorld.GetPlayerManager()
|
|
108 |
for index in xrange(playerManager.GetPlayerCount()):
|
|
109 |
curPlayer = playerManager.GetPlayerByIndex(index)
|
8f7a29
|
110 |
if not GameWorld.IsNormalPlayer(curPlayer):
|
64bd5a
|
111 |
continue
|
H |
112 |
__CheckPlayerCrossActGubao(curPlayer)
|
|
113 |
|
|
114 |
return
|
|
115 |
|
|
116 |
def __CheckPlayerCrossActGubao(curPlayer):
|
|
117 |
|
|
118 |
playerID = curPlayer.GetPlayerID()
|
|
119 |
|
|
120 |
actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_Gubao)
|
|
121 |
cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
|
122 |
actID = actInfo.get(ShareDefine.ActKey_ID, 0)
|
|
123 |
state = actInfo.get(ShareDefine.ActKey_State, 0)
|
|
124 |
dayIndex = actInfo.get(ShareDefine.ActKey_DayIndex, 0)
|
|
125 |
|
|
126 |
playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CA_GubaoID) # 玩家身上的活动ID
|
|
127 |
|
|
128 |
# 活动ID 相同的话不处理
|
|
129 |
if actID == playerActID:
|
|
130 |
GameWorld.DebugLog("跨服古宝养成活动ID不变,不处理!cfgID=%s,dayIndex=%s,actID=%s" % (cfgID, dayIndex, actID), playerID)
|
|
131 |
return
|
|
132 |
GameWorld.DebugLog("跨服古宝养成活动重置! cfgID=%s,actID=%s,playerActID=%s,state=%s" % (cfgID, actID, playerActID, state), playerID)
|
|
133 |
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CA_GubaoID, actID)
|
|
134 |
|
|
135 |
if not state:
|
|
136 |
CrossRealmPlayer.NotifyCrossActEnd(curPlayer, ShareDefine.CrossActName_Gubao)
|
|
137 |
|
|
138 |
Sync_CrossActGubaoActionInfo(curPlayer)
|
|
139 |
return True
|
|
140 |
|
|
141 |
def OnGubaoCost(curPlayer, costPieceInfo, costItemList):
|
|
142 |
|
|
143 |
playerID = curPlayer.GetPlayerID()
|
|
144 |
for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_Gubao, {}).values():
|
|
145 |
actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
|
146 |
if not actInfo.get(ShareDefine.ActKey_State):
|
|
147 |
continue
|
|
148 |
|
a49287
|
149 |
cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
H |
150 |
ipyData = IpyGameDataPY.GetIpyGameData("ActGubao", cfgID)
|
|
151 |
if not ipyData:
|
|
152 |
continue
|
|
153 |
|
|
154 |
if ipyData.GetIsRelationCrossAct():
|
|
155 |
crossActInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_Gubao)
|
|
156 |
if crossActInfo.get(ShareDefine.ActKey_State, 0):
|
|
157 |
if crossActInfo.get(ShareDefine.ActKey_StateJoin) != ShareDefine.ActStateJoin_Start:
|
|
158 |
GameWorld.Log("跨服古宝养成非参与活动中: actNum=%s" % actNum, playerID)
|
|
159 |
continue
|
64bd5a
|
160 |
else:
|
H |
161 |
if actInfo.get(ShareDefine.ActKey_StateJoin) != ShareDefine.ActStateJoin_Start:
|
|
162 |
GameWorld.Log("古宝养成非参与活动中: actNum=%s" % actNum, playerID)
|
|
163 |
continue
|
|
164 |
|
|
165 |
addGubaoScore = 0
|
|
166 |
pieceQualityScoreDict = IpyGameDataPY.GetFuncEvalCfg("GubaoAct", 1, {})
|
|
167 |
for pieceID, pieceCount in costPieceInfo.items():
|
a49287
|
168 |
gbIpyData = IpyGameDataPY.GetIpyGameData("Gubao", pieceID)
|
H |
169 |
if not gbIpyData:
|
64bd5a
|
170 |
continue
|
a49287
|
171 |
quality = gbIpyData.GetGubaoQuality()
|
64bd5a
|
172 |
if str(quality) not in pieceQualityScoreDict:
|
H |
173 |
continue
|
|
174 |
qualityScore = pieceQualityScoreDict[str(quality)] * pieceCount
|
|
175 |
addGubaoScore += qualityScore
|
|
176 |
GameWorld.DebugLog("古宝活动碎片积分统计: actNum=%s,pieceID=%s,quality=%s,pieceCount=%s,qualityScore=%s, %s"
|
|
177 |
% (actNum, pieceID, quality, pieceCount, qualityScore, addGubaoScore))
|
|
178 |
|
|
179 |
otherAddScore = IpyGameDataPY.GetFuncCfg("GubaoAct", 2)
|
|
180 |
for itemID, costCount in costItemList:
|
|
181 |
otherScore = costCount * otherAddScore
|
|
182 |
addGubaoScore += otherScore
|
|
183 |
GameWorld.DebugLog("古宝活动其他积分统计: actNum=%s,itemID=%s,costCount=%s,otherScore=%s, %s"
|
|
184 |
% (actNum, itemID, costCount, otherScore, addGubaoScore))
|
|
185 |
|
|
186 |
if addGubaoScore <= 0:
|
|
187 |
continue
|
|
188 |
|
a49287
|
189 |
AddPlayerScore(curPlayer, actNum, addGubaoScore, ipyData.GetIsRelationCrossAct())
|
64bd5a
|
190 |
|
H |
191 |
return
|
|
192 |
|
a49287
|
193 |
def AddPlayerScore(curPlayer, actNum, addScore, isRelationCrossAct):
|
64bd5a
|
194 |
if addScore <= 0:
|
H |
195 |
return 0
|
|
196 |
score = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActGubaoScore % actNum)
|
|
197 |
updScore = score + addScore
|
|
198 |
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActGubaoScore % actNum, updScore)
|
|
199 |
GameWorld.DebugLog("古宝活动增加积分: actNum=%s,addScore=%s,updScore=%s" % (actNum, addScore, updScore))
|
|
200 |
Sync_GubaoPlayerInfo(curPlayer, actNum)
|
8b266c
|
201 |
PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_GubaoTrainScore, addScore, "ActGubaoTrain")
|
64bd5a
|
202 |
PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_GubaoScore, updScore, autoSort=True)
|
a49287
|
203 |
SendToGameServer_Gubao(curPlayer, "AddGubaoScore", [addScore, updScore, isRelationCrossAct])
|
64bd5a
|
204 |
return updScore
|
H |
205 |
|
|
206 |
def SendToGameServer_Gubao(curPlayer, msgType, dataMsg=""):
|
|
207 |
playerID = curPlayer.GetPlayerID()
|
|
208 |
msgList = str([msgType, dataMsg])
|
|
209 |
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(playerID, 0, 0, "ActGubao", msgList, len(msgList))
|
|
210 |
GameWorld.Log("古宝养成发送GameServer: %s, %s" % (msgType, dataMsg), playerID)
|
|
211 |
return
|
|
212 |
|
8b266c
|
213 |
def GetActGubaoTrainScore(curPlayer):
|
H |
214 |
## 获取活动中养成积分
|
|
215 |
actScore = 0
|
|
216 |
for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_Gubao, {}).values():
|
|
217 |
actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
|
218 |
if not actInfo.get(ShareDefine.ActKey_State):
|
|
219 |
continue
|
|
220 |
score = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActGubaoScore % actNum)
|
|
221 |
actScore = max(score, actScore)
|
|
222 |
return actScore
|
|
223 |
|
64bd5a
|
224 |
def Sync_GubaoActionInfo(curPlayer, actNum):
|
H |
225 |
## 通知活动信息
|
|
226 |
|
|
227 |
actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_Gubao, actNum)
|
|
228 |
if not actInfo.get(ShareDefine.ActKey_State):
|
|
229 |
return
|
|
230 |
|
|
231 |
cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
|
232 |
ipyData = IpyGameDataPY.GetIpyGameData("ActGubao", cfgID)
|
|
233 |
if not ipyData:
|
|
234 |
return
|
|
235 |
|
|
236 |
personalTempID = ipyData.GetPersonalTemplateID()
|
|
237 |
personalTempIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActGubaoBillTemp", personalTempID) if personalTempID else []
|
|
238 |
|
|
239 |
startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData)
|
|
240 |
|
|
241 |
clientPack = ChPyNetSendPack.tagMCActGubaoInfo()
|
|
242 |
clientPack.ActNum = actNum
|
|
243 |
clientPack.StartDate = startDateStr
|
|
244 |
clientPack.EndtDate = endDateStr
|
|
245 |
clientPack.JoinStartTime = ipyData.GetJoinStartTime()
|
|
246 |
clientPack.JoinEndTime = ipyData.GetJoinEndTime()
|
|
247 |
clientPack.LimitLV = ipyData.GetLVLimit()
|
c7be7c
|
248 |
clientPack.ShopType = ipyData.GetActShopType()
|
64bd5a
|
249 |
|
H |
250 |
clientPack.PersonalBillboardInfoList = __GetTempRankBillPackList(personalTempIpyDataList)
|
|
251 |
clientPack.PersonalBillCount = len(clientPack.PersonalBillboardInfoList)
|
|
252 |
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
|
253 |
return
|
|
254 |
|
|
255 |
def Sync_GubaoPlayerInfo(curPlayer, actNum):
|
|
256 |
|
|
257 |
actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_Gubao, actNum)
|
|
258 |
if not actInfo.get(ShareDefine.ActKey_State):
|
|
259 |
return
|
|
260 |
|
|
261 |
clientPack = ChPyNetSendPack.tagMCActGubaoPlayerInfo()
|
|
262 |
clientPack.ActNum = actNum
|
|
263 |
clientPack.Score = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActGubaoScore % actNum)
|
|
264 |
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
|
265 |
return
|
|
266 |
|
|
267 |
def Sync_CrossActGubaoActionInfo(curPlayer):
|
|
268 |
## 通知活动信息
|
|
269 |
actInfo = CrossRealmPlayer.GetPlayerCrossActInfo(curPlayer, ShareDefine.CrossActName_Gubao)
|
|
270 |
if not actInfo:
|
|
271 |
return
|
|
272 |
|
|
273 |
if not actInfo.get(ShareDefine.ActKey_State):
|
|
274 |
return
|
|
275 |
|
|
276 |
ipyDataDict = actInfo.get(ShareDefine.ActKey_IpyDataInfo, {})
|
|
277 |
if not ipyDataDict:
|
|
278 |
return
|
|
279 |
|
|
280 |
personalTempID = ipyDataDict.get("PersonalTemplateID", 0)
|
|
281 |
personalTempIpyDataList = IpyGameDataPY.GetIpyGameDataList("ActGubaoBillTemp", personalTempID) if personalTempID else []
|
|
282 |
|
|
283 |
clientPack = ChPyNetSendPack.tagMCCrossActGubaoInfo()
|
|
284 |
clientPack.ServerIDRangeInfo = str(actInfo.get(ShareDefine.ActKey_ServerIDRangeList, []))
|
|
285 |
clientPack.ServerInfoLen = len(clientPack.ServerIDRangeInfo)
|
|
286 |
clientPack.GroupValue1 = ipyDataDict.get("ZoneID", 0)
|
|
287 |
clientPack.StartDate = ipyDataDict.get("StartDate", "")
|
|
288 |
clientPack.EndtDate = ipyDataDict.get("EndDate", "")
|
|
289 |
clientPack.JoinStartTime = ipyDataDict.get("JoinStartTime", "")
|
|
290 |
clientPack.JoinEndTime = ipyDataDict.get("JoinEndTime", "")
|
|
291 |
|
|
292 |
clientPack.PersonalBillboardInfoList = __GetTempRankBillPackList(personalTempIpyDataList)
|
|
293 |
clientPack.PersonalBillCount = len(clientPack.PersonalBillboardInfoList)
|
|
294 |
|
|
295 |
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
|
296 |
return
|
|
297 |
|
|
298 |
def __GetTempRankBillPackList(ipyDataList):
|
|
299 |
packBillList = []
|
|
300 |
if not ipyDataList:
|
|
301 |
return packBillList
|
|
302 |
for tempIpyData in ipyDataList:
|
|
303 |
rankInfo = ChPyNetSendPack.tagMCActGubaoBillard()
|
|
304 |
rankInfo.Rank = tempIpyData.GetRank()
|
|
305 |
|
|
306 |
rankInfo.AwardItemList = []
|
|
307 |
awardItemList = tempIpyData.GetAwardItemList()
|
|
308 |
for itemID, itemCount, isAuctionItem in awardItemList:
|
|
309 |
item = ChPyNetSendPack.tagMCActGubaoItem()
|
|
310 |
item.Clear()
|
|
311 |
item.ItemID = itemID
|
|
312 |
item.ItemCount = itemCount
|
|
313 |
item.IsBind = isAuctionItem
|
|
314 |
rankInfo.AwardItemList.append(item)
|
|
315 |
rankInfo.Count = len(rankInfo.AwardItemList)
|
|
316 |
|
|
317 |
# rankInfo.MemAwardItemList = []
|
|
318 |
# memAwardItemList = tempIpyData.GetMemAwardItemList()
|
|
319 |
# for itemID, itemCount, isAuctionItem in memAwardItemList:
|
|
320 |
# item = ChPyNetSendPack.tagMCActGubaoItem()
|
|
321 |
# item.Clear()
|
|
322 |
# item.ItemID = itemID
|
|
323 |
# item.ItemCount = itemCount
|
|
324 |
# item.IsBind = isAuctionItem
|
|
325 |
# rankInfo.MemAwardItemList.append(item)
|
|
326 |
# rankInfo.MemCount = len(rankInfo.MemAwardItemList)
|
|
327 |
|
82a9f8
|
328 |
rankInfo.NeedScore = tempIpyData.GetNeedScore()
|
H |
329 |
rankInfo.AwardItemExList = []
|
|
330 |
scoreAwardEx = tempIpyData.GetScoreAwardEx()
|
|
331 |
scoreExList = scoreAwardEx.keys()
|
|
332 |
scoreExList.sort()
|
|
333 |
for scoreEx in scoreExList:
|
|
334 |
itemExList = scoreAwardEx[scoreEx]
|
|
335 |
awardEx = ChPyNetSendPack.tagMCActGubaoAwardEx()
|
|
336 |
awardEx.NeedScore = scoreEx
|
|
337 |
awardEx.AwardItemList = []
|
|
338 |
for itemID, itemCount, isAuctionItem in itemExList:
|
|
339 |
item = ChPyNetSendPack.tagMCActGubaoItem()
|
|
340 |
item.Clear()
|
|
341 |
item.ItemID = itemID
|
|
342 |
item.ItemCount = itemCount
|
|
343 |
item.IsBind = isAuctionItem
|
|
344 |
awardEx.AwardItemList.append(item)
|
|
345 |
awardEx.Count = len(awardEx.AwardItemList)
|
|
346 |
|
|
347 |
rankInfo.AwardItemExList.append(awardEx)
|
|
348 |
rankInfo.CountEx = len(rankInfo.AwardItemExList)
|
|
349 |
|
64bd5a
|
350 |
packBillList.append(rankInfo)
|
H |
351 |
return packBillList
|