#!/usr/bin/python # -*- coding: GBK -*- # # ##@package PlayerCompensationTube.py # # @todo:GM²¹³¥¹ÜÀí µØͼ´¦Àí # # @author xmnathan # @date 2010-01-01 10:00 # @version 1.4 # @note: # @change: "2014-09-29 13:00" xmnathan GM²¹³¥¹ÜÀí # @change: "2014-11-05 10:50" xmnathan Áìȡʧ°ÜÒ²»Ø°üGameServer£¬ÓÃÓÚÖØÖÃÁìȡ״̬ # @change: "2016-07-25 22:00" hxp Ôö¼ÓÁìÈ¡Óʼþʼþ»ã±¨ # @change: "2017-05-04 12:00" hxp Ôö¼Ó·ûÓ¡ÐéÄâ±³°üÖ§³Ö #------------------------------------------------------------------------------ #"""Version = 2017-05-04 12:00""" #------------------------------------------------------------------------------ import IPY_GameWorld import GameWorld import ShareDefine import ChPyNetSendPack import NetPackCommon import ItemCommon import ItemControler import ChMapToGamePyPack import ReadChConfig import EventReport import ChConfig import PlayerControl import IpyGameDataPY import PlayerSuccess import EventShell import time ##A5 3B ÇëÇóÁìÈ¡²¹³¥#tagCMRequestCompensation # @param index, clientPack, tick # @return None def OnCMRequestCompensation(index, clientPack, tick): curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index) if not curPlayer: return GameWorld.DebugLog("#OnCMRequestCompensation in, PlayerID %s GUID %s"%(curPlayer.GetPlayerID(), clientPack.GUID)) #±³°üûλÖà itemPackSpace = ItemControler.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem) #·¢ËÍÏà¹ØÊý¾Ý sendPack = ChMapToGamePyPack.tagMGRequestCompensation() sendPack.GUID = clientPack.GUID sendPack.PlayerID = curPlayer.GetPlayerID() sendPack.PackSpaceCount = itemPackSpace NetPackCommon.SendPyPackToGameServer(sendPack) return ##03 02 Íæ¼ÒÁìÈ¡²¹³¥½á¹û#tagGMRequestCompensationResult # @param curPackData, tick # @return None def OnGMRequestCompensationResult(curPackData, tick): GameWorld.DebugLog("OnGMRequestCompensationResult in") curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curPackData.PlayerID) if not curPlayer: #·¢ËÍÏà¹ØÊý¾Ý »Ø±¨²¹³¥·¢·Å½á¹û sendPack = ChMapToGamePyPack.tagMGGiveCompensationResult() sendPack.GUID = curPackData.GUID sendPack.PlayerID = curPackData.PlayerID sendPack.CompensationType = curPackData.CompensationType sendPack.Result = 0 NetPackCommon.SendPyPackToGameServer(sendPack) GameWorld.DebugLog(" PlayerID %s no found "%curPackData.PlayerID) return hasAuctionItem = False needPackSpaceDict = {} isPackSpaceEnough = True # ÏÈ»ã×ÜÎïÆ·ËùÊô±³°ü for i in xrange(curPackData.Count): curPackItem = curPackData.Items[i] itemID = curPackItem.ItemID curItemData = GameWorld.GetGameData().GetItemByTypeID(itemID) if not curItemData: continue isAuctionItem = curPackItem.IsBind packType = ChConfig.GetItemPackType(curItemData) needSpace = ItemControler.GetItemNeedPackCount(packType, curItemData, curPackItem.Count, isAuctionItem) needPackSpaceDict[packType] = needPackSpaceDict.get(packType, 0) + needSpace if isAuctionItem: hasAuctionItem = True GameWorld.DebugLog(" hasAuctionItem=%s,needPackSpaceDict=%s" % (hasAuctionItem, needPackSpaceDict)) for packType, needSpace in needPackSpaceDict.items(): if needSpace > ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace): PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_676165", [packType]) isPackSpaceEnough = False break auctionItemTimeout = False auctionItemCreateTime = 0 # 20201223 Ö÷¸ÉÈ¡ÏûÅÄÆ·ÓÐЧʱ³¤É趨 # if hasAuctionItem: # auctionItemValidTimesMax = IpyGameDataPY.GetFuncCfg("AuctionItem", 1) * 3600 # ÅÄÆ·ÓÐЧʱ³¤ # auctionItemValidTimesMail = IpyGameDataPY.GetFuncCfg("AuctionItem", 2) * 3600 # ÓʼþÅÄÆ·¸½¼ÓÓÐЧʱ³¤ # auctionItemValidTimesTotal = auctionItemValidTimesMail + auctionItemValidTimesMax # mailCreateTimeStr = curPackData.CreateTime # mailCreateTime = GameWorld.ChangeTimeStrToNum(mailCreateTimeStr) # curTime = int(time.time()) # passTime = curTime - mailCreateTime # if passTime <= auctionItemValidTimesMail: # GameWorld.DebugLog("ÓʼþÅÄÆ·Áìȡʱ¼äÔÚ¸½¼Ó±£»¤Ê±³¤ÄÚ£¬ÅÄÆ·´´½¨Ê±¼ä¼´ÁìÈ¡Óʼþʱ¼ä¿ªÊ¼Ëã!passTime(%s) <= auctionItemValidTimesMail(%s)" % (passTime, auctionItemValidTimesMail)) # pass # elif auctionItemValidTimesMail < passTime < auctionItemValidTimesTotal: # auctionItemCreateTime = curTime - (passTime - auctionItemValidTimesMail) # GameWorld.DebugLog("ÓʼþÅÄÆ·Áìȡʱ¼ä³¬¹ýÓʼþ±£»¤Ê±¼ä£¬ÅÄÆ·´´½¨Ê±¼äÐè¿Û³ýÁìȡʱµÄÒç³öʱ¼ä!auctionItemValidTimesMail(%s) < passTime(%s) < auctionItemValidTimesTotal(%s), auctionItemCreateTime=%s" # % (auctionItemValidTimesMail, passTime, auctionItemValidTimesTotal, GameWorld.ChangeTimeNumToStr(auctionItemCreateTime))) # elif passTime >= auctionItemValidTimesMax: # auctionItemTimeout = True # GameWorld.DebugLog("ÓʼþÖеÄÅÄÆ·ÒѹýÆÚ£¬½«×Ô¶¯×ªÎª·ÇÅÄÆ·!passTime(%s) >= auctionItemValidTimesMax(%s)" # % (passTime, auctionItemValidTimesMax)) #±³°ü¿Õ¼ä²»×ã if not isPackSpaceEnough: GameWorld.DebugLog(" itemPack no space") sendMCPack = ChPyNetSendPack.tagMCGiveCompensationResult() sendMCPack.GUID = curPackData.GUID sendMCPack.Result = 0 NetPackCommon.SendFakePack(curPlayer, sendMCPack) #·¢ËÍÏà¹ØÊý¾Ý »Ø±¨²¹³¥·¢·Å½á¹û sendPack = ChMapToGamePyPack.tagMGGiveCompensationResult() sendPack.GUID = curPackData.GUID sendPack.PlayerID = curPackData.PlayerID sendPack.CompensationType = curPackData.CompensationType sendPack.Result = 0 NetPackCommon.SendPyPackToGameServer(sendPack) return Text = curPackData.Text contentList = Text.split("<$_$>") content = contentList[2] if len(contentList) > 2 else "" isPaimaiMail = "PaimaiMail3" in content for i in xrange(curPackData.Count): curPackItem = curPackData.Items[i] itemID = curPackItem.ItemID itemCount = curPackItem.Count isAuctionItem = curPackItem.IsBind and not auctionItemTimeout for _ in range(itemCount/65535+1): if itemCount <= 0: break if ItemControler.GetAppointItemRealID(itemID): curCreateItem = ItemControler.GetItemByData(ItemControler.GetAppointItemDictData(itemID, isAuctionItem)) else: curCreateItem = ItemCommon.CreateSingleItem(itemID, itemCount, isAuctionItem) if not curCreateItem: GameWorld.ErrLog("OnGMRequestCompensationResult CreateSingleItem %s Err "%itemID) continue giveCount = ItemControler.GetItemCount(curCreateItem) itemCount -= giveCount ##UserData°üº¬ÁË×·¼ÓÊôÐÔ²»ÍêÕû£¬ÕâÀïÐèÒª²¹Æë userDataCreateTime = 0 if curPackItem.UserDataLen: UserDataDict = eval(curPackItem.UserData) ItemCommon.SetItemUserData(curCreateItem, UserDataDict) userDataCreateTime = curCreateItem.GetUserAttr(ShareDefine.Def_IudetAuctionItemCreateTime) if isAuctionItem and auctionItemCreateTime and not userDataCreateTime: curCreateItem.SetUserAttr(ShareDefine.Def_IudetAuctionItemCreateTime, auctionItemCreateTime) ItemCommon.MakeEquipGS(curCreateItem) if isPaimaiMail and ItemCommon.CheckItemIsEquip(curCreateItem): EventShell.EventRespons_BuyAuctionEquip(curPlayer, curCreateItem.GetItemColor()) #·ÅÈëÍæ¼Ò±³°ü ItemControler.PlayerItemControler(curPlayer).PutInItem(IPY_GameWorld.rptItem, curCreateItem, event=[ChConfig.ItemGive_Mail, False, {"MailGUID":curPackData.GUID}]) moneySource = curPackData.MoneySource + ChConfig.Def_GiveMoney_Unknown # ´æֵʱΪbyteÀàÐÍ£¬Ê¹ÓÃʱÐ軹ԭ»ØÀ´ if curPackData.Gold != 0: PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, curPackData.Gold, moneySource) if curPackData.GoldPaper != 0: PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Paper, curPackData.GoldPaper, moneySource) if curPackData.Silver != 0: PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, curPackData.Silver, moneySource) #·¢ËÍÏà¹ØÊý¾Ý »Ø±¨²¹³¥·¢·Å½á¹û sendPack = ChMapToGamePyPack.tagMGGiveCompensationResult() sendPack.GUID = curPackData.GUID sendPack.PlayerID = curPackData.PlayerID sendPack.CompensationType = curPackData.CompensationType sendPack.Result = 1 NetPackCommon.SendPyPackToGameServer(sendPack) #¸æËß¿Í»§¶Ë²¹³¥ÒÑÁìÈ¡ sendMCPack = ChPyNetSendPack.tagMCGiveCompensationResult() sendMCPack.GUID = curPackData.GUID sendMCPack.Result = 1 NetPackCommon.SendFakePack(curPlayer, sendMCPack) #Ä£°å±àºÅ[%s,%s] lSign, rSign = "", "" if lSign in content and rSign in content: mailKey = content[content.index(lSign) + len(lSign):content.index(rSign)] try: mailParamList = eval(content[content.index(rSign) + len(rSign):]) except: mailParamList = [] if mailKey in ["CrossBattlefieldEnterOrderWeek", "CrossBattlefieldCallOrderWeek", "CrossBattlefieldScoreOrderWeek"]: GameWorld.DebugLog("¹ÅÉñÕ½³¡ÖÜ°ñÓʼþ´¦Àí³É¾Í: mailKey=%s,mailParamList=%s" % (mailKey, mailParamList), curPlayer.GetPlayerID()) if mailParamList and mailParamList[0] == 1: PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_Battlefield_BillFirst, 1) PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_Battlefield_BillIn, 1) #=========================================================================== # #ÁìÈ¡²¹³¥Ê¼þ¼Ç¼ # Text = curPackData.Text # #%s<$_$>%s # sender, title, content = Text.split("<$_$>") # #Ä£°å±àºÅ[%s,%s] # if "" in content: # mailContentList = content.split("") # mailTemplateNO = GameWorld.ToIntDef(mailContentList[0][14:], None) # EventMailInfo = ReadChConfig.GetEvalChConfig("EventMailInfo") # if mailTemplateNO not in EventMailInfo: # return # title, content = EventMailInfo[mailTemplateNO] # # mailParamStr = mailContentList[1] # mailParamStr = mailParamStr.replace(" ", "") # if mailParamStr.startswith("[") and mailParamStr.endswith("]") and len(mailParamStr) > 2: # content = content % tuple(eval(mailParamStr)) # # comments = "%s: %s, %s; %s" % (title, curPackData.GUID, eventItemInfo, content) # EventReport.WriteEvent_custom_events(curPlayer, EventReport.Def_Custom_Events_GetMail, comments) #=========================================================================== return