#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package PlayerLove # # @todo:ÇéԵϵͳ # @author hxp # @date 2021-11-09 # @version 1.0 # # ÏêϸÃèÊö: ÇéԵϵͳ # #------------------------------------------------------------------------------- #"""Version = 2021-11-09 20:00""" #------------------------------------------------------------------------------- import GameWorld import PyDataManager import PlayerControl import ChPyNetSendPack import PlayerCompensation import PlayerFamilyRedPacket import PyGameDataStruct import NetPackCommon import IpyGameDataPY import PlayerSocial import PlayerCharm import ShareDefine import PyGameData import CommFunc import operator import time import math class MarryReq(): ## ½øÐÐÖеÄÇóÇ×£¬²»´æµµ£¬»ØÓ¦·½ÉÏÏßÒ²²»Í¨Öª£¬½öË«·½¶¼ÔÚÏßʱͬ²½´¦Àí£¬·þÎñÆ÷ά»¤²»´æµµ£¬ÖØÐÂÇëÇó def __init__(self): self.playerIDA = 0 # ÇëÇó·½ self.playerIDB = 0 # »ØÓ¦·½ self.bridePriceID = 0 # ƸÀñID self.reqTime = 0 # ÇëÇóʱ¼ä´Á return class MarryCandy(): ## ϲÌÇÑç»á£¬²»´æ¿â£¬·þÎñÆ÷¹Ø·þʱδ½áÊøµÄϲÑçÇ¿ÖÆ½áËã def __init__(self): self.playerIDA = 0 self.playerNameA = "" self.playerIDB = 0 self.playerNameB = "" self.bridePriceID = 0 # ƸÀñID self.marryTime = 0 # ³ÉÇ×ʱ¼ä´Á self.endTime = 0 # ½áËãʱ¼ä´Á self.prosperity = 0 # ×Ü·±ÈÙ¶È self.prosperitySuccessList = [] # ·±ÈÙ¶È´ï±ê³É¾ÍÒÑ´¦ÀíÖµ self.playerFreeEatCountDict = {} # Íæ¼ÒÃâ·Ñ³ÔϲÌÇ´ÎÊý {playerID:´ÎÊý, ...} self.fireworksCountDict = {} # ÑÌ»¨´ÎÊýÐÅÏ¢ {playerID:´ÎÊý, ...} return class PlayerCouple(): def __init__(self, coupleData): self.coupleData = coupleData # PyGameDataStruct.tagDBPyCouple() # ¸üÐÂ×î´óƸÀñID self.BridePriceMaxID = 0 maxCount = IpyGameDataPY.IPY_Data().GetMarryCount() for index in range(maxCount)[::-1]: ipyData = IpyGameDataPY.IPY_Data().GetMarryByIndex(index) priceID = ipyData.GetBridePriceID() if self.GetBridePriceBuyCount(priceID): self.BridePriceMaxID = priceID break return def GetCoupleID(self, playerID): return self.coupleData.PlayerIDA if (playerID == self.coupleData.PlayerIDB) else self.coupleData.PlayerIDB def GetCoupleName(self, playerID): return PlayerSocial.GetSocialPlayerName(self.GetCoupleID(playerID)) def GetCoupleJob(self, playerID): return PlayerSocial.GetSocialPlayerJob(self.GetCoupleID(playerID)) def GetNewMarryTime(self): return self.coupleData.NewMarryTime def GetMarryTime(self): return self.coupleData.MarryTime def GetBridePriceState(self): return self.coupleData.BridePriceState def GetBridePriceBuyCount(self, priceID): return GameWorld.GetDataByDigitPlace(self.coupleData.BridePriceState, priceID - 1) def SetBridePriceBuyCount(self, priceID, buyCount): self.coupleData.BridePriceState = GameWorld.ChangeDataByDigitPlace(self.coupleData.BridePriceState, priceID - 1, min(buyCount, 9)) return self.coupleData.BridePriceState def GetBreakRequestID(self): return self.coupleData.BreakRequestID def GetBreakRequestTime(self): return self.coupleData.BreakRequestTime def SetBreakRequestID(self, reqID): self.coupleData.BreakRequestID = reqID self.coupleData.BreakRequestTime = 0 if reqID > 0: curTime = int(time.time()) self.coupleData.BreakRequestTime = curTime if reqID == self.coupleData.PlayerIDA: self.coupleData.BreakRequestTimeA = curTime else: self.coupleData.BreakRequestTimeB = curTime return def GetPlayerBreakRequestTime(self, playerID): return self.coupleData.BreakRequestTimeA if (playerID == self.coupleData.PlayerIDA) else self.coupleData.BreakRequestTimeB def GetSendMapServerCoupleInfo(self, playerID): coupleID = self.GetCoupleID(playerID) coupleName = self.GetCoupleName(playerID) coupleJob = self.GetCoupleJob(playerID) bridePriceMaxID = self.BridePriceMaxID return coupleID, coupleName, coupleJob, bridePriceMaxID class DBPyCoupleManager(object): ## °éÂÂÊý¾Ý¹ÜÀí def __init__(self): self.coupleDict = {} # {(playerIDA, playerIDB):PlayerCouple, ...} self.coupleIDDict = {} # {playerID:(playerIDA, playerIDB), ...} # °é¶ÔÓ¦¹ØÏµ return def DelCouple(self, playerIDA, playerIDB): ## ɾ³ý°éÂÂÊý¾Ý£¬Èç¹ûÒÑÀë»éÇÒ¾ùÒÑ֪ͨ£¬Ôò¿ÉÖ±½Óɾ³ý key = (playerIDA, playerIDB) if key in self.coupleDict: self.coupleDict.pop(key) if playerIDA in self.coupleIDDict and self.coupleIDDict[playerIDA] == key: self.coupleIDDict.pop(playerIDA) if playerIDB in self.coupleIDDict and self.coupleIDDict[playerIDB] == key: self.coupleIDDict.pop(playerIDB) return def AddCouple(self, playerIDA, playerIDB, coupleData): ## Ìí¼Óаé coupleKey = (playerIDA, playerIDB) couple = PlayerCouple(coupleData) self.coupleDict[coupleKey] = couple self.coupleIDDict[playerIDA] = coupleKey self.coupleIDDict[playerIDB] = coupleKey return couple def GetCouple(self, playerID): ## »ñÈ¡°é coupleData = None # ²»¿ÉÄܳÉÁ¢µÄÌõ¼þ£¬Ö»ÊÇΪÁË. Äܳö´úÂëÌáʾָÏò PlayerCouple Àà if False: coupleData = PlayerCouple(None) if playerID not in self.coupleIDDict: return coupleData coupleKey = self.coupleIDDict[playerID] if coupleKey not in self.coupleDict: return coupleData coupleData = self.coupleDict[coupleKey] return coupleData def SendMapServerCoupleInfo(self, syncPlayerIDList=None): ## ͬ²½µØÍ¼°éÂÂÐÅÏ¢ syncCoupleInfo = {} if syncPlayerIDList == None: syncPlayerIDList = self.coupleIDDict.keys() # ·ÖÅúͬ²½£¬×Ó·þ³¤¶È²»Äܳ¬¹ý 65535£¬Ã¿ÅúÔݶ¨×î´óͬ²½1000¸ö for playerID in syncPlayerIDList: couple = self.GetCouple(playerID) if not couple: syncCoupleInfo[playerID] = [] else: syncCoupleInfo[playerID] = couple.GetSendMapServerCoupleInfo(playerID) if len(syncCoupleInfo) >= 1000: GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_CoupleInfo, syncCoupleInfo) syncCoupleInfo = {} if not syncCoupleInfo: return GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_CoupleInfo, syncCoupleInfo) return # ±£´æÊý¾Ý ´æÊý¾Ý¿âºÍrealtimebackup def GetSaveData(self): savaData = "" cntData = "" cnt = 0 for couple in self.coupleDict.values(): cnt += 1 savaData += couple.coupleData.getBuffer() GameWorld.Log("Save DBPyMarry count :%s len=%s" % (cnt, len(savaData))) return CommFunc.WriteDWORD(cntData, cnt) + savaData # ´ÓÊý¾Ý¿âÔØÈëÊý¾Ý def LoadPyGameData(self, datas, pos, dataslen): cnt, pos = CommFunc.ReadDWORD(datas, pos) GameWorld.Log("Load DBPyMarry count :%s" % cnt) for _ in xrange(cnt): coupleData = PyGameDataStruct.tagDBPyCouple() coupleData.clear() pos += coupleData.readData(datas, pos, dataslen) playerIDA = coupleData.PlayerIDA playerIDB = coupleData.PlayerIDB couple = self.AddCouple(playerIDA, playerIDB, coupleData) if couple.GetBreakRequestTime() > 0: PyGameData.g_marryBreakInfo[(playerIDA, playerIDB)] = couple SortMarryBreak() return pos class DBPyUnNotifyLoveGiftRecManager(object): ## δ֪ͨµÄÔùËÍÀñÎï¼Ç¼¹ÜÀí def __init__(self): self.unNotifyLoveGiftDict = {} # {playerID:[PyGameDataStruct.tagDBPyUnNotifyLoveGiftRec, ...], ...} return def AddUnNotifyGiftRec(self, receivePlayerID, givePlayerID, giftNum, giftCount, sendTime): ''' Ìí¼Óδ֪ͨµÄÔùËÍÀñÎï¼Ç¼ @param receivePlayerID: δ֪ͨµÄÊÜÔù·½Íæ¼ÒID @param givePlayerID: ÔùËÍ·½Íæ¼ÒID ''' recData = PyGameDataStruct.tagDBPyUnNotifyLoveGiftRec() recData.PlayerID = receivePlayerID recData.GivePlayerID = givePlayerID recData.GiftNum = giftNum recData.GiftCount = giftCount recData.SendTime = sendTime if receivePlayerID not in self.unNotifyLoveGiftDict: self.unNotifyLoveGiftDict[receivePlayerID] = [] giftList = self.unNotifyLoveGiftDict[receivePlayerID] giftList.append(recData) return def LoginNotify(self, curPlayer): receivePlayerID = curPlayer.GetPlayerID() if receivePlayerID not in self.unNotifyLoveGiftDict: return giftList = self.unNotifyLoveGiftDict.pop(receivePlayerID, []) sendGiftList = [] for recData in giftList: giftOK = ChPyNetSendPack.tagGCSendGiftsOK() giftOK.PlayerID = recData.GivePlayerID giftOK.Name = PlayerSocial.GetSocialPlayerName(recData.GivePlayerID) giftOK.NameLen = len(giftOK.Name) giftOK.GiftNum = recData.GiftNum giftOK.GiftCount = recData.GiftCount giftOK.SendTime = recData.SendTime sendGiftList.append(giftOK) clientPack = ChPyNetSendPack.tagGCSendGiftsOKList() clientPack.SendGiftsOKList = sendGiftList clientPack.Count = len(clientPack.SendGiftsOKList) NetPackCommon.SendFakePack(curPlayer, clientPack) return # ±£´æÊý¾Ý ´æÊý¾Ý¿âºÍrealtimebackup def GetSaveData(self): savaData = "" cntData = "" cnt = 0 for recDataList in self.unNotifyLoveGiftDict.values(): for recData in recDataList: cnt += 1 savaData += recData.getBuffer() GameWorld.Log("Save DBPyUnNotifyLoveGiftRec count :%s len=%s" % (cnt, len(savaData))) return CommFunc.WriteDWORD(cntData, cnt) + savaData # ´ÓÊý¾Ý¿âÔØÈëÊý¾Ý def LoadPyGameData(self, datas, pos, dataslen): cnt, pos = CommFunc.ReadDWORD(datas, pos) GameWorld.Log("Load DBPyUnNotifyLoveGiftRec count :%s" % cnt) for _ in xrange(cnt): recData = PyGameDataStruct.tagDBPyUnNotifyLoveGiftRec() recData.clear() pos += recData.readData(datas, pos, dataslen) playerID = recData.PlayerID if playerID not in self.unNotifyLoveGiftDict: self.unNotifyLoveGiftDict[playerID] = [] recDataList = self.unNotifyLoveGiftDict[playerID] recDataList.append(recData) return pos def AddProsperity(candyObj, addValue): candyObj.prosperity += addValue succProsperityStrList = [] # ·±ÈÙ¶ÈÈ«·þºì°ü redpackDict = IpyGameDataPY.GetFuncEvalCfg("LoveCandyAward", 1, {}) for prosperityStr, redPackID in redpackDict.items(): if candyObj.prosperity < int(prosperityStr): continue if prosperityStr in candyObj.prosperitySuccessList: continue succProsperityStrList.append(prosperityStr) PlayerFamilyRedPacket.CreateSystemRedPacket(redPackID) # ·±ÈٶȶîÍâ½±Àø itemInfoDict = IpyGameDataPY.GetFuncEvalCfg("LoveCandyAward", 2, {}) for prosperityStr, itemList in itemInfoDict.items(): if candyObj.prosperity < int(prosperityStr): continue if prosperityStr in candyObj.prosperitySuccessList: continue succProsperityStrList.append(prosperityStr) playerIDList = [candyObj.playerIDA, candyObj.playerIDB] paramList = [candyObj.playerNameA, candyObj.playerNameB, prosperityStr] PlayerCompensation.SendMailByKey("MarryCandyProsperity", playerIDList, itemList, paramList) for prosperityStr in succProsperityStrList: if prosperityStr not in candyObj.prosperitySuccessList: candyObj.prosperitySuccessList.append(prosperityStr) return def OnServerClose(): for candyObj in PyGameData.g_marryCandySortList: __DoMarryCandyOver(candyObj) return def DoOnDay(): # ÖØÖÃÿÈÕÆ¸Àñ״̬ syncPlayerIDList = [] coupleMgr = PyDataManager.GetDBPyCoupleManager() ipyDataMgr = IpyGameDataPY.IPY_Data() for index in range(ipyDataMgr.GetMarryCount()): ipyData = ipyDataMgr.GetMarryByIndex(index) if not ipyData.GetIsDayReset(): continue bridePriceID = ipyData.GetBridePriceID() for couple in coupleMgr.coupleDict.values(): bridePriceState = couple.GetBridePriceState() buyCount = couple.GetBridePriceBuyCount(bridePriceID) if not buyCount: continue coupleIDInfo = [couple.coupleData.PlayerIDA, couple.coupleData.PlayerIDB] updBridePriceState = couple.SetBridePriceBuyCount(bridePriceID, 0) GameWorld.DebugLog("ÖØÖÃÿÈÕÆ¸Àñ´ÎÊý: coupleIDInfo=%s,bridePriceState=%s,bridePriceID=%s,updBridePriceState=%s" % (coupleIDInfo, bridePriceState, bridePriceID, updBridePriceState)) syncPlayerIDList.extend(coupleIDInfo) if syncPlayerIDList: playerMgr = GameWorld.GetPlayerManager() syncPlayerIDList = list(set(syncPlayerIDList)) for playerID in syncPlayerIDList: curPlayer = playerMgr.FindPlayerByID(playerID) if not curPlayer or PlayerControl.GetIsTJG(curPlayer): continue Sync_CoupleInfo(curPlayer) return def OnPlayerLogin(curPlayer): PyDataManager.GetDBPyUnNotifyLoveGiftRecManager().LoginNotify(curPlayer) # ͬ²½°éÂÂÇ×ÃÜ¶È playerID = curPlayer.GetPlayerID() couple = PyDataManager.GetDBPyCoupleManager().GetCouple(playerID) if couple: coupleID = couple.GetCoupleID(playerID) intimacys = PyDataManager.GetIntimacyManager().GetIntimacys(playerID) intimacys.SyncMapServerIntimacy(curPlayer, coupleID) Sync_CoupleInfo(curPlayer) Sync_CandyList(curPlayer) return def OnTimeProcess(curTime, tick): ## ÿÃë´¥·¢Ò»´Î # ¼ì²é½áËãϲÌÇ doCount = len(PyGameData.g_marryCandySortList) while doCount > 0 and PyGameData.g_marryCandySortList: doCount -= 1 candyObj = PyGameData.g_marryCandySortList[0] if curTime <= candyObj.endTime: break PyGameData.g_marryCandySortList.pop(0) PyGameData.g_marryCandyInfo.pop((candyObj.playerIDA, candyObj.playerIDB), None) __DoMarryCandyOver(candyObj) # ¼ì²éºÍÀë breakWaitTimes = IpyGameDataPY.GetFuncCfg("LoveMarryBreak", 5) doCount = len(PyGameData.g_marryBreakSortList) while doCount > 0 and PyGameData.g_marryBreakSortList: doCount -= 1 couple = PyGameData.g_marryBreakSortList[0] if curTime <= (couple.GetBreakRequestTime() + breakWaitTimes): break playerIDA, playerIDB = couple.coupleData.PlayerIDA, couple.coupleData.PlayerIDB PyGameData.g_marryBreakSortList.pop(0) PyGameData.g_marryBreakInfo.pop((playerIDA, playerIDB), None) GameWorld.Log("ºÍÀëÌá½»ÇëÇóµ½ÆÚ£¬ÏµÍ³×Ô¶¯ºÍÀë! playerIDA=%s,playerIDB=%s, len(g_marryBreakSortList)=%s" % (playerIDA, playerIDB, len(PyGameData.g_marryBreakSortList))) __DoMarryBreakLogic(couple, 0) return def __DoMarryCandyOver(candyObj): playerIDA, playerIDB, prosperity = candyObj.playerIDA, candyObj.playerIDB, candyObj.prosperity GameWorld.Log("½áËã»éÀñϲÌÇÑç»á: playerIDA=%s,playerIDB=%s,prosperity=%s" % (playerIDA, playerIDB, prosperity)) transformItemInfo = IpyGameDataPY.GetFuncEvalCfg("LoveCandyAward", 3) if len(transformItemInfo) != 2: return unitProsperity, itemID = transformItemInfo itemCount = int(math.ceil(prosperity / float(unitProsperity))) remainSeconds = candyObj.endTime - int(time.time()) GameWorld.Log("ϲÑç·±ÈÙ¶Èת»¯½±Àø: playerIDA=%s,playerIDB=%s,prosperity=%s,itemID=%s,itemCount=%s,marryTime=%s,endTime=%s,remainSeconds=%s" % (playerIDA, playerIDB, prosperity, itemID, itemCount, GameWorld.ChangeTimeNumToStr(candyObj.marryTime), GameWorld.ChangeTimeNumToStr(candyObj.endTime), remainSeconds )) if not itemID or not itemCount: return playerIDList = [playerIDA, playerIDB] itemList = [[itemID, itemCount, 0]] paramList = [candyObj.playerNameA, candyObj.playerNameB, prosperity] PlayerCompensation.SendMailByKey("MarryCandyOver", playerIDList, itemList, paramList) return #// B3 12 ÌáÇ×»ØÓ¦ #tagCGMarryResponse # #struct tagCGMarryResponse #{ # tagHead Head; # DWORD ReqPlayerID; // ÌáÇ×µÄÍæ¼ÒID # BYTE IsOK; // ÊÇ·ñͬÒ⣬0-·ñ£¬1-ÊÇ #}; def OnMarryResponse(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) reqPlayerID = clientData.ReqPlayerID isOK = clientData.IsOK reqPlayer = GameWorld.GetPlayerManager().FindPlayerByID(reqPlayerID) if not __MarryCheckComm(curPlayer, reqPlayer, reqPlayerID, False): return playerID = curPlayer.GetPlayerID() if reqPlayerID not in PyGameData.g_marryReqInfo: GameWorld.DebugLog("ÌáÇ×ÇëÇó²»´æÔÚ! reqPlayerID=%s" % reqPlayerID, playerID) PlayerControl.NotifyCode(curPlayer, "MarryReqInvalid") return reqData = PyGameData.g_marryReqInfo[reqPlayerID] if reqData.playerIDB != playerID: GameWorld.DebugLog("·ÇĿǰÌáÇ×¶ÔÏó! reqPlayerID=%s, playerIDB(%s) != playerID(%s)" % (reqPlayerID, reqData.playerIDB, playerID), playerID) PlayerControl.NotifyCode(curPlayer, "MarryReqInvalid") return if __CheckMarryReqTimeout(reqData): GameWorld.DebugLog("ÌáÇ×ÇëÇóÒѳ¬Ê±! reqPlayerID=%s" % reqPlayerID, playerID) PlayerControl.NotifyCode(curPlayer, "MarryReqInvalid") PyGameData.g_marryReqInfo.pop(reqPlayerID, None) return __DoMarryResponse(curPlayer, playerID, reqPlayer, reqPlayerID, isOK) return def __DoMarryResponse(curPlayer, playerID, reqPlayer, reqPlayerID, isOK, needResponse=True): ''' ÌáÇ×»ØÓ¦ @param curPlayer: »ØÓ¦Íæ¼Ò @param reqPlayer: ÌáÇ×Íæ¼Ò @param isOK: ÊÇ·ñͳһ ''' reqData = PyGameData.g_marryReqInfo.pop(reqPlayerID, None) if not reqData: return bridePriceID = reqData.bridePriceID ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID) if not ipyData: return #playerID = curPlayer.GetPlayerID() reqPlayerName = reqPlayer.GetName() if reqPlayer else PlayerSocial.GetSocialPlayerName(reqPlayerID) playerName = curPlayer.GetName() if curPlayer else PlayerSocial.GetSocialPlayerName(playerID) if needResponse: responsePack = ChPyNetSendPack.tagGCMarryResponseRet() responsePack.PlayerIDA = reqPlayerID responsePack.PlayerNameA = reqPlayerName responsePack.NameALen = len(responsePack.PlayerNameA) responsePack.PlayerIDB = playerID responsePack.PlayerNameB = playerName responsePack.NameBLen = len(responsePack.PlayerNameB) responsePack.IsOK = isOK if reqPlayer: NetPackCommon.SendFakePack(reqPlayer, responsePack) # ±Ø»Ø¸´ÌáÇ×·½ # ¾Ü¾ø if not isOK: return if needResponse and curPlayer: NetPackCommon.SendFakePack(curPlayer, responsePack) # »ØÓ¦·½½öͬÒâʱͬ²½ # ===================== ÒÔÏÂÖ´ÐгÉÇ×Âß¼­ ===================== GameWorld.Log("Ö´ÐгÉÇ×: reqPlayerID=%s,playerID=%s,bridePriceID=%s" % (reqPlayerID, playerID, bridePriceID), playerID) curTime = int(time.time()) prosperity = ipyData.GetProsperity() candyTimes = ipyData.GetCandyTimes() brideGiftItemInfo = ipyData.GetBrideGiftItemInfo() worldNotifyKey = ipyData.GetWorldNotifyKey() if worldNotifyKey: paramList = [reqPlayerName, playerName] for itemID, itemCount, _ in brideGiftItemInfo: paramList.extend([itemID, itemCount]) PlayerControl.WorldNotify(0, worldNotifyKey, paramList) coupleMgr = PyDataManager.GetDBPyCoupleManager() couple = coupleMgr.GetCouple(playerID) if not couple: GameWorld.Log(" лé: reqPlayerID=%s,playerID=%s,bridePriceID=%s" % (reqPlayerID, playerID, bridePriceID), playerID) coupleData = PyGameDataStruct.tagDBPyCouple() coupleData.PlayerIDA = reqPlayerID coupleData.PlayerNameA = reqPlayerName coupleData.PlayerIDB = playerID coupleData.PlayerNameB = playerName coupleData.NewMarryTime = curTime couple = coupleMgr.AddCouple(reqPlayerID, playerID, coupleData) # ֪ͨ¸øÏà¹ØÉç½»ÈËÔ± PlayerSocial.NotifySocialCoupleChange(reqPlayerID, playerID) PlayerSocial.NotifySocialCoupleChange(playerID, reqPlayerID) # ֪ͨµØÍ¼È«¾Ö°éÂÂÐÅÏ¢ PyDataManager.GetDBPyCoupleManager().SendMapServerCoupleInfo([playerID, reqPlayerID]) else: GameWorld.Log(" Òѻ飬ÔÙ´ÎÌáÇ×: PlayerIDA=%s,PlayerIDB=%s, cur reqPlayerID=%s,playerID=%s,bridePriceID=%s" % (couple.coupleData.PlayerIDA, couple.coupleData.PlayerIDB, reqPlayerID, playerID, bridePriceID), playerID) couple.coupleData.MarryTime = curTime updBuyCountValue = couple.SetBridePriceBuyCount(bridePriceID, couple.GetBridePriceBuyCount(bridePriceID) + 1) GameWorld.Log(" updBuyCountValue=%s" % updBuyCountValue, playerID) if bridePriceID > couple.BridePriceMaxID: couple.BridePriceMaxID = bridePriceID GameWorld.Log(" update BridePriceMaxID=%s" % couple.BridePriceMaxID, playerID) # Í¨ÖªÍæ¼Ò for player in [reqPlayer, curPlayer]: if not player: continue mapServerCoupleInfo = couple.GetSendMapServerCoupleInfo(player.GetPlayerID()) curIntimacys = PyDataManager.GetIntimacyManager().GetIntimacys(player.GetPlayerID()) coupleIntimacy = curIntimacys.GetTagIntimacy(couple.GetCoupleID(player.GetPlayerID())) if curIntimacys else 0 dataMsg = [reqPlayerID, bridePriceID, mapServerCoupleInfo, coupleIntimacy] MapServer_QueryPlayer_DoLogic_Love(player, "MarrySuccess", dataMsg, playerID) Sync_CoupleInfo(player) # ƸÀñ½±Àø·¢Óʼþ playerIDList = [reqPlayerID, playerID] paramList = [reqPlayerName, playerName] PlayerCompensation.SendMailByKey("MarrySuccess", playerIDList, brideGiftItemInfo, paramList) # ÐÂÔöϲÌÇ candyObj = MarryCandy() candyObj.playerIDA = reqPlayerID candyObj.playerNameA = reqPlayerName candyObj.playerIDB = playerID candyObj.playerNameB = playerName candyObj.bridePriceID = bridePriceID candyObj.marryTime = curTime candyObj.endTime = curTime + candyTimes AddProsperity(candyObj, prosperity) PyGameData.g_marryCandyInfo[(reqPlayerID, playerID)] = candyObj __SortCandy() Sync_CandyList(None, [candyObj]) PyGameData.g_marryReqInfo.pop(playerID, None) # ¿ÉÄÜ´æÔÚÏ໥ÌáÇ×µÄÇé¿ö£¬³¢ÊÔ˳±ã°Ñ×ÔÉíµÄÌáÇ×ÇëÇóɾ³ý£¬ÒòΪÒѾ­ÎÞÓÃÁË return True def GMAddCandy(curPlayer, bridePriceID, addCount): ## GMÌí¼Ó²âÊÔϲÌÇÑç»á fakeID = 0 for playerIDA, playerIDB in PyGameData.g_marryCandyInfo.keys(): if playerIDA < 10000: fakeID = max(playerIDA, fakeID) if playerIDB < 10000: fakeID = max(playerIDB, fakeID) ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID) if not ipyData: return 0 prosperity = ipyData.GetProsperity() candyTimes = ipyData.GetCandyTimes() syncCandyList = [] curTime = int(time.time()) for _ in xrange(addCount): playerIDA = fakeID + 1 playerIDB = fakeID + 2 fakeID = playerIDB candyObj = MarryCandy() candyObj.playerIDA = playerIDA candyObj.playerNameA = PlayerSocial.GetSocialPlayerName(playerIDA) candyObj.playerIDB = playerIDB candyObj.playerNameB = PlayerSocial.GetSocialPlayerName(playerIDB) candyObj.bridePriceID = bridePriceID candyObj.marryTime = curTime candyObj.endTime = curTime + candyTimes AddProsperity(candyObj, prosperity) PyGameData.g_marryCandyInfo[(playerIDA, playerIDB)] = candyObj syncCandyList.append(candyObj) __SortCandy() Sync_CandyList(None, syncCandyList) return addCount def __SortCandy(): PyGameData.g_marryCandySortList = PyGameData.g_marryCandyInfo.values() PyGameData.g_marryCandySortList.sort(key=operator.attrgetter("endTime")) return def SortMarryBreak(): PyGameData.g_marryBreakSortList = PyGameData.g_marryBreakInfo.values() PyGameData.g_marryBreakSortList.sort(key=operator.attrgetter("coupleData.BreakRequestTime")) #GameWorld.DebugLog("SortMarryBreak count=%s" % len(PyGameData.g_marryBreakSortList)) return def __CheckMarryReqTimeout(reqData): ## ¼ì²éÌáÇ×ÊÇ·ñ³¬Ê± curTime = int(time.time()) passSeconds = curTime - reqData.reqTime reqSecondCD = IpyGameDataPY.GetFuncCfg("LoveMarry", 1) return passSeconds > reqSecondCD #// B3 16 ºÍƽÀë»é»ØÓ¦ #tagGCMarryBreakResponse # #struct tagGCMarryBreakResponse #{ # tagHead Head; # BYTE IsOK; // ÊÇ·ñͬÒ⣬0-·ñ£¬1-ÊÇ #}; def OnMarryBreakResponse(index, clientData, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) isOK = clientData.IsOK playerID = curPlayer.GetPlayerID() couple = PyDataManager.GetDBPyCoupleManager().GetCouple(playerID) if not couple: GameWorld.Log("ûÓа飬ÎÞ·¨»ØÓ¦ºÍÀë! ", playerID) return coupleID = couple.GetCoupleID(playerID) breakRequestID = couple.GetBreakRequestID() if not breakRequestID or coupleID != breakRequestID: GameWorld.Log("°éÂÂûÓÐÌá³öºÍÀ룬ÎÞ·¨»ØÓ¦ºÍÀë! coupleID=%s,breakRequestID=%s" % (coupleID, breakRequestID), playerID) return playerIDA, playerIDB = couple.coupleData.PlayerIDA, couple.coupleData.PlayerIDB if (playerIDA, playerIDB) in PyGameData.g_marryBreakInfo: PyGameData.g_marryBreakInfo.pop((playerIDA, playerIDB), None) SortMarryBreak() if not isOK: GameWorld.Log("¾Ü¾øºÍÀë! coupleID=%s" % coupleID, playerID) couple.SetBreakRequestID(0) # Çå³ýºÍÀëÇëÇóID Sync_CoupleInfo(curPlayer) tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(coupleID) if tagPlayer and not PlayerControl.GetIsTJG(tagPlayer): Sync_CoupleInfo(tagPlayer) PlayerCompensation.SendMailByKey("MarryBreakRefuse", [coupleID], [], [curPlayer.GetName()]) return GameWorld.Log("ͬÒâºÍÀë: coupleID=%s" % coupleID, playerID) __DoMarryBreakLogic(couple, playerID) return def __DoMarryBreakLogic(couple, playerID=0): ## Ö´ÐÐÀë»é if not couple: return playerIDA = couple.coupleData.PlayerIDA playerIDB = couple.coupleData.PlayerIDB coupleMgr = PyDataManager.GetDBPyCoupleManager() # Ç×ÃܶȼõÉÙ decIntimacyPer = IpyGameDataPY.GetFuncCfg("LoveMarryBreak", 4) if decIntimacyPer: PyDataManager.GetIntimacyManager().DelIntimacyBothPer(playerIDA, playerIDB, decIntimacyPer) # Óʼþ֪ͨÀë»é for pid in [playerIDA, playerIDB]: coupleName = couple.GetCoupleName(pid) playerIDList = [pid] paramList = [coupleName] PlayerCompensation.SendMailByKey("MarryBreakOK", playerIDList, [], paramList) coupleMgr.DelCouple(playerIDA, playerIDB) # ֪ͨµØÍ¼È«¾Ö°éÂÂÐÅÏ¢ PyDataManager.GetDBPyCoupleManager().SendMapServerCoupleInfo([playerIDA, playerIDB]) # Í¨ÖªÍæ¼Ò dataMsg = [] for pid in [playerIDA, playerIDB]: tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(pid) if tagPlayer and not PlayerControl.GetIsTJG(tagPlayer): MapServer_QueryPlayer_DoLogic_Love(tagPlayer, "ClearCoupleSocial", dataMsg, playerID) Sync_CoupleInfo(tagPlayer) # ֪ͨ¸øÏà¹ØÉç½»ÈËÔ± PlayerSocial.NotifySocialCoupleChange(playerIDA, 0) PlayerSocial.NotifySocialCoupleChange(playerIDB, 0) if (playerIDA, playerIDB) in PyGameData.g_marryCandyInfo: GameWorld.Log("Àë»éʱͬ²½Çå³ýϲÌÇÑç»á: playerIDA=%s, playerIDB=%s" % (playerIDA, playerIDB), playerID) PyGameData.g_marryCandyInfo.pop((playerIDA, playerIDB)) __SortCandy() Sync_CandyList(None) if (playerIDA, playerIDB) in PyGameData.g_marryBreakInfo: GameWorld.Log("Àë»éʱͬ²½Çå³ýºÍÀëÇëÇó: playerIDA=%s, playerIDB=%s" % (playerIDA, playerIDB), playerID) PyGameData.g_marryBreakInfo.pop((playerIDA, playerIDB), None) SortMarryBreak() return True def MapServer_Love(curPlayer, msgList): mapID = curPlayer.GetRealMapID() GameWorld.Log("MapServer_Love mapID=%s,msgList=%s" % (mapID, msgList), curPlayer.GetPlayerID()) if not msgList: return msgType, dataMsg = msgList # ËÍÀñÎïÇëÇó if msgType == "SendGiftsReq": ret = __SendGiftsReq(curPlayer, dataMsg) # ËÍÀñÎï elif msgType == "SendGiftsOK": __DoSendGiftsOK(curPlayer, dataMsg) return # ÌáÇ× elif msgType == "MarryReq": __DoMarryReq(curPlayer, dataMsg) return # ³ÔϲÌÇ elif msgType == "MarryEatCandy": ret = __DoMarryEatCandy(curPlayer, dataMsg) # ¹ºÂòϲÌÇÑÌ»¨ elif msgType == "MarryBuyFireworks": ret = __DoMarryBuyFireworks(curPlayer, dataMsg) # Àë»é elif msgType == "MarryBreakReq": ret = __DoMarryBreakReq(curPlayer, dataMsg) if ret == None: return return msgList + [ret] def __SendGiftsReq(curPlayer, dataMsg): ## ËÍÀñÎïÇëÇó tagPlayerID = dataMsg[0] playerID = curPlayer.GetPlayerID() if not PlayerControl.GetDBPlayerAccIDByID(tagPlayerID): PlayerControl.NotifyCode(curPlayer, "NoInDBPlayer") return # ºÚÃûµ¥¼ì²é if PyDataManager.GetBlacklistManager().CheckBlacklistBoth(playerID, tagPlayerID, curPlayer): return return True def __DoSendGiftsOK(curPlayer, dataMsg): ## ËÍÀñÎï playerID = curPlayer.GetPlayerID() playerName = curPlayer.GetName() tagPlayerID, giftNum, giftItemID, giftCount, isAutoBuy = dataMsg ipyData = IpyGameDataPY.GetIpyGameData("LoveGift", giftNum) if not ipyData: return addCharmSelf = int(ipyData.GetAddCharmSelf() * giftCount) addCharmTag = int(ipyData.GetAddCharmTag() * giftCount) addIntimacy = ipyData.GetAddIntimacy() * giftCount worldNotifyKey = ipyData.GetWorldNotifyKey() GameWorld.Log("ÔùËÍÀñÎï: tagPlayerID=%s,giftNum=%s,giftItemID=%s,giftCount=%s,addCharmSelf=%s,addCharmTag=%s,addIntimacy=%s,isAutoBuy=%s" % (tagPlayerID, giftNum, giftItemID, giftCount, addCharmSelf, addCharmTag, addIntimacy, isAutoBuy), playerID) tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID) PyDataManager.GetIntimacyManager().AddIntimacyBoth(playerID, tagPlayerID, addIntimacy) PlayerCharm.AddCharm(curPlayer, playerID, playerID, addCharmSelf) PlayerCharm.AddCharm(tagPlayer, tagPlayerID, playerID, addCharmTag) tagPlayerName = "" isOnline = tagPlayer and not PlayerControl.GetIsTJG(tagPlayer) if isOnline: tagPlayerName = tagPlayer.GetName() else: tagPlayerName = PlayerSocial.GetSocialPlayerName(tagPlayerID) if worldNotifyKey: PlayerControl.WorldNotify(0, worldNotifyKey, [playerName, tagPlayerName, giftItemID, giftCount]) sendTime = int(time.time()) if not isOnline: PyDataManager.GetDBPyUnNotifyLoveGiftRecManager().AddUnNotifyGiftRec(tagPlayerID, playerID, giftNum, giftCount, sendTime) return # ֪ͨĿ±êǰ¶ËËÍ»¨³É¹¦ giftOK = ChPyNetSendPack.tagGCSendGiftsOK() giftOK.PlayerID = playerID giftOK.Name = playerName giftOK.NameLen = len(giftOK.Name) giftOK.GiftNum = giftNum giftOK.GiftCount = giftCount giftOK.SendTime = sendTime clientPack = ChPyNetSendPack.tagGCSendGiftsOKList() clientPack.SendGiftsOKList = [giftOK] clientPack.Count = len(clientPack.SendGiftsOKList) NetPackCommon.SendFakePack(tagPlayer, clientPack) return def MapServer_QueryPlayer_DoLogic_Love(tagPlayer, msgType, dataMsg, playerID=0): ## ֪ͨĿ±êÍæ¼ÒµØÍ¼Ö´ÐÐ DoLogic tagPlayerID = tagPlayer.GetPlayerID() tagMapID = tagPlayer.GetRealMapID() if tagMapID: cmdStr = str([msgType, dataMsg]) GameWorld.Log("MapServer_QueryPlayer_DoLogic_Love: msgType=%s,tagPlayerID=%s,tagMapID=%s,dataMsg=%s" % (msgType, tagPlayerID, tagMapID, dataMsg), playerID) GameWorld.GetPlayerManager().MapServer_QueryPlayer(0, 0, tagPlayer.GetPlayerID(), tagMapID, "Love", cmdStr, len(cmdStr), tagPlayer.GetRouteServerIndex()) return def __MarryCheckComm(curPlayer, tagPlayer, tagPlayerID, checkIntimacy): ## ³ÉÇ×ͨÓüì²é playerID = curPlayer.GetPlayerID() if not PlayerControl.GetDBPlayerAccIDByID(tagPlayerID): PlayerControl.NotifyCode(curPlayer, "NoInDBPlayer") return # ºÚÃûµ¥¼ì²é if PyDataManager.GetBlacklistManager().CheckBlacklistBoth(playerID, tagPlayerID, curPlayer): return curCouple = PyDataManager.GetDBPyCoupleManager().GetCouple(playerID) if curCouple and curCouple.GetCoupleID(playerID) != tagPlayerID: PlayerControl.NotifyCode(curPlayer, "HaveCouple") # ÒѾ­ÓÐÆäËû°éÂÂÁË return tagCouple = PyDataManager.GetDBPyCoupleManager().GetCouple(tagPlayerID) if tagCouple and tagCouple.GetCoupleID(tagPlayerID) != playerID: PlayerControl.NotifyCode(curPlayer, "TagHaveCouple") # ¶Ô·½ÒѾ­ÓÐÆäËû°éÂÂÁË return if not tagPlayer or PlayerControl.GetIsTJG(tagPlayer): if not curCouple: PlayerControl.NotifyCode(curPlayer, "LoveOffline") # ÀëÏß return # »ØÓ¦·½¿É²»¼ì²éÇ×ÃÜ¶È if checkIntimacy: needIntimacy = IpyGameDataPY.GetFuncCfg("LoveMarry", 2) curIntimacys = PyDataManager.GetIntimacyManager().GetIntimacys(playerID) if not curIntimacys or curIntimacys.GetTagIntimacy(tagPlayerID) < needIntimacy: PlayerControl.NotifyCode(curPlayer, "IntimacyLack", [needIntimacy]) # Ç×ÃܶȲ»×ã return return True def __DoMarryReq(curPlayer, dataMsg): ## ÌáÇ× tagPlayerID, bridePriceID = dataMsg tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID) if not __MarryCheckComm(curPlayer, tagPlayer, tagPlayerID, True): return curTime = int(time.time()) playerID = curPlayer.GetPlayerID() if (playerID, tagPlayerID) in PyGameData.g_marryCandyInfo or (tagPlayerID, playerID) in PyGameData.g_marryCandyInfo: PlayerControl.NotifyCode(curPlayer, "MarryReqLimitByCandy") # ϲÑçÖÐÎÞ·¨²Ù×÷ return couple = PyDataManager.GetDBPyCoupleManager().GetCouple(playerID) if couple: coupleID = couple.GetCoupleID(playerID) if coupleID != tagPlayerID: GameWorld.Log("ÒѳÉÇ×°éÂÂID²»Ò»Ö£¬ÎÞ·¨ÌáÇ×! tagPlayerID(%s) != coupleID(%s)" % (tagPlayerID, coupleID), playerID) return if couple.GetBreakRequestID(): PlayerControl.NotifyCode(curPlayer, "LimitByMarryBroke") # ºÍÀëÖÐÎÞ·¨²Ù×÷ return ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID) if not ipyData: return canBuyMax = ipyData.GetCanBuyCount() buyCount = couple.GetBridePriceBuyCount(bridePriceID) GameWorld.DebugLog("bridePriceID=%s,buyCount=%s,canBuyMax=%s %s" % (bridePriceID, buyCount, canBuyMax, couple.coupleData.BridePriceState)) if canBuyMax and buyCount >= canBuyMax: GameWorld.Log("ƸÀñÌáÇ×´ÎÊý²»×㣬ÎÞ·¨ÌáÇ×! bridePriceID=%s,buyCount(%s) >= canBuyMax(%s)" % (bridePriceID, buyCount, canBuyMax), playerID) return GameWorld.Log("ÒѳÉÇ׵İéÂÂÔÙ´ÎÌáÇ×£¬Ö±½Ó³ÉÇ×! tagPlayerID=%s,coupleID=%s" % (tagPlayerID, coupleID), playerID) reqData = MarryReq() reqData.playerIDA = playerID reqData.playerIDB = tagPlayerID reqData.bridePriceID = bridePriceID reqData.reqTime = curTime PyGameData.g_marryReqInfo[playerID] = reqData __DoMarryResponse(tagPlayer, tagPlayerID, curPlayer, playerID, 1, False) return if tagPlayerID in PyGameData.g_marryReqInfo: tagReqData = PyGameData.g_marryReqInfo[tagPlayerID] tagBridePriceID = tagReqData.bridePriceID if playerID == tagReqData.playerIDB and not __CheckMarryReqTimeout(tagReqData): if tagBridePriceID < bridePriceID: GameWorld.Log("Íæ¼ÒÌáÇ×ʱ£¬Ä¿±ê¸ÕºÃÒѾ­ÏÈÌá¹ýÇ×£¬ÇÒÔÚÓÐЧÆÚÄÚ£¬Ö±½Ó³ÉÇ×£¡Ê¹Óõ±Ç°ÌáÇ×Íæ¼Ò½Ï¸ßƸÀñIDΪ׼! tagPlayerID=%s,tagBridePriceID=%s < bridePriceID=%s" % (tagPlayerID, tagBridePriceID, bridePriceID), playerID) reqData = MarryReq() reqData.playerIDA = playerID reqData.playerIDB = tagPlayerID reqData.bridePriceID = bridePriceID reqData.reqTime = curTime PyGameData.g_marryReqInfo[playerID] = reqData if __DoMarryResponse(tagPlayer, tagPlayerID, curPlayer, playerID, 1): return GameWorld.Log("Íæ¼ÒÌáÇ×ʱ£¬Ä¿±ê¸ÕºÃÒѾ­ÏÈÌá¹ýÇ×£¬ÇÒÔÚÓÐЧÆÚÄÚ£¬Ö±½Ó³ÉÇ×£¡tagPlayerID=%s,tagBridePriceID=%s,bridePriceID=%s" % (tagPlayerID, tagBridePriceID, bridePriceID), playerID) if __DoMarryResponse(curPlayer, playerID, tagPlayer, tagPlayerID, 1): return else: GameWorld.DebugLog("¶Ô·½ÓÐÌáÇ×£¬µ«ÊǶÔÏó²»Ò»Ñù»òÒѳ¬Ê±£¡ tagPlayerID=%s, timeout=%s" % (tagReqData.playerIDB, __CheckMarryReqTimeout(tagReqData)), playerID) if playerID not in PyGameData.g_marryReqInfo: reqData = MarryReq() PyGameData.g_marryReqInfo[playerID] = reqData else: reqData = PyGameData.g_marryReqInfo[playerID] # Ìáǰ²»ÑéÖ¤£¬Ö±½Ó¸²¸Ç£¬·ÅÔÚ»ØÓ¦ÖÐÑéÖ¤ reqData.playerIDA = playerID reqData.playerIDB = tagPlayerID reqData.bridePriceID = bridePriceID reqData.reqTime = curTime # ֪ͨ×Ô¼ºÇëÇó³É¹¦ NetPackCommon.SendFakePack(curPlayer, ChPyNetSendPack.tagGCMarryReqOK()) # ֪ͨ¶Ô·½ clientPack = ChPyNetSendPack.tagGCMarryReqInfo() clientPack.PlayerID = playerID clientPack.PlayerName = curPlayer.GetName() clientPack.NameLen = len(clientPack.PlayerName) clientPack.BridePriceID = bridePriceID NetPackCommon.SendFakePack(tagPlayer, clientPack) return def __DoMarryEatCandy(curPlayer, dataMsg): ## ³ÔϲÌÇ playerIDA, playerIDB, playerID, costMoneyType, costMoneyValue, playerMoneyValue = dataMsg coupleIDInfo = (playerIDA, playerIDB) if coupleIDInfo not in PyGameData.g_marryCandyInfo: GameWorld.ErrLog("²»´æÔڸûéÀñϲÌÇÑç»á! playerIDA=%s, playerIDB=%s" % (playerIDA, playerIDB)) return candyObj = PyGameData.g_marryCandyInfo[coupleIDInfo] bridePriceID = candyObj.bridePriceID ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID) if not ipyData: return candyItemInfo = [] candyItemWeightInfo = ipyData.GetCandyItemWeightInfo() candyNotifyItemInfo = ipyData.GetCandyNotifyItemInfo() playerFreeEatCount = candyObj.playerFreeEatCountDict.get(playerID, 0) playerFireworksCount = candyObj.fireworksCountDict.get(playerID, 0) candyFreeCount = IpyGameDataPY.GetFuncCfg("LoveCandy", 1) # Ãâ·ÑϲÌÇ´ÎÊý fireworksCandyCount = IpyGameDataPY.GetFuncCfg("LoveCandyFire", 3) # ¹ºÂòÒ»´ÎÑÌ»¨ÔùËÍϲÌÇ´ÎÊý totalFreeCount = candyFreeCount + fireworksCandyCount * playerFireworksCount isFree = (playerFreeEatCount < totalFreeCount) canBuy = isFree or (playerMoneyValue >= costMoneyValue) GameWorld.Log("³ÔϲÌÇ: coupleIDInfo=%s,costMoneyType=%s,costMoneyValue=%s,playerMoneyValue=%s,playerFireworksCount=%s,playerFreeEatCount=%s,totalFreeCount=%s,isFree=%s,canBuy=%s" % (coupleIDInfo, costMoneyType, costMoneyValue, playerMoneyValue, playerFireworksCount, playerFreeEatCount, totalFreeCount, isFree, canBuy), playerID) if canBuy: addProsperityValue = IpyGameDataPY.GetFuncCfg("LoveCandy", 3) # ϲÌÇÿ´ÎÔö¼Ó·±ÈÙ¶È AddProsperity(candyObj, addProsperityValue) PlayerControl.NotifyCode(curPlayer, "EatCandyProsperity", [curPlayer.GetName(), addProsperityValue]) for pID in [playerIDA, playerIDB]: if playerID == pID: continue player = GameWorld.GetPlayerManager().FindPlayerByID(pID) if not player or PlayerControl.GetIsTJG(player): continue PlayerControl.NotifyCode(player, "EatCandyProsperity", [curPlayer.GetName(), addProsperityValue]) if isFree: candyObj.playerFreeEatCountDict[playerID] = playerFreeEatCount + 1 Sync_CandyList(None, [candyObj]) updProsperity = candyObj.prosperity updPlayerFreeEatCount = candyObj.playerFreeEatCountDict.get(playerID, 0) getCandyItemInfo = GameWorld.GetResultByWeightList(candyItemWeightInfo, []) if getCandyItemInfo: candyItemInfo.append(getCandyItemInfo) itemID, itemCount = getCandyItemInfo[:2] if itemID in candyNotifyItemInfo: PlayerControl.WorldNotify(0, "EatCandyItemNotify", [curPlayer.GetName(), itemID, itemCount]) GameWorld.Log("¸üÐÂϲÌÇÑç»á: updProsperity=%s,updPlayerFreeEatCount=%s,getCandyItemInfo=%s" % (updProsperity, updPlayerFreeEatCount, getCandyItemInfo), playerID) return canBuy, isFree, costMoneyType, costMoneyValue, candyItemInfo def __DoMarryBuyFireworks(curPlayer, dataMsg): ## ¹ºÂòϲÌÇÑÌ»¨ playerIDA, playerIDB, playerID, costMoneyType, costMoneyValue, playerMoneyValue = dataMsg coupleIDInfo = (playerIDA, playerIDB) if coupleIDInfo not in PyGameData.g_marryCandyInfo: GameWorld.ErrLog("²»´æÔڸûéÀñϲÌÇÑç»áÑÌ»¨! playerIDA=%s, playerIDB=%s" % (playerIDA, playerIDB)) return candyObj = PyGameData.g_marryCandyInfo[coupleIDInfo] fireworksTotalBuyCount = sum(candyObj.fireworksCountDict.values()) totalBuyCountLimit = IpyGameDataPY.GetFuncCfg("LoveCandyFire", 1) if fireworksTotalBuyCount >= totalBuyCountLimit: PlayerControl.NotifyCode(curPlayer, "MarryFireworksSoldout") return addProsperityValue = IpyGameDataPY.GetFuncCfg("LoveCandyFire", 4) # ÑÌ»¨Ï²ÌÇÔùËÍ·±ÈÙ¶È GameWorld.Log("¹ºÂò»éÀñÑÌ»¨: coupleIDInfo=%s,costMoneyType=%s,costMoneyValue=%s,playerMoneyValue=%s,fireworksCountDict=%s" % (coupleIDInfo, costMoneyType, costMoneyValue, playerMoneyValue, candyObj.fireworksCountDict), playerID) AddProsperity(candyObj, addProsperityValue) candyObj.fireworksCountDict[playerID] = candyObj.fireworksCountDict.get(playerID, 0) + 1 Sync_CandyList(None, [candyObj]) PlayerControl.WorldNotify(0, "BuyFireworks", [curPlayer.GetName(), candyObj.playerNameA, candyObj.playerNameB]) GameWorld.Log("¸üлéÀñÑÌ»¨: updProsperity=%s,fireworksCountDict=%s" % (candyObj.prosperity, candyObj.fireworksCountDict), playerID) return costMoneyType, costMoneyValue def __DoMarryBreakReq(curPlayer, dataMsg): ## Àë»éÇëÇó playerID, breakType, moneyType, moneyValue = dataMsg couple = PyDataManager.GetDBPyCoupleManager().GetCouple(playerID) if not couple: GameWorld.Log("ûÓа飬²»ÐèÒªÀë»é! ", playerID) return coupleID = couple.GetCoupleID(playerID) curTime = int(time.time()) # ¹«¹²CD marryTime = couple.GetMarryTime() passTime = curTime - marryTime marryBreakCD = IpyGameDataPY.GetFuncCfg("LoveMarryBreak", 1) if marryBreakCD and passTime < marryBreakCD: GameWorld.Log("¾àÀë×î½üÒ»´Î³ÉÇ×Àë»éµÈ´ýʱ¼äδµ½£¬ÎÞ·¨ÇëÇóÀë»é! marryTime=%s,passTime(%s) < %s" % (GameWorld.ChangeTimeNumToStr(marryTime), passTime, marryBreakCD), playerID) return # ºÍÀë¶îÍâÏÞÖÆ¸öÈËCD playerBreakRequestTime = couple.GetPlayerBreakRequestTime(playerID) if breakType == 0 and playerBreakRequestTime: passTime = curTime - playerBreakRequestTime breakReqCD = IpyGameDataPY.GetFuncCfg("LoveMarryBreak", 2) if breakReqCD and passTime < breakReqCD: GameWorld.Log("¾àÀë×î½üÒ»´ÎÇëÇóºÍÀëµÈ´ýʱ¼äδµ½£¬ÎÞ·¨ÇëÇóÀë»é! playerBreakRequestTime=%s,passTime(%s) < %s" % (GameWorld.ChangeTimeNumToStr(playerBreakRequestTime), passTime, breakReqCD), playerID) return if couple.GetBreakRequestID() == coupleID: GameWorld.Log("ÇëÇóÀë»éʱ¶Ô·½ÒѾ­Ìá³öºÍÀëÁË£¬Ö±½ÓÀë»é! coupleID=%s,breakRequestID=%s" % (coupleID, couple.GetBreakRequestID()), playerID) __DoMarryBreakLogic(couple, playerID) return # 0-ºÍƽÀë»é£»1-Ç¿ÖÆÀë»é if breakType == 0: if couple.GetBreakRequestID() != playerID: playerIDA, playerIDB = couple.coupleData.PlayerIDA, couple.coupleData.PlayerIDB GameWorld.Log("ÐÂÔöÌá½»ºÍÀë! coupleID=%s" % coupleID, playerID) couple.SetBreakRequestID(playerID) PyGameData.g_marryBreakInfo[(playerIDA, playerIDB)] = couple SortMarryBreak() playerBreakRequestTime = couple.GetPlayerBreakRequestTime(playerID) else: GameWorld.Log("ÖØ¸´Ìá½»ºÍÀë! coupleID=%s" % coupleID, playerID) Sync_CoupleInfo(curPlayer) tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(coupleID) if tagPlayer and not PlayerControl.GetIsTJG(tagPlayer): Sync_CoupleInfo(tagPlayer) return GameWorld.Log("Ç¿ÖÆÀë»é: coupleID=%s" % coupleID, playerID) __DoMarryBreakLogic(couple, playerID) return moneyType, moneyValue def Sync_CoupleInfo(curPlayer): ## ͬ²½°éÂÂÐÅÏ¢ playerID = curPlayer.GetPlayerID() clientPack = ChPyNetSendPack.tagGCCoupleInfo() curCouple = PyDataManager.GetDBPyCoupleManager().GetCouple(playerID) if curCouple: clientPack.CoupleID = curCouple.GetCoupleID(playerID) clientPack.CoupleName = curCouple.GetCoupleName(playerID) clientPack.NameLen = len(clientPack.CoupleName) clientPack.NewMarryTime = curCouple.GetNewMarryTime() clientPack.MarryTime = curCouple.GetMarryTime() clientPack.BridePriceState = curCouple.GetBridePriceState() clientPack.BreakRequestID = curCouple.GetBreakRequestID() clientPack.BreakRequestTime = curCouple.GetBreakRequestTime() clientPack.PlayerBreakRequestTime = curCouple.GetPlayerBreakRequestTime(playerID) NetPackCommon.SendFakePack(curPlayer, clientPack) return def Sync_CandyList(curPlayer, syncCandyList=None): if syncCandyList == None: syncCandyList = PyGameData.g_marryCandySortList if not syncCandyList: return clientPack = ChPyNetSendPack.tagGCCandyList() clientPack.CandyInfoList = [] for candyObj in syncCandyList: candyInfo = ChPyNetSendPack.tagGCCandyInfo() candyInfo.PlayerIDA = candyObj.playerIDA candyInfo.PlayerNameA = candyObj.playerNameA candyInfo.NameALen = len(candyInfo.PlayerNameA) candyInfo.PlayerIDB = candyObj.playerIDB candyInfo.PlayerNameB = candyObj.playerNameB candyInfo.NameBLen = len(candyInfo.PlayerNameB) candyInfo.BridePriceID = candyObj.bridePriceID candyInfo.MarryTime = candyObj.marryTime candyInfo.EndTime = candyObj.endTime candyInfo.Prosperity = candyObj.prosperity candyInfo.FireworksTotalBuyCount = sum(candyObj.fireworksCountDict.values()) if curPlayer: candyInfo.FireworksPlayerBuyCount = candyObj.fireworksCountDict.get(curPlayer.GetPlayerID(), 0) candyInfo.PlayerFreeEatCandyCount = candyObj.playerFreeEatCountDict.get(curPlayer.GetPlayerID(), 0) clientPack.CandyInfoList.append(candyInfo) clientPack.CandyCount = len(clientPack.CandyInfoList) if not curPlayer: playerManager = GameWorld.GetPlayerManager() for i in xrange(playerManager.GetActivePlayerCount()): curPlayer = playerManager.GetActivePlayerAt(i) if curPlayer == None: continue if PlayerControl.GetIsTJG(curPlayer): continue for candyInfo in clientPack.CandyInfoList: coupleIDInfo = (candyInfo.PlayerIDA, candyInfo.PlayerIDB) if coupleIDInfo not in PyGameData.g_marryCandyInfo: continue candyObj = PyGameData.g_marryCandyInfo[coupleIDInfo] candyInfo.FireworksPlayerBuyCount = candyObj.fireworksCountDict.get(curPlayer.GetPlayerID(), 0) candyInfo.PlayerFreeEatCandyCount = candyObj.playerFreeEatCountDict.get(curPlayer.GetPlayerID(), 0) NetPackCommon.SendFakePack(curPlayer, clientPack) else: if PlayerControl.GetIsTJG(curPlayer): return NetPackCommon.SendFakePack(curPlayer, clientPack) return