提交 | 用户 | age
f4f907 1 #!/usr/bin/python
H 2 # -*- coding: GBK -*-
3 #-------------------------------------------------------------------------------
4 #
5 ##@package Player.PlayerLove
6 #
7 # @todo:情缘系统
8 # @author hxp
9 # @date 2021-11-09
10 # @version 1.0
11 #
12 # 详细描述: 情缘系统
13 #
14 #-------------------------------------------------------------------------------
15 #"""Version = 2021-11-09 20:00"""
16 #-------------------------------------------------------------------------------
17
18 import GameWorld
19 import ItemCommon
20 import PlayerControl
21 import IpyGameDataPY
22 import ChPyNetSendPack
ffa8a6 23 import FunctionNPCCommon
f4f907 24 import IPY_GameWorld
H 25 import ItemControler
26 import NetPackCommon
27 import ChConfig
93b6f0 28 import SkillCommon
H 29 import BuffSkill
30 import PyGameData
f4f907 31
8c1ca0 32 def DoPlayerOnDay(curPlayer):
H 33     if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveEatCandyToday):
34         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveEatCandyToday, 0)
35         Sync_LoveInfo(curPlayer)
f4f907 36     return
H 37
38 def DoPlayerLogin(curPlayer):
8c1ca0 39     Sync_LoveInfo(curPlayer)
f4f907 40     Sync_LoveRingInfo(curPlayer)
H 41     return
42
ffa8a6 43 #// B3 10 送礼物 #tagCMSendGifts
f4f907 44 #
ffa8a6 45 #struct    tagCMSendGifts
f4f907 46 #{
H 47 #    tagHead        Head;
48 #    DWORD        TagPlayerID;    // 目标玩家ID
ffa8a6 49 #    WORD        GiftNum;        // 赠送礼物编号
H 50 #    DWORD        GiftCount;    // 赠送礼物数量
51 #    BYTE        IsAutoBuy;    // 是否自动购买
f4f907 52 #};
ffa8a6 53 def OnSendGifts(index, clientData, tick):
f4f907 54     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
H 55     tagPlayerID = clientData.TagPlayerID
ffa8a6 56     giftNum = clientData.GiftNum
H 57     giftCount = clientData.GiftCount
58     isAutoBuy = clientData.IsAutoBuy
f4f907 59     
ffa8a6 60     if giftNum <= 0 or giftCount <= 0:
f4f907 61         return
H 62     
ffa8a6 63     ipyData = IpyGameDataPY.GetIpyGameData("LoveGift", giftNum)
H 64     if not ipyData:
f4f907 65         return
H 66     
ffa8a6 67     giftItemID = ipyData.GetGiftItemID()
H 68     if not ipyData.GetAllowBatch():
69         giftCount = 1 # 不允许批量赠送的默认赠送1个
70         
71     _, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, giftItemID, giftCount)
72     lackCnt = giftCount - bindCnt - unBindCnt
f4f907 73     if lackCnt > 0:
ffa8a6 74         if not isAutoBuy:
H 75             GameWorld.DebugLog("礼物道具不足,无法赠送! giftItemID=%s,giftCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s" 
76                                % (giftItemID, giftCount, bindCnt, unBindCnt, lackCnt))
77             return
78         
79         moneyType = IpyGameDataPY.GetFuncCfg("LoveGift", 1)
80         infoDict = {ChConfig.Def_Cost_Reason_SonKey:giftItemID}
81         if not FunctionNPCCommon.PayAutoBuyItem(curPlayer, {giftItemID:lackCnt}, moneyType, ChConfig.Def_Cost_Love, infoDict, isCheck=True):
82             return
83         
f4f907 84     if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
H 85         PlayerControl.NotifyCode(curPlayer, "RequestLater")
86         return
87     
ffa8a6 88     dataMsg = [tagPlayerID, giftNum, giftItemID, giftCount, isAutoBuy]
H 89     SendToGameServer_Love(curPlayer, "SendGiftsReq", dataMsg)
f4f907 90     return
H 91
92 #// B3 11 提亲 #tagCMMarryReq
93 #
94 #struct    tagCMMarryReq
95 #{
96 #    tagHead        Head;
97 #    DWORD        TagPlayerID;    // 目标玩家ID
98 #    BYTE        BridePriceID;    // 聘礼ID
99 #};
100 def OnMarryReq(index, clientData, tick):
101     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
102     tagPlayerID = clientData.TagPlayerID
103     bridePriceID = clientData.BridePriceID
104     
105     ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID)
106     if not ipyData:
107         return
108     costMoneyInfo = ipyData.GetCostMoneyInfo()
109     if len(costMoneyInfo) != 2:
110         return
111     moneyType, moneyValue = costMoneyInfo
112     
113     if not PlayerControl.HaveMoney(curPlayer, moneyType, moneyValue):
114         return
115     
116     if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
117         PlayerControl.NotifyCode(curPlayer, "RequestLater")
118         return
119     
120     dataMsg = [tagPlayerID, bridePriceID]
121     SendToGameServer_Love(curPlayer, "MarryReq", dataMsg)
122     return
123
124 #// B3 13 吃喜糖 #tagCMMarryEatCandy
125 #
126 #struct    tagCMMarryEatCandy
127 #{
128 #    tagHead        Head;
129 #    DWORD        PlayerIDA;    // 喜糖所属玩家IDA
130 #    DWORD        PlayerIDB;    // 喜糖所属玩家IDB
131 #};
132 def OnMarryEatCandy(index, clientData, tick):
133     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
134     
135     playerIDA = clientData.PlayerIDA
136     playerIDB = clientData.PlayerIDB
137     
138     playerID = curPlayer.GetPlayerID()
139     
8c1ca0 140     EatCandyMax = IpyGameDataPY.GetFuncCfg("LoveCandy", 4)
H 141     if EatCandyMax:
142         eatCandyToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveEatCandyToday)
143         if eatCandyToday >= EatCandyMax:
144             GameWorld.DebugLog("已达今日吃喜糖次数上限. eatCandyToday=%s >= %s" % (eatCandyToday, EatCandyMax), playerID)
145             return
146         
f4f907 147     if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
H 148         PlayerControl.NotifyCode(curPlayer, "RequestLater")
149         return
150     
151     costMoneyType, costMoneyValue = IpyGameDataPY.GetFuncEvalCfg("LoveCandy", 2)
152     playerMoneyValue = PlayerControl.GetMoney(curPlayer, costMoneyType)
153     
154     dataMsg = [playerIDA, playerIDB, playerID, costMoneyType, costMoneyValue, playerMoneyValue]
155     SendToGameServer_Love(curPlayer, "MarryEatCandy", dataMsg)
156     return
157
158
159 #// B3 14 购买婚礼烟花 #tagCMMarryBuyFireworks
160 #
161 #struct    tagCMMarryBuyFireworks
162 #{
163 #    tagHead        Head;
164 #    DWORD        PlayerIDA;    // 喜糖所属玩家IDA
165 #    DWORD        PlayerIDB;    // 喜糖所属玩家IDB
166 #};
167 def OnMarryBuyFireworks(index, clientData, tick):
168     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
169     
170     playerIDA = clientData.PlayerIDA
171     playerIDB = clientData.PlayerIDB
172     
173     playerID = curPlayer.GetPlayerID()
174     
175     costMoneyType, costMoneyValue = IpyGameDataPY.GetFuncEvalCfg("LoveCandyFire", 2)
176     if not PlayerControl.HaveMoney(curPlayer, costMoneyType, costMoneyValue):
177         return
178     playerMoneyValue = PlayerControl.GetMoney(curPlayer, costMoneyType)    
179     
180     if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
181         PlayerControl.NotifyCode(curPlayer, "RequestLater")
182         return
183     
184     dataMsg = [playerIDA, playerIDB, playerID, costMoneyType, costMoneyValue, playerMoneyValue]
185     SendToGameServer_Love(curPlayer, "MarryBuyFireworks", dataMsg)
186     return
187
188 #// B3 15 离婚 #tagCMMarryBreak
189 #
190 #struct    tagCMMarryBreak
191 #{
192 #    tagHead        Head;
193 #    BYTE        BreakType;    // 0-和平离婚;1-强制离婚
194 #};
195 def OnMarryBreak(index, clientData, tick):
196     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
197     breakType = clientData.BreakType
198     playerID = curPlayer.GetPlayerID()
199     
200     moneyType, moneyValue = 0, 0
201     if breakType == 1:
ffa8a6 202         costMoneyInfo = IpyGameDataPY.GetFuncEvalCfg("LoveMarryBreak", 3)
f4f907 203         if len(costMoneyInfo) != 2:
H 204             return
205         moneyType, moneyValue = costMoneyInfo
206         
207         if not PlayerControl.HaveMoney(curPlayer, moneyType, moneyValue):
208             return
209         
210     if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
211         PlayerControl.NotifyCode(curPlayer, "RequestLater")
212         return
213     
ffa8a6 214     dataMsg = [playerID, breakType, moneyType, moneyValue]
f4f907 215     SendToGameServer_Love(curPlayer, "MarryBreakReq", dataMsg)
H 216     return
217
218 def SendToGameServer_Love(curPlayer, msgType, dataMsg):
219     ## 发送信息到跨服服务器
220     msgList = str([msgType, dataMsg])
221     GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetPlayerID(), 0, 0, "Love", msgList, len(msgList))
222     GameWorld.Log("情缘发送GameServer: %s, %s" % (msgType, dataMsg), curPlayer.GetPlayerID())
223     return
224
225 def GameServer_Love_DoLogic(curPlayer, msgData):
226     
227     msgType, dataMsg = msgData[:2]
228     
229     ## 结婚成功
ffa8a6 230     if msgType == "MarrySuccess":
f4f907 231         __DoMarrySuccess(curPlayer, dataMsg)
H 232     
233     ## 离婚成功
234     elif msgType == "ClearCoupleSocial":
235         __ClearCoupleSocial(curPlayer, dataMsg)
93b6f0 236     
H 237     ## 同步亲密度
238     elif msgType == "SyncMapServerIntimacy":
239         SyncMapServerIntimacy(curPlayer, dataMsg)
f4f907 240         
H 241     return
242
243 def GameServer_Love_DoResult(curPlayer, msgData):
244     
245     msgType, dataMsg, ret = msgData
246     
ffa8a6 247     ## 送礼物请求返回
H 248     if msgType == "SendGiftsReq":
f4f907 249         if not ret:
H 250             return
ffa8a6 251         __DoSendGiftsReq(curPlayer, dataMsg)
f4f907 252         
H 253     ## 吃喜糖返回
254     elif msgType == "MarryEatCandy":
255         if not ret:
256             return
257         __DoMarryEatCandy(curPlayer, ret)
258         
259     ## 购买婚礼烟花返回
260     elif msgType == "MarryBuyFireworks":
261         if not ret:
262             return
263         __DoMarryBuyFireworks(curPlayer, ret)
264         
265     ## 离婚请求返回
266     elif msgType == "MarryBreakReq":
267         if not ret:
268             return
269         __DoMarryBreakReq(curPlayer, ret)
270         
271     return
272
ffa8a6 273 def __DoSendGiftsReq(curPlayer, dataMsg):
H 274     ## 送礼物方处理
f4f907 275     
H 276     playerID = curPlayer.GetPlayerID()
ffa8a6 277     tagPlayerID, giftNum, giftItemID, giftCount, isAutoBuy = dataMsg
f4f907 278     
ffa8a6 279     costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, giftItemID, giftCount)
H 280     lackCnt = giftCount - bindCnt - unBindCnt
281     delCnt = giftCount
f4f907 282     if lackCnt > 0:
ffa8a6 283         if not isAutoBuy:
H 284             GameWorld.ErrLog("礼物道具不足,无法赠送! giftItemID=%s,giftCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s" 
285                              % (giftItemID, giftCount, bindCnt, unBindCnt, lackCnt))
286             return
287         
288         moneyType = IpyGameDataPY.GetFuncCfg("LoveGift", 1)
289         infoDict = {ChConfig.Def_Cost_Reason_SonKey:giftItemID}
290         if not FunctionNPCCommon.PayAutoBuyItem(curPlayer, {giftItemID:lackCnt}, moneyType, ChConfig.Def_Cost_Love, infoDict):
291             return
292         delCnt -= lackCnt
293         
294     GameWorld.Log("赠送礼物: tagPlayerID=%s,giftNum=%s,giftItemID=%s,giftCount=%s,isAutoBuy=%s" 
295                   % (tagPlayerID, giftNum, giftItemID, giftCount, isAutoBuy), playerID)
f4f907 296     
ffa8a6 297     # 扣除消耗
H 298     if delCnt > 0:
299         ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, "Love")
300         
301     SendToGameServer_Love(curPlayer, "SendGiftsOK", dataMsg)
f4f907 302     return
H 303
304 def __DoMarryEatCandy(curPlayer, retInfo):
305     ## 执行吃喜糖结果
306     
307     canBuy, isFree, costMoneyType, costMoneyValue, candyItemInfo = retInfo
308     
309     if not isFree:
310         if not PlayerControl.HaveMoney(curPlayer, costMoneyType, costMoneyValue):
311             return
312         
313     if not canBuy:
314         return
315     
8c1ca0 316     updEatCandyToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveEatCandyToday) + 1
H 317     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveEatCandyToday, updEatCandyToday)
318     Sync_LoveInfo(curPlayer)
319     
320     GameWorld.Log("吃喜糖结果: isFree=%s,updEatCandyToday=%s" % (isFree, updEatCandyToday), curPlayer.GetPlayerID())
f4f907 321     
H 322     if not isFree:
323         infoDict = {ChConfig.Def_Cost_Reason_SonKey:"EatCandy"}
324         PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, ChConfig.Def_Cost_Love, infoDict, isMinus=True)
325         
326     ItemControler.GivePlayerItemOrMail(curPlayer, candyItemInfo)
327     return
328     
329 def __DoMarryBuyFireworks(curPlayer, retInfo):
330     ## 执行购买婚礼烟花结果
331     
332     costMoneyType, costMoneyValue = retInfo
333     GameWorld.Log("执行购买婚礼烟花结果: costMoneyType=%s, costMoneyValue=%s" % (costMoneyType, costMoneyValue), curPlayer.GetPlayerID())
334     
335     infoDict = {ChConfig.Def_Cost_Reason_SonKey:"MarryBuyFireworks"}
336     PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, ChConfig.Def_Cost_Love, infoDict, isMinus=True)
337     return
338     
339 def __DoMarryBreakReq(curPlayer, retInfo):
340     ## 离婚请求结果返回
341     
342     costMoneyType, costMoneyValue = retInfo
ffa8a6 343     GameWorld.Log("执行强制离婚请求结果: costMoneyType=%s, costMoneyValue=%s" % (costMoneyType, costMoneyValue), curPlayer.GetPlayerID())
f4f907 344     
H 345     infoDict = {ChConfig.Def_Cost_Reason_SonKey:"MarryBreak"}
346     PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, ChConfig.Def_Cost_Love, infoDict, isMinus=True)
347     return
348
349 def __DoMarrySuccess(curPlayer, dataMsg):
350     ## 执行成亲成功
93b6f0 351     reqPlayerID, bridePriceID, mapServerCoupleInfo, coupleIntimacy = dataMsg
f4f907 352     playerID = curPlayer.GetPlayerID()
ffa8a6 353     PlayerControl.SetCoupleInfo(playerID, mapServerCoupleInfo)
f4f907 354     
93b6f0 355     GameWorld.Log("执行成亲成功! reqPlayerID=%s,bridePriceID=%s,coupleIntimacy=%s" % (reqPlayerID, bridePriceID, coupleIntimacy), playerID)
f4f907 356     
H 357     if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV) == 0:
358         GameWorld.DebugLog("激活情戒!")
359         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingClassLV, 1)
360         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingStarLV, 1)
361         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingEatCount, 0)
362         Sync_LoveRingInfo(curPlayer)
363         
93b6f0 364     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveCoupleIntimacy, coupleIntimacy)
H 365     RefreshCoupleTeamBuff(curPlayer)
366     
f4f907 367     # 提亲的玩家扣除消耗
H 368     if playerID == reqPlayerID:
369         ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID)
370         if ipyData:
371             moneyType, moneyValue = ipyData.GetCostMoneyInfo()
372             infoDict = {ChConfig.Def_Cost_Reason_SonKey:"MarrySuccess", "bridePriceID":bridePriceID}
373             PlayerControl.PayMoney(curPlayer, moneyType, moneyValue, ChConfig.Def_Cost_Love, infoDict, isMinus=True)
374             
375     RefreshLoveAttr(curPlayer)
376     return
377
378 def __ClearCoupleSocial(curPlayer, dataMsg):
379     ## 离婚 - 清除伴侣关系
380     
381     playerID = curPlayer.GetPlayerID()
382     
383     coupleID = PlayerControl.GetCoupleID(curPlayer)
ffa8a6 384     PlayerControl.SetCoupleInfo(playerID, None)
f4f907 385     
H 386     GameWorld.Log("清除伴侣关系成功! coupleID=%s" % (coupleID), playerID)
93b6f0 387     
H 388     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveCoupleIntimacy, 0)
389     RefreshCoupleTeamBuff(curPlayer)
390     
f4f907 391     RefreshLoveAttr(curPlayer)
H 392     return
393
394 #// B3 17 情戒解锁 #tagCMLoveRingUnlock
395 #
396 #struct    tagCMLoveRingUnlock
397 #{
398 #    tagHead        Head;
399 #};
400 def OnLoveRingUnlock(index, clientData, tick):
401     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
402     playerID = curPlayer.GetPlayerID()
403     unlockItemID = IpyGameDataPY.GetFuncCfg("LoveRing", 1)
404     
405     unlockItem = ItemCommon.FindItemInPackByItemID(curPlayer, unlockItemID, IPY_GameWorld.rptItem)
406     if not ItemCommon.CheckItemCanUse(unlockItem):
407         GameWorld.DebugLog("物品解锁情戒缺少道具! unlockItemID=%s" % unlockItemID, playerID)
408         return
409     ItemCommon.DelItem(curPlayer, unlockItem, 1)
410     
411     classLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV)
412     if classLV < 1:
413         GameWorld.DebugLog("物品解锁情戒!", playerID)
414         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingClassLV, 1)
415         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingStarLV, 1)
416         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingEatCount, 0)
417         Sync_LoveRingInfo(curPlayer)
418         RefreshLoveAttr(curPlayer)
419         
420     NetPackCommon.SendFakePack(curPlayer, ChPyNetSendPack.tagMCLoveRingUnlockOK())
421     return
422
423 #// B3 18 情戒升级 #tagCMLoveRingUp
424 #
425 #struct    tagCMLoveRingUp
426 #{
427 #    tagHead        Head;
428 #    DWORD        UseItemCnt;        //消耗材料个数
429 #};
430 def OnLoveRingUp(index, clientData, tick):
431     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
432     costItemCount = clientData.UseItemCnt # 消耗材料个数
433     #isAutoBuy = False # 本功能暂不提供自动购买
434     playerID = curPlayer.GetPlayerID()
435     
436     classLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV)
437     if not classLV:
438         GameWorld.DebugLog("情戒未解锁!", playerID)
439         return
440     
441     starLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingStarLV)
442     curEatItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingEatCount)
443     
444     ringIpyData = IpyGameDataPY.GetIpyGameData("LoveRing", classLV, starLV)
445     if not ringIpyData:
446         return
447     needEatCount = ringIpyData.GetNeedEatCount()
448     
449     if not needEatCount:
450         GameWorld.DebugLog("情戒已满级!classLV=%s,starLV=%s" % (classLV, starLV), playerID)
451         return
452     
453     costItemID = IpyGameDataPY.GetFuncCfg("LoveRing", 2)
454     if not costItemID or costItemCount <= 0:
455         return
456     
457     costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount)
458     lackCnt = costItemCount - bindCnt - unBindCnt
459     if lackCnt > 0:
460         GameWorld.DebugLog("消耗道具不足,无法升级情戒! costItemID=%s,costItemCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s" 
461                            % (costItemID, costItemCount, bindCnt, unBindCnt, lackCnt), playerID)
462         return
463     delCnt = costItemCount
464     
465     updClassLV, updStarLV = classLV, starLV
466     updEatItemCount = curEatItemCount + costItemCount
467     GameWorld.DebugLog("情戒升级: classLV=%s,starLV=%s,curEatItemCount=%s,costItemCount=%s,updEatItemCount=%s,needEatCount=%s" 
468                        % (classLV, starLV, curEatItemCount, costItemCount, updEatItemCount, needEatCount), playerID)
469     
470     ringUpType = ""
471     if updEatItemCount >= needEatCount:
472         ringUpType = "starUp"
473         updStarLV += 1
474         nextRingIpyData = IpyGameDataPY.GetIpyGameDataNotLog("LoveRing", updClassLV, updStarLV)
475         if not nextRingIpyData:
476             updClassLV += 1
477             updStarLV = 1
478             nextRingIpyData = IpyGameDataPY.GetIpyGameData("LoveRing", updClassLV, updStarLV)
479             if not nextRingIpyData:
480                 GameWorld.ErrLog("情戒升级数据异常: classLV=%s,starLV=%s,curEatItemCount=%s,costItemCount=%s,updEatItemCount=%s,needEatCount=%s" 
481                        % (classLV, starLV, curEatItemCount, costItemCount, updEatItemCount, needEatCount), playerID)
482                 return
483             ringUpType = "classUp"
484         updEatItemCount -= needEatCount
485         
486     # 扣除消耗
487     if delCnt:
ffa8a6 488         ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, "Love")
f4f907 489         
H 490     # 升星
491     if ringUpType == "starUp":
492         GameWorld.DebugLog("    升星: updClassLV=%s,updStarLV=%s,updEatItemCount=%s" % (updClassLV, updStarLV, updEatItemCount), playerID)
493         
494     # 升阶
495     elif ringUpType == "classUp":
496         GameWorld.DebugLog("    升阶: updClassLV=%s,updStarLV=%s,updEatItemCount=%s" % (updClassLV, updStarLV, updEatItemCount), playerID)
497         
498     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingClassLV, updClassLV)
499     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingStarLV, updStarLV)
500     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingEatCount, updEatItemCount)
501     
502     Sync_LoveRingInfo(curPlayer)
503     RefreshLoveAttr(curPlayer)
504     return
505
506 def RefreshLoveAttr(curPlayer):
507     CalcLoveAttr(curPlayer)
508     PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
509     return
510
511 def CalcLoveAttr(curPlayer):
512     
513     classLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV)
514     starLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingStarLV)
515     
516     coupleID = PlayerControl.GetCoupleID(curPlayer)
517     
518     allAttrList = [{} for _ in range(4)]
519     allAttrListCouple = [{} for _ in range(4)]
520     
521     ipyDataMgr = IpyGameDataPY.IPY_Data()
522     for index in xrange(ipyDataMgr.GetLoveRingCount()):
523         ringIpyData = ipyDataMgr.GetLoveRingByIndex(index)
524         dataClassLV = ringIpyData.GetRingClassLV()
525         dataStarLV = ringIpyData.GetRingStarLV()
526         if dataClassLV > classLV or (dataClassLV == classLV and dataStarLV > starLV):
527             break
528         elif dataClassLV == classLV and dataStarLV == starLV:
529             upItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingEatCount)
530         else:
531             upItemCount = ringIpyData.GetNeedEatCount()
532             
533         # 阶星属性
534         starAttrTypeList = ringIpyData.GetStarAttrType()
535         starAttrValueList = ringIpyData.GetStarAttrValue()
536         for i, attrID in enumerate(starAttrTypeList):
537             attrValue = starAttrValueList[i]
538             PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
539         
540         # 升级个数属性
541         upItemPerCount = ringIpyData.GetUpEatItemPerCount()
542         if upItemCount and upItemPerCount:
543             upItemAttrTypeList = ringIpyData.GetUpItemAttrType()
544             upItemAttrValueList = ringIpyData.GetUpItemAttrValue()
545             attrMultiple = upItemCount / upItemPerCount
546             for i, attrID in enumerate(upItemAttrTypeList):
547                 attrValue = upItemAttrValueList[i]
548                 PlayerControl.CalcAttrDict_Type(attrID, attrValue * attrMultiple, allAttrList)
549                 
550         # 仙侣属性
551         if coupleID:
552             coupleAttrTypeList = ringIpyData.GetCoupleAttrType()
553             coupleAttrValueList = ringIpyData.GetCoupleAttrValue()
554             for i, attrID in enumerate(coupleAttrTypeList):
555                 attrValue = coupleAttrValueList[i]
556                 PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrListCouple)
557                 
558     #GameWorld.DebugLog("情戒基础属性: classLV=%s,starLV=%s,allAttrList=%s" % (classLV, starLV, allAttrList))
559     #GameWorld.DebugLog("情戒仙侣属性: classLV=%s,starLV=%s,allAttrListCouple=%s" % (classLV, starLV, allAttrListCouple))
560     
561     # 保存计算值
562     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_LoveRing, allAttrList)
563     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_LoveRingCouple, allAttrListCouple)
564     return
565
566 def Sync_LoveRingInfo(curPlayer):
567     ## 同步情戒信息
568     clientPack = ChPyNetSendPack.tagMCLoveRingInfo()
569     clientPack.ClassLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV)
570     clientPack.StarLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingStarLV)
571     clientPack.EatCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingEatCount)
572     NetPackCommon.SendFakePack(curPlayer, clientPack)
573     return
574
8c1ca0 575 def Sync_LoveInfo(curPlayer):
H 576     ## 同步情缘相关信息
577     clientPack = ChPyNetSendPack.tagMCLoveInfo()
578     clientPack.EatCandyToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveEatCandyToday)
579     NetPackCommon.SendFakePack(curPlayer, clientPack)
580     return
581
93b6f0 582 def SyncMapServerIntimacy(curPlayer, dataMsg):
H 583     tagID, intimacyValue = dataMsg
584     coupleID = PlayerControl.GetCoupleID(curPlayer)
585     if coupleID == tagID:
586         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveCoupleIntimacy, intimacyValue)
587         RefreshCoupleTeamBuff(curPlayer)
588     return
589
590 def RefreshCoupleTeamBuff(curPlayer):
591     ## 刷新伴侣组队buff
592     
593     teamID = curPlayer.GetTeamID()
594     playerID = curPlayer.GetPlayerID()
595     cupleID = PlayerControl.GetCoupleID(curPlayer)
596     teamPlayerInfoDict = PyGameData.g_teamPlayerInfoDict.get(teamID, {}) if teamID else {}
597     teamPlayerIDList = teamPlayerInfoDict.keys()
598     skillLV = 0
599     skillTypeID = IpyGameDataPY.GetFuncCfg("IntimacyBuff", 2)
600     coupleIntimacy = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveCoupleIntimacy)
601     if cupleID and cupleID in teamPlayerIDList:
602         skillLVIntimacyList = IpyGameDataPY.GetFuncEvalCfg("IntimacyBuff", 1)
603         for lv, lvIntimacy in enumerate(skillLVIntimacyList, 1):
604             if coupleIntimacy >= lvIntimacy:
605                 skillLV = lv
606             else:
607                 break
608             
609     GameWorld.DebugLog("刷新伴侣组队Buff: cupleID=%s,coupleIntimacy=%s,teamID=%s,teamPlayerIDList=%s,skillTypeID=%s,skillLV=%s" 
610                        % (cupleID, coupleIntimacy, teamID, teamPlayerIDList, skillTypeID, skillLV), playerID)
611     tick = GameWorld.GetGameWorld().GetTick()
612     if skillLV > 0:
613         findBuff = SkillCommon.FindBuffByID(curPlayer, skillTypeID)[0]
614         if findBuff:
615             if skillLV == findBuff.GetSkill().GetSkillLV():
616                 return
617             BuffSkill.DelBuffBySkillID(curPlayer, skillTypeID, tick)
618         SkillCommon.AddBuffBySkillType(curPlayer, skillTypeID, tick, skillLV)
619     else:
620         if BuffSkill.DelBuffBySkillID(curPlayer, skillTypeID, tick):
621             #统一刷新状态
622             playerControl = PlayerControl.PlayerControl(curPlayer)
623             playerControl.RefreshPlayerAttrByBuff()
624             
625     return