| | |
| | | import datetime
|
| | |
|
| | |
|
| | | def GetShopTypeList(cfgID, dayIndex, state):
|
| | | def GetShopTypeList(cfgID, dayIndex, state, woldLV):
|
| | | if cfgID == 0 or state == 0:
|
| | | return []
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("ActFlashSale", cfgID)
|
| | | if not ipyData:
|
| | | return []
|
| | | shopTypeList = ipyData.GetShopTypeList()
|
| | | shopTypeList = GameWorld.GetDictValueByRangeKey(ipyData.GetShopTypeList(), woldLV, [])
|
| | | if not shopTypeList:
|
| | | return []
|
| | | todayShopTypeList = shopTypeList[-1] if dayIndex >= len(shopTypeList) else shopTypeList[dayIndex]
|
| | | return [todayShopTypeList[state - 1] if state - 1 < len(todayShopTypeList) else todayShopTypeList[-1]]
|
| | |
|
| | |
| | | state = actInfo.get(ShareDefine.ActKey_State, 0)
|
| | | cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
| | | dayIndex = actInfo.get(ShareDefine.ActKey_DayIndex, 0)
|
| | | woldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
| | | playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleID, 0, ChConfig.Def_PDictType_FlashSale) # 玩家身上的活动ID
|
| | | playerActState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleState, 0, ChConfig.Def_PDictType_FlashSale) # 玩家身上的活动State
|
| | | playerMailState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleMailState, 0, ChConfig.Def_PDictType_FlashSale) # 玩家身上的活动提醒邮件状态
|
| | |
| | | isReset = True
|
| | | if cfgID:
|
| | | flashSaleIpyData = IpyGameDataPY.GetIpyGameData("ActFlashSale", cfgID)
|
| | | startDate = flashSaleIpyData.GetStartDate()
|
| | | openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
|
| | | startDate = GameWorld.GetOperationActionDateStr(flashSaleIpyData.GetStartDate(), openServerDay)
|
| | | startTimeNum = GameWorld.ChangeTimeStrToNum(startDate, timeFormat=ChConfig.TYPE_Time_Format_Day)
|
| | | else:
|
| | | startTimeNum = 0
|
| | |
| | | GameWorld.DebugLog(' 限时抢购活动重置!')
|
| | | curPlayer.ClearNomalDict(ChConfig.Def_PDictType_FlashSale)
|
| | |
|
| | | shopTypeList = GetShopTypeList(cfgID, dayIndex, state)
|
| | | shopTypeList = GetShopTypeList(cfgID, dayIndex, state, woldLV)
|
| | | if shopTypeList:
|
| | | FunctionNPCCommon.ResetShopItemBuyCountByShopType(curPlayer, shopTypeList)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleID, actID, ChConfig.Def_PDictType_FlashSale)
|
| | |
| | | LVLimit = flashSaleIpyData.GetLVLimit()
|
| | | if not mailKey or curPlayer.GetLV() < LVLimit:
|
| | | return
|
| | | startDate = flashSaleIpyData.GetStartDate()
|
| | | endDate = flashSaleIpyData.GetEndDate()
|
| | | openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
|
| | | startDate = GameWorld.GetOperationActionDateStr(flashSaleIpyData.GetStartDate(), openServerDay)
|
| | | endDate = GameWorld.GetOperationActionDateStr(flashSaleIpyData.GetEndDate(), openServerDay)
|
| | | startTimeList = flashSaleIpyData.GetStartTimeList()
|
| | | endTimeList = flashSaleIpyData.GetEndTimeList()
|
| | | if not startTimeList or not endTimeList:
|
| | |
| | | endTime = datetime.datetime.strptime("%s %s:00" % (endDate, endTimeList[-1]), ChConfig.TYPE_Time_Format)
|
| | | curDateTime = GameWorld.GetCurrentTime()
|
| | | if startTime <= curDateTime <= endTime:
|
| | | PlayerControl.SendMailByKey(mailKey, [curPlayer.GetID()], flashSaleIpyData.GetMailItemPrize())
|
| | | paramList = [startDate.replace('-','/'), endDate.replace('-','/'), GameWorld.GbkToCode('、').join(startTimeList)]
|
| | | PlayerControl.SendMailByKey(mailKey, [curPlayer.GetID()], flashSaleIpyData.GetMailItemPrize(), paramList)
|
| | | startTimeNum = GameWorld.ChangeTimeStrToNum(startDate, timeFormat=ChConfig.TYPE_Time_Format_Day)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleMailState, startTimeNum, ChConfig.Def_PDictType_FlashSale)
|
| | | GameWorld.DebugLog(" 发送新限时抢购邮件提醒!", curPlayer.GetID())
|
| | |
| | | flashSaleIpyData = IpyGameDataPY.GetIpyGameData("ActFlashSale", cfgID)
|
| | | if not flashSaleIpyData:
|
| | | return
|
| | | shopTypeList = flashSaleIpyData.GetShopTypeList()
|
| | | woldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
| | | shopTypeList = GameWorld.GetDictValueByRangeKey(flashSaleIpyData.GetShopTypeList(), woldLV, [])
|
| | | startTimeList = flashSaleIpyData.GetStartTimeList()
|
| | | endTimeList = flashSaleIpyData.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.tagMCFlashSaleInfo()
|
| | | packInfo.StartDate = GameWorld.GetOperationActionDateStr(flashSaleIpyData.GetStartDate(), openServerDay)
|
| | |
| | | giftBag.MoneyType = itemIpyData.GetMoneyType()
|
| | | giftBag.MoneyNumber = itemIpyData.GetMoneyNum()
|
| | | giftBag.MoneyOriginal = itemIpyData.GetMoneyOriginal()
|
| | | giftBag.ItemID = itemIpyData.GetItemID()
|
| | | itemID = itemIpyData.GetItemID()
|
| | | jobItemList = itemIpyData.GetJobItem()
|
| | | jobItemID = FunctionNPCCommon.GetShopJobItem(job, itemID, jobItemList)
|
| | | giftBag.ItemID = jobItemID
|
| | | giftBag.ItemCount = itemIpyData.GetItemCnt()
|
| | | giftBag.IsBind = itemIpyData.GetIsBind()
|
| | | shop.GiftbagInfo.append(giftBag)
|
| | |
| | | if not cfgID:
|
| | | return
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleYY % goodsID, packData.State, ChConfig.Def_PDictType_FlashSale)
|
| | | Sync_FlashSaleAppointmentInfo(curPlayer)
|
| | | Sync_FlashSaleAppointmentInfo(curPlayer, goodsID)
|
| | | return
|
| | |
|
| | |
|
| | | def Sync_FlashSaleAppointmentInfo(curPlayer):
|
| | | def Sync_FlashSaleAppointmentInfo(curPlayer, goodsID=0):
|
| | | ##通知限时抢购预约情况
|
| | | actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {})
|
| | | if not actInfo:
|
| | |
| | | flashSaleIpyData = IpyGameDataPY.GetIpyGameData("ActFlashSale", cfgID)
|
| | | if not flashSaleIpyData:
|
| | | return
|
| | | woldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
| | | |
| | | packInfo = ChPyNetSendPack.tagMCFlashSaleAppointmentInfo()
|
| | | packInfo.GoodsList = []
|
| | | shopTypeList = flashSaleIpyData.GetShopTypeList()
|
| | | for dayIndex, shopList in enumerate(shopTypeList):
|
| | | for timeIndex, shopType in enumerate(shopList):
|
| | | shopItemIpyDataList = IpyGameDataPY.GetIpyGameDataByCondition("Store", {"ShopType":shopType}, True, True)
|
| | | if not shopItemIpyDataList:
|
| | | continue
|
| | | for i in xrange(len(shopItemIpyDataList)):
|
| | | goodsMark = dayIndex * 10000 + timeIndex * 100 + i #商品标识
|
| | | isAppointment = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleYY % goodsMark, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | if isAppointment:
|
| | | packInfo.GoodsList.append(goodsMark)
|
| | | if goodsID == 0:
|
| | | packInfo.IsAll = 1
|
| | | shopTypeList = GameWorld.GetDictValueByRangeKey(flashSaleIpyData.GetShopTypeList(), woldLV, [])
|
| | | for dayIndex, shopList in enumerate(shopTypeList):
|
| | | for timeIndex, shopType in enumerate(shopList):
|
| | | shopItemIpyDataList = IpyGameDataPY.GetIpyGameDataByCondition("Store", {"ShopType":shopType}, True, True)
|
| | | if not shopItemIpyDataList:
|
| | | continue
|
| | | for i in xrange(len(shopItemIpyDataList)):
|
| | | goodsMark = dayIndex * 10000 + timeIndex * 100 + i #商品标识
|
| | | isAppointment = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleYY % goodsMark, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | if isAppointment:
|
| | | appoinetmentPack = ChPyNetSendPack.tagMCFlashSaleAppointmentState()
|
| | | appoinetmentPack.GoodsMark = goodsMark
|
| | | appoinetmentPack.State = 1
|
| | | packInfo.GoodsList.append(appoinetmentPack)
|
| | | else:
|
| | | packInfo.IsAll = 0
|
| | | isAppointment = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleYY % goodsID, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | appoinetmentPack = ChPyNetSendPack.tagMCFlashSaleAppointmentState()
|
| | | appoinetmentPack.GoodsMark = goodsID
|
| | | appoinetmentPack.State = isAppointment
|
| | | packInfo.GoodsList.append(appoinetmentPack)
|
| | | packInfo.GoodsCount = len(packInfo.GoodsList)
|
| | | NetPackCommon.SendFakePack(curPlayer, packInfo)
|
| | | return
|