| | |
| | |
|
| | |
|
| | | def OnPlayerLogin(curPlayer):
|
| | | __CheckPlayerflashSaleAction(curPlayer)
|
| | | |
| | | TransferPlayerActDBKeyValue(curPlayer)
|
| | | |
| | | for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {}).values():
|
| | | actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
| | | __CheckPlayerflashSaleAction(curPlayer, actNum)
|
| | | |
| | | return
|
| | |
|
| | | def TransferPlayerActDBKeyValue(curPlayer):
|
| | | ## 玩家登录时调用,旧版本玩家活动数据转移到新版本字典,线上版本维护之后的版本可删除此代码,线上版本分支 gt_1.100.4
|
| | | |
| | | #限时抢购活动
|
| | | Def_PDict_FlashSaleID = "FlashSaleID" # 玩家身上的限时抢购活动ID,唯一标识,取活动开始日期time
|
| | | Def_PDict_FlashSaleState = "FlashSaleState" # 玩家身上的限时抢购活动state
|
| | | Def_PDict_FlashSaleMailState = "FlashSaleMailState" # 玩家身上的活动更新提醒邮件状态
|
| | | Def_PDict_FlashSaleYY = "FlashSaleYY_%s" # 玩家预约限时抢购商品
|
| | | |
| | | playerActID = curPlayer.NomalDictGetProperty(Def_PDict_FlashSaleID, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | if not playerActID:
|
| | | return
|
| | | |
| | | tagActNum = 10
|
| | | |
| | | playerState = curPlayer.NomalDictGetProperty(Def_PDict_FlashSaleState, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | playerMailState = curPlayer.NomalDictGetProperty(Def_PDict_FlashSaleMailState, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleID % tagActNum, playerActID, ChConfig.Def_PDictType_FlashSale)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleState % tagActNum, playerState, ChConfig.Def_PDictType_FlashSale)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleMailState % tagActNum, playerMailState, ChConfig.Def_PDictType_FlashSale)
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, Def_PDict_FlashSaleID, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, Def_PDict_FlashSaleState, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, Def_PDict_FlashSaleMailState, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | |
| | | GameWorld.Log("限时抢购转移玩家活动字典记录: tagActNum=%s,playerActID=%s,playerState=%s,playerMailState=%s" |
| | | % (tagActNum, playerActID, playerState, playerMailState), curPlayer.GetPlayerID())
|
| | | |
| | | for dayIndex in xrange(7): # 支持7天
|
| | | for timeIndex in xrange(2): # 支持2个时段
|
| | | for i in xrange(10): # 支持10个物品
|
| | | goodsMark = dayIndex * 10000 + timeIndex * 100 + i #商品标识
|
| | | isAppointment = curPlayer.NomalDictGetProperty(Def_PDict_FlashSaleYY % goodsMark, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | if not isAppointment:
|
| | | continue
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleYY % (tagActNum, goodsMark), isAppointment, ChConfig.Def_PDictType_FlashSale)
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, Def_PDict_FlashSaleYY % goodsMark, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | |
| | | GameWorld.Log(" 转移预约状态: dayIndex=%s,timeIndex=%s,i=%s,goodsMark=%s, %s" |
| | | % (dayIndex, timeIndex, i, goodsMark, isAppointment), curPlayer.GetPlayerID())
|
| | | |
| | | return
|
| | |
|
| | | def RefreshflashSaleActionInfo():
|
| | | def RefreshflashSaleActionInfo(actNum):
|
| | | ## 收到GameServer同步的活动信息,刷新活动信息
|
| | | playerManager = GameWorld.GetPlayerManager()
|
| | | for index in xrange(playerManager.GetPlayerCount()):
|
| | | curPlayer = playerManager.GetPlayerByIndex(index)
|
| | | if curPlayer.GetID() == 0:
|
| | | continue
|
| | | __CheckPlayerflashSaleAction(curPlayer)
|
| | | __CheckPlayerflashSaleAction(curPlayer, actNum)
|
| | | return
|
| | |
|
| | |
|
| | | def __CheckPlayerflashSaleAction(curPlayer):
|
| | | def __CheckPlayerflashSaleAction(curPlayer, actNum):
|
| | | ## 检查玩家限时抢购活动数据信息
|
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
|
| | | actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {})
|
| | | actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_FlashSale, actNum)
|
| | | actID = actInfo.get(ShareDefine.ActKey_ID, 0)
|
| | | 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) # 玩家身上的活动提醒邮件状态
|
| | | playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleID % actNum, 0, ChConfig.Def_PDictType_FlashSale) # 玩家身上的活动ID
|
| | | playerActState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleState % actNum, 0, ChConfig.Def_PDictType_FlashSale) # 玩家身上的活动State
|
| | | playerMailState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleMailState % actNum, 0, ChConfig.Def_PDictType_FlashSale) # 玩家身上的活动提醒邮件状态
|
| | | isReset = False
|
| | | if actID != playerActID or (state != playerActState):
|
| | | isReset = True
|
| | |
| | | shopTypeList = GetShopTypeList(cfgID, dayIndex, state, woldLV)
|
| | | if shopTypeList:
|
| | | FunctionNPCCommon.ResetShopItemBuyCountByShopType(curPlayer, shopTypeList)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleID, actID, ChConfig.Def_PDictType_FlashSale)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleState, state, ChConfig.Def_PDictType_FlashSale)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleID % actNum, actID, ChConfig.Def_PDictType_FlashSale)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleState % actNum, state, ChConfig.Def_PDictType_FlashSale)
|
| | | #Sync_flashSaleActionInfo(curPlayer)
|
| | | GameWorld.DebugLog("限时抢购单场重置! actID=%s,playerActID=%s,dayIndex=%s,state=%s,playerActState=%s,shopTypeList=%s,playerMailState=%s" % (actID, playerActID, dayIndex, state, playerActState, shopTypeList,playerMailState), playerID)
|
| | | GameWorld.DebugLog("限时抢购单场重置! actNum=%s,actID=%s,playerActID=%s,dayIndex=%s,state=%s,playerActState=%s,shopTypeList=%s,playerMailState=%s" % (actNum, actID, playerActID, dayIndex, state, playerActState, shopTypeList,playerMailState), playerID)
|
| | | else:
|
| | | GameWorld.DebugLog("限时抢购活动ID不变,不处理!", playerID)
|
| | | GameWorld.DebugLog("限时抢购活动ID不变,不处理!actNum=%s,actID=%s,state=%s" % (actNum, actID, state), playerID)
|
| | |
|
| | | if cfgID:
|
| | | Sync_flashSaleActionInfo(curPlayer)
|
| | | Sync_FlashSaleAppointmentInfo(curPlayer)
|
| | | Sync_flashSaleActionInfo(curPlayer, actNum)
|
| | | Sync_FlashSaleAppointmentInfo(curPlayer, actNum)
|
| | | return isReset
|
| | |
|
| | | def IsFlashSaleShopType(shopType):
|
| | | ## 判断是否活动中的商店
|
| | | for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {}).values():
|
| | | actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
| | | |
| | | state = actInfo.get(ShareDefine.ActKey_State, 0)
|
| | | if not state:
|
| | | continue
|
| | | shopTypeList = GetShopTypeList(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0), state, actInfo.get(ShareDefine.ActKey_WorldLV, 0))
|
| | | if not shopTypeList:
|
| | | continue
|
| | | actShopType = shopTypeList[0]
|
| | | if shopType == actShopType:
|
| | | GameWorld.DebugLog("限时抢购活动中的商店类型: actNum=%s,shopType=%s" % (actNum, shopType))
|
| | | return True
|
| | | |
| | | GameWorld.DebugLog("限时抢购非活动中或非活动中的商店类型!shopType=%s" % (shopType))
|
| | | return False
|
| | |
|
| | | def ProcessFlashSaleMail(curPlayer, tick):
|
| | | if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_FlashSale, tick):
|
| | | return
|
| | | playerMailState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleMailState, 0, ChConfig.Def_PDictType_FlashSale) # 玩家身上的活动提醒邮件状态
|
| | | if playerMailState:
|
| | | return
|
| | | actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {})
|
| | | if not actInfo:
|
| | | return
|
| | | cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
| | | if not cfgID:
|
| | | return
|
| | | flashSaleIpyData = IpyGameDataPY.GetIpyGameData("ActFlashSale", cfgID)
|
| | | if not flashSaleIpyData:
|
| | | return
|
| | | mailKey = flashSaleIpyData.GetMailKey()
|
| | | LVLimit = flashSaleIpyData.GetLVLimit()
|
| | | if not mailKey or curPlayer.GetLV() < LVLimit:
|
| | | return
|
| | | 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:
|
| | | return
|
| | | advanceMinutes = flashSaleIpyData.GetAdvanceMinutes()
|
| | | startTime = datetime.datetime.strptime("%s %s:00" % (startDate, startTimeList[0]), ChConfig.TYPE_Time_Format) + datetime.timedelta(minutes=-advanceMinutes)
|
| | | endTime = datetime.datetime.strptime("%s %s:00" % (endDate, endTimeList[-1]), ChConfig.TYPE_Time_Format)
|
| | | curDateTime = GameWorld.GetCurrentTime()
|
| | | if startTime <= curDateTime <= endTime:
|
| | | 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())
|
| | | # else:
|
| | | # GameWorld.DebugLog(" 发送新限时抢购邮件提醒 时间没到!startTime=%s,endTime=%s,curDateTime=%s"%(startTime,endTime,curDateTime), curPlayer.GetID())
|
| | | |
| | | for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {}).values():
|
| | | actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
| | | if not actInfo:
|
| | | continue
|
| | | cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
| | | if not cfgID:
|
| | | continue
|
| | | playerMailState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleMailState % actNum, 0, ChConfig.Def_PDictType_FlashSale) # 玩家身上的活动提醒邮件状态
|
| | | if playerMailState:
|
| | | continue
|
| | | flashSaleIpyData = IpyGameDataPY.GetIpyGameData("ActFlashSale", cfgID)
|
| | | if not flashSaleIpyData:
|
| | | continue
|
| | | mailKey = flashSaleIpyData.GetMailKey()
|
| | | LVLimit = flashSaleIpyData.GetLVLimit()
|
| | | if not mailKey or curPlayer.GetLV() < LVLimit:
|
| | | continue
|
| | | 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:
|
| | | continue
|
| | | advanceMinutes = flashSaleIpyData.GetAdvanceMinutes()
|
| | | startTime = datetime.datetime.strptime("%s %s:00" % (startDate, startTimeList[0]), ChConfig.TYPE_Time_Format) + datetime.timedelta(minutes=-advanceMinutes)
|
| | | endTime = datetime.datetime.strptime("%s %s:00" % (endDate, endTimeList[-1]), ChConfig.TYPE_Time_Format)
|
| | | curDateTime = GameWorld.GetCurrentTime()
|
| | | if startTime <= curDateTime <= endTime:
|
| | | 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 % actNum, startTimeNum, ChConfig.Def_PDictType_FlashSale)
|
| | | GameWorld.DebugLog(" 发送新限时抢购邮件提醒!", curPlayer.GetID())
|
| | | # else:
|
| | | # GameWorld.DebugLog(" 发送新限时抢购邮件提醒 时间没到!startTime=%s,endTime=%s,curDateTime=%s"%(startTime,endTime,curDateTime), curPlayer.GetID())
|
| | | return
|
| | |
|
| | |
|
| | | def Sync_flashSaleActionInfo(curPlayer):
|
| | | def Sync_flashSaleActionInfo(curPlayer, actNum):
|
| | | ## 通知限时抢购活动信息
|
| | | actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {})
|
| | | actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_FlashSale, actNum)
|
| | | if not actInfo:
|
| | | return
|
| | |
|
| | |
| | | job = curPlayer.GetJob()
|
| | | openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
|
| | | packInfo = ChPyNetSendPack.tagMCFlashSaleInfo()
|
| | | packInfo.ActNum = actNum
|
| | | packInfo.StartDate = GameWorld.GetOperationActionDateStr(flashSaleIpyData.GetStartDate(), openServerDay)
|
| | | packInfo.EndtDate = GameWorld.GetOperationActionDateStr(flashSaleIpyData.GetEndDate(), openServerDay)
|
| | | packInfo.AdvanceMinutes = flashSaleIpyData.GetAdvanceMinutes()
|
| | |
| | | #struct tagCMFlashSaleAppointment
|
| | | #{
|
| | | # tagHead Head;
|
| | | # BYTE ActNum; //活动编号
|
| | | # DWORD GoodsID; // 抢购商品标识
|
| | | # BYTE State; // 1-预约 0-取消
|
| | | #};
|
| | | def OnFlashSaleAppointment(index, packData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | actNum = packData.ActNum
|
| | | goodsID = packData.GoodsID
|
| | |
|
| | | actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {})
|
| | | actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_FlashSale, actNum)
|
| | | if not actInfo:
|
| | | return
|
| | | cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
| | | if not cfgID:
|
| | | return
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleYY % goodsID, packData.State, ChConfig.Def_PDictType_FlashSale)
|
| | | Sync_FlashSaleAppointmentInfo(curPlayer, goodsID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FlashSaleYY % (actNum, goodsID), packData.State, ChConfig.Def_PDictType_FlashSale)
|
| | | Sync_FlashSaleAppointmentInfo(curPlayer, actNum, goodsID)
|
| | | return
|
| | |
|
| | |
|
| | | def Sync_FlashSaleAppointmentInfo(curPlayer, goodsID=0):
|
| | | def Sync_FlashSaleAppointmentInfo(curPlayer, actNum, goodsID=0):
|
| | | ##通知限时抢购预约情况
|
| | | actInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_FlashSale, {})
|
| | | actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_FlashSale, actNum)
|
| | | if not actInfo:
|
| | | return
|
| | | cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
| | |
| | | woldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
| | |
|
| | | packInfo = ChPyNetSendPack.tagMCFlashSaleAppointmentInfo()
|
| | | packInfo.ActNum = actNum
|
| | | packInfo.GoodsList = []
|
| | | if goodsID == 0:
|
| | | packInfo.IsAll = 1
|
| | |
| | | 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)
|
| | | isAppointment = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleYY % (actNum, goodsMark), 0, ChConfig.Def_PDictType_FlashSale)
|
| | | if isAppointment:
|
| | | appoinetmentPack = ChPyNetSendPack.tagMCFlashSaleAppointmentState()
|
| | | appoinetmentPack.GoodsMark = goodsMark
|
| | |
| | | packInfo.GoodsList.append(appoinetmentPack)
|
| | | else:
|
| | | packInfo.IsAll = 0
|
| | | isAppointment = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleYY % goodsID, 0, ChConfig.Def_PDictType_FlashSale)
|
| | | isAppointment = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FlashSaleYY % (actNum, goodsID), 0, ChConfig.Def_PDictType_FlashSale)
|
| | | appoinetmentPack = ChPyNetSendPack.tagMCFlashSaleAppointmentState()
|
| | | appoinetmentPack.GoodsMark = goodsID
|
| | | appoinetmentPack.State = isAppointment
|