| | |
| | | import DataRecordPack
|
| | | import IPY_GameWorld
|
| | | import NetPackCommon
|
| | | import ItemCommon
|
| | | import GameWorld
|
| | | import ChConfig
|
| | |
|
| | |
| | | return templateID
|
| | |
|
| | | def OnPlayerLogin(curPlayer):
|
| | | isReset = __CheckPlayerCostRebateAction(curPlayer)
|
| | | if not isReset:
|
| | | actCostRebateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_CostRebate, {})
|
| | | # 活动中同步活动信息
|
| | | if actCostRebateInfo.get(ShareDefine.ActKey_State):
|
| | | Sync_CostRebateActionInfo(curPlayer)
|
| | | Sync_CostRebateInfo(curPlayer)
|
| | | |
| | | for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_CostRebate, {}).values():
|
| | | actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
| | | isReset = __CheckPlayerCostRebateAction(curPlayer, actNum)
|
| | | if not isReset:
|
| | | # 活动中同步活动信息
|
| | | if actInfo.get(ShareDefine.ActKey_State):
|
| | | Sync_CostRebateActionInfo(curPlayer, actNum)
|
| | | Sync_CostRebateInfo(curPlayer, actNum)
|
| | | return
|
| | |
|
| | | def RefreshCostRebateActionInfo():
|
| | | def RefreshCostRebateActionInfo(actNum):
|
| | | ## 收到GameServer同步的活动信息,刷新活动信息
|
| | | playerManager = GameWorld.GetPlayerManager()
|
| | | for index in xrange(playerManager.GetPlayerCount()):
|
| | | curPlayer = playerManager.GetPlayerByIndex(index)
|
| | | if curPlayer.GetID() == 0:
|
| | | continue
|
| | | __CheckPlayerCostRebateAction(curPlayer)
|
| | | __CheckPlayerCostRebateAction(curPlayer, actNum)
|
| | | return
|
| | |
|
| | | def __CheckPlayerCostRebateAction(curPlayer):
|
| | | def __CheckPlayerCostRebateAction(curPlayer, actNum):
|
| | | ## 检查玩家消费返利活动数据信息
|
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
|
| | | actCostRebateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_CostRebate, {})
|
| | | costRebateID = actCostRebateInfo.get(ShareDefine.ActKey_ID, 0)
|
| | | state = actCostRebateInfo.get(ShareDefine.ActKey_State, 0)
|
| | | actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_CostRebate, actNum)
|
| | | actID = actInfo.get(ShareDefine.ActKey_ID, 0)
|
| | | state = actInfo.get(ShareDefine.ActKey_State, 0)
|
| | |
|
| | | playerCostRebateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateID) # 玩家身上的活动ID
|
| | | playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateID % actNum) # 玩家身上的活动ID
|
| | |
|
| | | # 活动ID 相同的话不处理
|
| | | if costRebateID == playerCostRebateID:
|
| | | #GameWorld.DebugLog("消费返利活动ID不变,不处理!", curPlayer.GetPlayerID())
|
| | | if actID == playerActID:
|
| | | GameWorld.DebugLog("消费返利活动ID不变,不处理!actNum=%s,actID=%s" % (actNum, actID), curPlayer.GetPlayerID())
|
| | | return
|
| | | actWorldLV = actCostRebateInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
| | | playerWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateWorldLV)
|
| | | templateID = GetTemplateID(actCostRebateInfo.get(ShareDefine.ActKey_CfgID, 0), actCostRebateInfo.get(ShareDefine.ActKey_DayIndex, 0))
|
| | | playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateTemplateID)
|
| | | actWorldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
| | | playerWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateWorldLV % actNum)
|
| | | templateID = GetTemplateID(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0))
|
| | | playerTemplateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateTemplateID % actNum)
|
| | |
|
| | | GameWorld.DebugLog("消费返利重置! costRebateID=%s,playerCostRebateID=%s,state=%s,templateID=%s,playerTemplateID=%s" |
| | | % (costRebateID, playerCostRebateID, state, templateID, playerTemplateID), playerID)
|
| | | GameWorld.DebugLog("消费返利重置! actNum=%s,actID=%s,playerActID=%s,state=%s,templateID=%s,playerTemplateID=%s" |
| | | % (actNum, actID, playerActID, state, templateID, playerTemplateID), playerID)
|
| | |
|
| | | # 未领取的奖励邮件发放
|
| | | __SendCostRebateMail(curPlayer, playerTemplateID, playerWorldLV)
|
| | | __SendCostRebateMail(curPlayer, playerTemplateID, playerWorldLV, actNum)
|
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateID, costRebateID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateTemplateID, templateID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateWorldLV, actWorldLV)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateGold, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateAwardRecord, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateID % actNum, actID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateTemplateID % actNum, templateID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateWorldLV % actNum, actWorldLV)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateGold % actNum, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateAwardRecord % actNum, 0)
|
| | |
|
| | | Sync_CostRebateActionInfo(curPlayer)
|
| | | Sync_CostRebateInfo(curPlayer)
|
| | | Sync_CostRebateActionInfo(curPlayer, actNum)
|
| | | Sync_CostRebateInfo(curPlayer, actNum)
|
| | | return True
|
| | |
|
| | | def __SendCostRebateMail(curPlayer, playerTemplateID, playerWorldLV):
|
| | | def __SendCostRebateMail(curPlayer, playerTemplateID, playerWorldLV, actNum):
|
| | | # 未领取的奖励邮件发放
|
| | |
|
| | | if not playerTemplateID:
|
| | | return
|
| | |
|
| | | costGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateGold)
|
| | | costGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateGold % actNum)
|
| | | if not costGold:
|
| | | return
|
| | |
|
| | |
| | | job = curPlayer.GetJob()
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | batchPlayerIDList, batchAddItemList, batchParamList = [], [], []
|
| | | awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateAwardRecord)
|
| | | awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateAwardRecord % actNum)
|
| | |
|
| | | for ipyData in ipyDataList:
|
| | | awardIndex = ipyData.GetAwardIndex()
|
| | |
| | | batchParamList.append([needCostGold])
|
| | |
|
| | | if batchPlayerIDList:
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateAwardRecord, awardRecord)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateAwardRecord % actNum, awardRecord)
|
| | | PlayerControl.SendMailBatch("ConsumptionRebateMail", batchPlayerIDList, batchAddItemList, batchParamList)
|
| | |
|
| | | return
|
| | |
| | | GameWorld.DebugLog("不计入消费返利的消费类型!costType=%s" % costType, curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | actCostRebateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_CostRebate, {})
|
| | | if not actCostRebateInfo.get(ShareDefine.ActKey_State):
|
| | | GameWorld.DebugLog("消费返利活动当前未开启!")
|
| | | return
|
| | | |
| | | actID = actCostRebateInfo.get(ShareDefine.ActKey_ID)
|
| | | templateID = GetTemplateID(actCostRebateInfo.get(ShareDefine.ActKey_CfgID, 0), actCostRebateInfo.get(ShareDefine.ActKey_DayIndex, 0))
|
| | | if not actID or not templateID:
|
| | | GameWorld.ErrLog("消费返利活动数据异常!actID=%s,templateID=%s" % (actID, templateID), curPlayer.GetPlayerID())
|
| | | return
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateID, actID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateTemplateID, templateID)
|
| | | |
| | | curCostGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateGold)
|
| | | updCostGold = curCostGold + costGold
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateGold, updCostGold)
|
| | | Sync_CostRebateInfo(curPlayer)
|
| | | GameWorld.DebugLog("玩家消费返利活动: actID=%s,templateID=%s,curCostGold=%s,costGold=%s,updCostGold=%s" |
| | | % (actID, templateID, curCostGold, costGold, updCostGold), curPlayer.GetPlayerID())
|
| | | for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_CostRebate, {}).values():
|
| | | actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
| | | |
| | | if not actInfo.get(ShareDefine.ActKey_State):
|
| | | GameWorld.DebugLog("消费返利活动当前未开启!actNum=%s" % actNum)
|
| | | continue
|
| | | |
| | | actID = actInfo.get(ShareDefine.ActKey_ID)
|
| | | templateID = GetTemplateID(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0))
|
| | | if not actID or not templateID:
|
| | | GameWorld.ErrLog("消费返利活动数据异常!actNum=%s,actID=%s,templateID=%s" % (actNum, actID, templateID), curPlayer.GetPlayerID())
|
| | | continue
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateID % actNum, actID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateTemplateID % actNum, templateID)
|
| | | |
| | | curCostGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateGold % actNum)
|
| | | updCostGold = curCostGold + costGold
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateGold % actNum, updCostGold)
|
| | | Sync_CostRebateInfo(curPlayer, actNum)
|
| | | GameWorld.DebugLog("玩家消费返利活动: actNum=%s,actID=%s,templateID=%s,curCostGold=%s,costGold=%s,updCostGold=%s" |
| | | % (actNum, actID, templateID, curCostGold, costGold, updCostGold), curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | def OnGetCostRebateAward(curPlayer, awardIndex):
|
| | | def OnGetCostRebateAward(curPlayer, awardIndex, actNum):
|
| | | ## 领取消费返利奖励
|
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
|
| | | actCostRebateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_CostRebate, {})
|
| | | costRebateID = actCostRebateInfo.get(ShareDefine.ActKey_ID, 0)
|
| | | state = actCostRebateInfo.get(ShareDefine.ActKey_State, 0)
|
| | | templateID = GetTemplateID(actCostRebateInfo.get(ShareDefine.ActKey_CfgID, 0), actCostRebateInfo.get(ShareDefine.ActKey_DayIndex, 0))
|
| | | if not state or not templateID:
|
| | | GameWorld.DebugLog("没有消费返利活动,无法领奖!state=%s,templateID=%s" % (state, templateID), playerID)
|
| | | actNum = GameWorld.ToIntDef(actNum, 0)
|
| | | if actNum <= 0:
|
| | | GameWorld.DebugLog("没有该活动编号! actNum=%s" % actNum)
|
| | | return
|
| | |
|
| | | playerCostRebateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateID) # 玩家身上的活动ID
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | |
| | | actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_CostRebate, actNum)
|
| | | costRebateID = actInfo.get(ShareDefine.ActKey_ID, 0)
|
| | | state = actInfo.get(ShareDefine.ActKey_State, 0)
|
| | | templateID = GetTemplateID(actInfo.get(ShareDefine.ActKey_CfgID, 0), actInfo.get(ShareDefine.ActKey_DayIndex, 0))
|
| | | if not state or not templateID:
|
| | | GameWorld.DebugLog("没有消费返利活动,无法领奖!actNum=%s,state=%s,templateID=%s" % (actNum, state, templateID), playerID)
|
| | | return
|
| | | |
| | | playerCostRebateID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateID % actNum) # 玩家身上的活动ID
|
| | | if costRebateID != playerCostRebateID:
|
| | | return
|
| | |
|
| | | awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateAwardRecord)
|
| | | awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateAwardRecord % actNum)
|
| | | if awardRecord & pow(2, awardIndex):
|
| | | GameWorld.DebugLog("已经领取过该消费返利活动奖励!awardIndex=%s" % awardIndex, playerID)
|
| | | GameWorld.DebugLog("已经领取过该消费返利活动奖励!actNum=%s,awardIndex=%s,awardRecord=%s" % (actNum, awardIndex, awardRecord), playerID)
|
| | | return
|
| | |
|
| | | ipyDataList = IpyGameDataPY.GetIpyGameDataList("CostRebateTemplate", templateID)
|
| | |
| | | return
|
| | |
|
| | | needCostGold = awardIpyData.GetNeedCostGold()
|
| | | actWorldLV = actCostRebateInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
| | | actWorldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
| | | awardItemList = __GetItemList(awardIpyData.GetAwardItemList(), curPlayer.GetJob(), actWorldLV)
|
| | |
|
| | | curCostGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateGold)
|
| | | curCostGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateGold % actNum)
|
| | | if curCostGold < needCostGold:
|
| | | GameWorld.DebugLog("所需消费仙玉数不足,无法领取!templateID=%s,awardIndex=%s,needCostGold=%s,curCostGold=%s"
|
| | | % (templateID, awardIndex, needCostGold, curCostGold), playerID)
|
| | | return
|
| | |
|
| | | needSpace = len(awardItemList)
|
| | | packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
|
| | | if packSpace < needSpace:
|
| | | if not ItemControler.CheckPackSpaceEnough(curPlayer, awardItemList):
|
| | | return
|
| | |
|
| | | awardRecord |= pow(2, awardIndex)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateAwardRecord, awardRecord)
|
| | | Sync_CostRebateInfo(curPlayer)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CostRebateAwardRecord % actNum, awardRecord)
|
| | | Sync_CostRebateInfo(curPlayer, actNum)
|
| | |
|
| | | notifyKey = awardIpyData.GetNotifyKey()
|
| | | if notifyKey:
|
| | | PlayerControl.WorldNotify(0, notifyKey, [curPlayer.GetPlayerName(), needCostGold])
|
| | |
|
| | | for itemID, itemCount, isBind in awardItemList:
|
| | | for itemID, itemCount, _ in awardItemList:
|
| | | ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, 0, [IPY_GameWorld.rptItem])
|
| | |
|
| | | addDataDict = {"TemplateID":templateID, "NeedCostGold":needCostGold, "AwardIndex":awardIndex,
|
| | | "ItemList":str(awardItemList)}
|
| | | "ItemList":str(awardItemList), "ActNum":actNum}
|
| | | DataRecordPack.DR_FuncGiveItem(curPlayer, "CostRebateAward", addDataDict)
|
| | | return
|
| | |
|
| | | def Sync_CostRebateInfo(curPlayer):
|
| | | def Sync_CostRebateInfo(curPlayer, actNum):
|
| | | ## 通知消费返利玩家数据信息
|
| | | playerActInfo = ChPyNetSendPack.tagMCCostRebatePlayerInfo()
|
| | | playerActInfo.CostGoldTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateGold)
|
| | | playerActInfo.AwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateAwardRecord)
|
| | | playerActInfo.ActNum = actNum
|
| | | playerActInfo.CostGoldTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateGold % actNum)
|
| | | playerActInfo.AwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CostRebateAwardRecord % actNum)
|
| | | NetPackCommon.SendFakePack(curPlayer, playerActInfo)
|
| | | return
|
| | |
|
| | | def Sync_CostRebateActionInfo(curPlayer):
|
| | | def Sync_CostRebateActionInfo(curPlayer, actNum):
|
| | | ## 通知消费返利活动信息
|
| | | actCostRebateInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_CostRebate, {})
|
| | | |
| | | actCostRebateInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_CostRebate, actNum)
|
| | | if not actCostRebateInfo:
|
| | | return
|
| | |
|
| | |
| | | actWorldLV = actCostRebateInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
| | | openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
|
| | | actInfo = ChPyNetSendPack.tagMCCostRebateInfo()
|
| | | actInfo.ActNum = actNum
|
| | | actInfo.StartDate = GameWorld.GetOperationActionDateStr(ipyData.GetStartDate(), openServerDay)
|
| | | actInfo.EndtDate = GameWorld.GetOperationActionDateStr(ipyData.GetEndDate(), openServerDay)
|
| | | actInfo.LimitLV = ipyData.GetLVLimit()
|