#!/usr/bin/python # -*- coding: GBK -*- #------------------------------------------------------------------------------- # ##@package Player.PlayerSpringSale # # @todo:ÏÞÊ±ÌØ»Ý»î¶¯ # @author hxp # @date 2018-7-17 # @version 1.0 # # ÏêϸÃèÊö: ÏÞÊ±ÌØ»Ý»î¶¯ # #------------------------------------------------------------------------------- #"""Version = 2018-7-17 12:00""" #------------------------------------------------------------------------------- import PyGameData import ShareDefine import PlayerControl import IpyGameDataPY import FunctionNPCCommon import ChPyNetSendPack import NetPackCommon import GameWorld import ChConfig def GetShopTypeList(cfgID, dayIndex, woldLV): if cfgID == None or dayIndex == None: return [] ipyData = IpyGameDataPY.GetIpyGameData("ActSpringSale", cfgID) if not ipyData: return [] shopTypeList = GameWorld.GetDictValueByRangeKey(ipyData.GetShopTypeList(), woldLV, []) todayShopType = shopTypeList[-1] if dayIndex >= len(shopTypeList) else shopTypeList[dayIndex] return todayShopType def OnPlayerLogin(curPlayer): __CheckPlayerSpringSaleAction(curPlayer) return def RefreshSpringSaleActionInfo(): ## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢ playerManager = GameWorld.GetPlayerManager() for index in xrange(playerManager.GetPlayerCount()): curPlayer = playerManager.GetPlayerByIndex(index) if curPlayer.GetID() == 0: continue __CheckPlayerSpringSaleAction(curPlayer) return def __CheckPlayerSpringSaleAction(curPlayer): ## ¼ì²éÍæ¼ÒÏÞÊ±ÌØ»Ý»î¶¯Êý¾ÝÐÅÏ¢ playerID = curPlayer.GetPlayerID() actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_SpringSale, {}) actID = actInfo.get(ShareDefine.ActKey_ID, 0) state = actInfo.get(ShareDefine.ActKey_State, 0) cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0) woldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0) playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SpringSaleID) # Íæ¼ÒÉíÉϵĻID isReset = False if actID != playerActID: isReset = True shopTypeList = GetShopTypeList(cfgID, actInfo.get(ShareDefine.ActKey_DayIndex, 0), woldLV) FunctionNPCCommon.ResetShopItemBuyCountByShopType(curPlayer, shopTypeList) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SpringSaleID, actID) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SpringSaleMailState, 0) #Sync_SpringSaleActionInfo(curPlayer) GameWorld.DebugLog("ÏÞÊ±ÌØ»ÝÖØÖÃ! actID=%s,playerActID=%s,state=%s,shopTypeList=%s" % (actID, playerActID, state, shopTypeList), playerID) else: GameWorld.DebugLog("ÏÞÊ±ÌØ»Ý»î¶¯ID²»±ä£¬²»´¦Àí£¡", playerID) playerMailState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SpringSaleMailState) # Íæ¼ÒÉíÉϵĻÌáÐÑÓʼþ״̬ if actID and state and state != playerMailState: springSaleIpyData = IpyGameDataPY.GetIpyGameData("ActSpringSale", cfgID) if springSaleIpyData and springSaleIpyData.GetMailKey() and curPlayer.GetLV() >= springSaleIpyData.GetLVLimit(): PlayerControl.SendMailByKey(springSaleIpyData.GetMailKey(), [playerID], springSaleIpyData.GetMailItemPrize()) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SpringSaleMailState, state) GameWorld.DebugLog(" ·¢ËÍÐÂÏÞÊ±ÌØ»ÝÓʼþÌáÐÑ! state=%s,playerMailState=%s" % (state, playerMailState), playerID) if cfgID: Sync_SpringSaleActionInfo(curPlayer) return isReset def Sync_SpringSaleActionInfo(curPlayer): ## ֪ͨÏÞÊ±ÌØ»Ý»î¶¯ÐÅÏ¢ actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_SpringSale, {}) if not actInfo: return #ÐèÒªÌáǰ֪ͨ£¬ËùÒÔÈ¥µô´ËÏÞÖÆ #if not actInfo.get(ShareDefine.ActKey_State): # return cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0) if not cfgID: return shopTypeList = GetShopTypeList(cfgID, actInfo.get(ShareDefine.ActKey_DayIndex, 0), actInfo.get(ShareDefine.ActKey_WorldLV, 0)) if not shopTypeList: return springSaleIpyData = IpyGameDataPY.GetIpyGameData("ActSpringSale", cfgID) if not springSaleIpyData: return startTimeList = springSaleIpyData.GetStartTimeList() endTimeList = springSaleIpyData.GetEndTimeList() if len(startTimeList) != len(endTimeList): GameWorld.ErrLog("ÏÞÊ±ÌØ»Ý¿ª¹ØÊ±¼äʱ·ÖÅäÖôíÎó!cfgID=%s" % cfgID) return job = curPlayer.GetJob() openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1 packInfo = ChPyNetSendPack.tagMCSpringSaleInfo() packInfo.StartDate = GameWorld.GetOperationActionDateStr(springSaleIpyData.GetStartDate(), openServerDay) packInfo.EndtDate = GameWorld.GetOperationActionDateStr(springSaleIpyData.GetEndDate(), openServerDay) packInfo.AdvanceMinutes = springSaleIpyData.GetAdvanceMinutes() packInfo.ActivityTime = [] for i, startTime in enumerate(startTimeList): timeInfo = ChPyNetSendPack.tagMCSpringSaleTime() timeInfo.StartTime = startTime timeInfo.EndtTime = endTimeList[i] packInfo.ActivityTime.append(timeInfo) packInfo.ActivityTimeCount = len(packInfo.ActivityTime) packInfo.IsDayReset = springSaleIpyData.GetIsDayReset() packInfo.LimitLV = springSaleIpyData.GetLVLimit() packInfo.ShopInfo = [] for shopType in shopTypeList: shopItemIpyDataList = IpyGameDataPY.GetIpyGameDataByCondition("Store", {"ShopType":shopType}, True, True) if not shopItemIpyDataList: continue shop = ChPyNetSendPack.tagMCSpringSaleShop() shop.GiftbagInfo = [] for itemIpyData in shopItemIpyDataList: giftBag = ChPyNetSendPack.tagMCSpringSaleGiftbag() giftBag.GiftID = itemIpyData.GetID() giftBag.BuyCountLimit = 0 if not itemIpyData.GetLimitCnt() else itemIpyData.GetLimitCnt()[0] giftBag.MoneyType = itemIpyData.GetMoneyType() giftBag.MoneyNumber = itemIpyData.GetMoneyNum() giftBag.MoneyOriginal = itemIpyData.GetMoneyOriginal() giftBag.ItemInfo = [] itemList = [[itemIpyData.GetItemID(), itemIpyData.GetItemCnt(), itemIpyData.GetIsBind()]] itemList += itemIpyData.GetItemListEx() jobItemList = itemIpyData.GetJobItem() for itemID, itemCount, isBind in itemList: item = ChPyNetSendPack.tagMCSpringSaleItem() jobItemID = FunctionNPCCommon.GetShopJobItem(job, itemID, jobItemList) item.ItemID = jobItemID item.ItemCount = itemCount item.IsBind = isBind item.IsMainItem = int(itemID == FunctionNPCCommon.GetShopJobItem(job, itemIpyData.GetMainItemID(), jobItemList)) giftBag.ItemInfo.append(item) giftBag.GiftItemCount = len(giftBag.ItemInfo) shop.GiftbagInfo.append(giftBag) shop.GiftbagCount = len(shop.GiftbagInfo) packInfo.ShopInfo.append(shop) packInfo.ShopCount = len(packInfo.ShopInfo) NetPackCommon.SendFakePack(curPlayer, packInfo) return