#!/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 PlayerBillboard import NetPackCommon import IpyGameDataPY import PlayerSocial import ShareDefine import PyGameData 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 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(): PlayerBillboard.ClearBillboardByIndex(ShareDefine.Def_BT_CharmDay) return def OnPlayerLogin(curPlayer): __LoginCheckCouple(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) 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() curTime = int(time.time()) 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 reqData = PyGameData.g_marryReqInfo.pop(reqPlayerID) bridePriceID = reqData.bridePriceID passSeconds = curTime - reqData.reqTime reqSecondCD = IpyGameDataPY.GetFuncCfg("LoveMarry", 1) if passSeconds > reqSecondCD: GameWorld.DebugLog("ÌáÇ×ÇëÇóÒѳ¬Ê±! reqPlayerID=%s" % reqPlayerID, playerID) PlayerControl.NotifyCode(curPlayer, "MarryReqInvalid") return ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID) if not ipyData: return reqPlayerName = reqPlayer.GetName() playerName = curPlayer.GetName() 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 NetPackCommon.SendFakePack(reqPlayer, responsePack) # ±Ø»Ø¸´ÌáÇ×·½ # ¾Ü¾ø if not isOK: return NetPackCommon.SendFakePack(curPlayer, responsePack) # »ØÓ¦·½½öͬÒâʱͬ²½ # ===================== ÒÔÏÂÖ´ÐгÉÇ×Âß¼­ ===================== 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) for player, coupleID, coupleName in [[reqPlayer, playerID, playerName], [curPlayer, reqPlayerID, reqPlayerName]]: PlayerControl.SetCoupleID(player, coupleID) # ¸üÐÂÉç½»¹ØÏµ socialPlayer = PyDataManager.GetPersonalSocialManager().GetSocialPlayer(player.GetPlayerID()) if socialPlayer: socialPlayer.SetCoupleInfo(coupleID, coupleName) socialPlayer.CheckUpdCouplePriceMaxID(bridePriceID) # ֪ͨµØÍ¼Íæ¼Ò dataMsg = [reqPlayerID, coupleID, curTime, bridePriceID] MapServer_QueryPlayer_DoLogic_Love(player, "MarrySuccess", dataMsg, playerID) # ƸÀñ½±Àø·¢Óʼþ playerIDList = [reqPlayerID, playerID] paramList = [reqPlayerName, playerName] PlayerCompensation.SendMailByKey("MarrySuccess", playerIDList, brideGiftItemInfo, paramList) # ֪ͨµØÍ¼È«¾Ö°éÂÂÐÅÏ¢ PlayerSocial.SendMapServerCoupleInfo([playerID, reqPlayerID]) # ÐÂÔöϲÌÇ 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 PyGameData.g_marryCandySortList = PyGameData.g_marryCandyInfo.values() PyGameData.g_marryCandySortList.sort(key=operator.attrgetter("endTime")) Sync_CandyList(None, [candyObj]) return #// 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() coupleID = PlayerControl.GetCoupleID(curPlayer) if not coupleID: return if coupleID not in PyGameData.g_marryBreakReqInfo: GameWorld.DebugLog("¶Ô·½Ã»ÓÐÇëÇóºÍÀ룬»ØÓ¦ÎÞЧ! coupleID=%s" % coupleID, playerID) return if playerID != PyGameData.g_marryBreakReqInfo[coupleID]: GameWorld.DebugLog("·Ç¶Ô·½Ã»ÓÐÇëÇóºÍÀë¶ÔÏ󣬻ØÓ¦ÎÞЧ! reqPlayerID=%s,tagPlayerID=%s" % (coupleID, PyGameData.g_marryBreakReqInfo[coupleID]), playerID) return PyGameData.g_marryBreakReqInfo.pop(coupleID, None) if not isOK: PlayerCompensation.SendMailByKey("MarryBreakRefuse", [coupleID], [], [curPlayer.GetName()]) return GameWorld.Log("ͬÒâºÍÀë: coupleID=%s" % coupleID, playerID) __DoMarryBreak(curPlayer, coupleID) return def __DoMarryBreak(curPlayer, coupleID): ## Ö´ÐÐÀë»é playerID = curPlayer.GetPlayerID() __ClearCoupleSocial(curPlayer) tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(coupleID) if tagPlayer: __ClearCoupleSocial(tagPlayer) # δÔÚÏߣ¬±ê¼ÇÀë»é״̬£¬µÈÏ´ÎÍæ¼ÒÉÏÏß´¦Àí else: socialPlayer = PyDataManager.GetPersonalSocialManager().GetSocialPlayer(coupleID) if socialPlayer: socialPlayer.SetCoupleBreakOffline() GameWorld.Log("Àë»éʱ°é²»ÔÚÏߣ¬±ê¼Ç°éÂÂÉç½»¹ØÏµÒÑÀë»é£¡µÈÏ´ÎÉÏÏß´¦Àí£¡ coupleID=%s" % coupleID, playerID) # ֪ͨµØÍ¼È«¾Ö°éÂÂÐÅÏ¢ PlayerSocial.SendMapServerCoupleInfo([playerID, coupleID]) return def __LoginCheckCouple(curPlayer): ## µÇ¼¼ì²éÊÇ·ñÒѱ»Àë»é playerID = curPlayer.GetPlayerID() coupleID = PlayerControl.GetCoupleID(curPlayer) if not coupleID: return socialPlayer = PyDataManager.GetPersonalSocialManager().GetSocialPlayer(playerID) if socialPlayer == None or socialPlayer.GetCoupleBreakOffline(): GameWorld.Log("Íæ¼ÒÉÏÏß¼ì²âµ½Òѱ»Àë»é£¬Ö´Ðнâ³ý°é¹ØÏµ£¡coupleID=%s" % coupleID, playerID) __ClearCoupleSocial(curPlayer) # ÉÏÏßδͬ²½¹ýµØÍ¼È«¾Ö°éÂÂÐÅÏ¢µÄÔòͬ²½ if socialPlayer and not socialPlayer.syncMapCouple and socialPlayer.GetCoupleID(): PlayerSocial.SendMapServerCoupleInfo([playerID]) return def __ClearCoupleSocial(curPlayer): ## Çå³ý°éÂÂÉç½»¹ØÏµ coupleID = PlayerControl.GetCoupleID(curPlayer) coupleName = "" playerID = curPlayer.GetPlayerID() GameWorld.Log("Íæ¼ÒÖ´Ðнâ³ý°é¹ØÏµ£¡ coupleID=%s" % coupleID, playerID) if coupleID: # Ç×ÃܶȼõÉÙ curFriends = PyDataManager.GetFriendManager().GetFriends(playerID) if curFriends != None: decIntimacyPer = IpyGameDataPY.GetFuncCfg("LoveMarryBreak", 3) updIntimacy = curFriends.AddIntimacyByPer(curPlayer, coupleID, -decIntimacyPer) GameWorld.Log(" ¸üÐÂ×ÔÉíÓë¶Ô·½Ç×ÃܶÈ: tagPlayerID=%s,decIntimacyPer=%s,updIntimacy=%s" % (coupleID, decIntimacyPer, updIntimacy), playerID) # ֪ͨµØÍ¼ dataMsg = [] MapServer_QueryPlayer_DoLogic_Love(curPlayer, "ClearCoupleSocial", dataMsg, playerID) # ÇåÉç½»¹ØÏµ - ÓɵØÍ¼Çå³ýºóͬ²½¸üРPlayerControl.SetCoupleID(curPlayer, 0) socialPlayer = PyDataManager.GetPersonalSocialManager().GetSocialPlayer(playerID) if socialPlayer: coupleName = socialPlayer.playerInfo.CoupleName socialPlayer.SetCoupleInfo(0, "") socialPlayer.CheckUpdCouplePriceMaxID(0) # Óʼþ֪ͨÀë»é playerIDList = [playerID] paramList = [coupleName] PlayerCompensation.SendMailByKey("MarryBreakOK", playerIDList, [], paramList) return 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 == "SendFlowersReq": ret = __CheckSendFlowers(curPlayer, dataMsg) # ËÍ»¨OK elif msgType == "SendFlowersOK": __DoSendFlowersOK(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 __CheckSendFlowers(curPlayer, dataMsg): ## ÔÚÏߺÃÓÑ¿ÉÔùËÍ tagPlayerID = dataMsg[0] playerID = curPlayer.GetPlayerID() curFriends = PyDataManager.GetFriendManager().GetFriends(playerID) if curFriends == None: return curFriend = curFriends.Find(tagPlayerID) if curFriend == None: PlayerControl.NotifyCode(curPlayer, "NotFriend") return tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID) if not tagPlayer or PlayerControl.GetIsTJG(tagPlayer): PlayerControl.NotifyCode(curPlayer, "LoveOffline") return return True def __DoSendFlowersOK(curPlayer, dataMsg): ## ËÍ»¨OK playerID = curPlayer.GetPlayerID() playerName = curPlayer.GetName() tagPlayerID, flowerID, flowerCount, addCharm, addCharmTag, addIntimacy, isWorldNotify = dataMsg GameWorld.Log("ÔùËÍÏÊ»¨OK: tagPlayerID=%s,flowerCount=%s,addCharm=%s,addCharmTag=%s,addIntimacy=%s" % (tagPlayerID, flowerCount, addCharm, addCharmTag, addIntimacy), playerID) curFriends = PyDataManager.GetFriendManager().GetFriends(playerID) if curFriends != None: updIntimacy = curFriends.AddIntimacy(curPlayer, tagPlayerID, addIntimacy) GameWorld.Log(" Ôö¼Ó×ÔÉíÓë¶Ô·½Ç×ÃܶÈ: tagPlayerID=%s,updIntimacy=%s" % (tagPlayerID, updIntimacy), playerID) tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(tagPlayerID) if not tagPlayer or PlayerControl.GetIsTJG(tagPlayer): return tagPlayerName = tagPlayer.GetName() tagFriends = PyDataManager.GetFriendManager().GetFriends(tagPlayerID) if tagFriends != None: updIntimacy = tagFriends.AddIntimacy(tagPlayer, playerID, addIntimacy) GameWorld.Log(" Ôö¼Ó¶Ô·½Óë×ÔÉíÇ×ÃܶÈ: tagPlayerID=%s,updIntimacy=%s" % (tagPlayerID, updIntimacy), playerID) if isWorldNotify: PlayerControl.WorldNotify(0, "SendFlowers%s" % flowerCount, [playerName, tagPlayerName, flowerCount, flowerID]) dataMsg = [addCharmTag] MapServer_QueryPlayer_DoLogic_Love(tagPlayer, "AddCharm", dataMsg, playerID) # ֪ͨĿ±êǰ¶ËËÍ»¨³É¹¦ clientPack = ChPyNetSendPack.tagGCSendFlowersOK() clientPack.PlayerID = playerID clientPack.Name = playerName clientPack.NameLen = len(clientPack.Name) clientPack.FlowerCount = flowerCount 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() curFriends = PyDataManager.GetFriendManager().GetFriends(playerID) if curFriends == None: PlayerControl.NotifyCode(curPlayer, "NotFriend") # ·ÇºÃÓÑ return curFriend = curFriends.Find(tagPlayerID) if curFriend == None: PlayerControl.NotifyCode(curPlayer, "NotFriend") # ·ÇºÃÓÑ return if not tagPlayer or PlayerControl.GetIsTJG(tagPlayer): PlayerControl.NotifyCode(curPlayer, "LoveOffline") # ÀëÏß return coupleID = PlayerControl.GetCoupleID(curPlayer) if coupleID and coupleID != tagPlayerID: PlayerControl.NotifyCode(curPlayer, "TagHaveCouple") # ÒѾ­ÓÐÆäËû°éÂÂÁË return tagCoupleID = PlayerControl.GetCoupleID(tagPlayer) if tagCoupleID and tagCoupleID != playerID: PlayerControl.NotifyCode(curPlayer, "TagHaveCouple") # ÒѾ­ÓÐÆäËû°éÂÂÁË return # »ØÓ¦·½¿É²»¼ì²éÇ×ÃÜ¶È if checkIntimacy: needIntimacy = IpyGameDataPY.GetFuncCfg("LoveMarry", 2) if curFriend.Intimacy < 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 playerID = curPlayer.GetPlayerID() if (playerID, tagPlayerID) in PyGameData.g_marryCandyInfo or (tagPlayerID, playerID) in PyGameData.g_marryCandyInfo: PlayerControl.NotifyCode(curPlayer, "MarryReqLimitByCandy") # ϲÑçÖÐÎÞ·¨²Ù×÷ return curTime = int(time.time()) 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 = ipyData.GetCandyItemInfo() 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) if isFree: candyObj.playerFreeEatCountDict[playerID] = playerFreeEatCount + 1 Sync_CandyList(None, [candyObj]) updProsperity = candyObj.prosperity updPlayerFreeEatCount = candyObj.playerFreeEatCountDict.get(playerID, 0) GameWorld.Log("¸üÐÂϲÌÇÑç»á: updProsperity=%s,updPlayerFreeEatCount=%s" % (updProsperity, updPlayerFreeEatCount), 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]) GameWorld.Log("¸üлéÀñÑÌ»¨: updProsperity=%s,fireworksCountDict=%s" % (candyObj.prosperity, candyObj.fireworksCountDict), playerID) return costMoneyType, costMoneyValue def __DoMarryBreakReq(curPlayer, dataMsg): ## Àë»éÇëÇó playerID, coupleID, breakType, moneyType, moneyValue = dataMsg gameServerCoupleID = PlayerControl.GetCoupleID(curPlayer) socialPlayer = PyDataManager.GetPersonalSocialManager().GetSocialPlayer(playerID) socialCoupleID = 0 if not socialPlayer else socialPlayer.GetCoupleID() if not gameServerCoupleID or coupleID != gameServerCoupleID or not socialCoupleID or coupleID != socialCoupleID: GameWorld.ErrLog("µØÍ¼Íæ¼Ò°éÂÂÊý¾ÝÓëGameServer²»Ò»Ö£¬Àë»éÇëÇóʱֱ½Óͨ¹ý! gameServerCoupleID=%s,socialCoupleID=%s,mapCoupleID=%s" % (gameServerCoupleID, socialCoupleID, coupleID), playerID) __ClearCoupleSocial(curPlayer) PlayerSocial.SendMapServerCoupleInfo([playerID]) return if (playerID, coupleID) in PyGameData.g_marryCandyInfo or (coupleID, playerID) in PyGameData.g_marryCandyInfo: PlayerControl.NotifyCode(curPlayer, "MarryReqLimitByCandy") # ϲÑçÖÐÎÞ·¨²Ù×÷ return # 0-ºÍƽÀë»é£»1-Ç¿ÖÆÀë»é if breakType == 0: tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(coupleID) if not tagPlayer or PlayerControl.GetIsTJG(tagPlayer): PlayerControl.NotifyCode(curPlayer, "LoveOffline") # ÀëÏß return clientPack = ChPyNetSendPack.tagGCMarryBreakInfo() clientPack.PlayerID = playerID clientPack.PlayerName = curPlayer.GetName() clientPack.NameLen = len(clientPack.PlayerName) NetPackCommon.SendFakePack(tagPlayer, clientPack) PyGameData.g_marryBreakReqInfo[playerID] = coupleID return GameWorld.Log("Ç¿ÖÆÀë»é: coupleID=%s" % coupleID, playerID) __DoMarryBreak(curPlayer, coupleID) return moneyType, moneyValue 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 PyGameData.g_marryCandySortList: 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: 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