| | |
| | | import PyGameData
|
| | | import ItemCommon
|
| | |
|
| | | import json
|
| | |
|
| | | def OnLogin(curPlayer):
|
| | | isReset = __CheckPlayerLoginAwardAction(curPlayer)
|
| | |
| | | playerID = curPlayer.GetPlayerID()
|
| | |
|
| | | actLoginAwardInfo = PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_LoginAward, {})
|
| | | #LoginAwardID = actLoginAwardInfo.get(ShareDefine.ActKey_ID, 0)
|
| | | #loginAwardID = actLoginAwardInfo.get(ShareDefine.ActKey_ID, 0)
|
| | | state = actLoginAwardInfo.get(ShareDefine.ActKey_State, 0)
|
| | | cfgID = actLoginAwardInfo.get(ShareDefine.ActKey_CfgID, 0)
|
| | | #passlv = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_TrialTower_PassLV)
|
| | | #isOk = AddLoginAwardActionCnt(curPlayer, ChConfig.Def_WPAct_Tower, passlv, False)
|
| | | #AddLoginAwardActionCnt(curPlayer, ChConfig.Def_WPAct_Login, 1)
|
| | | |
| | | if state:
|
| | | #每天都要触发
|
| | | AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_Login, 1, False, False)
|
| | | SyncLoginAwardPlayerInfo(curPlayer)
|
| | |
|
| | | playerLoginAwardID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoginAwardID, 0, ChConfig.Def_PDictType_LoginAward) # 玩家身上的活动ID
|
| | | # if not isOk and state:
|
| | | # SyncLoginAwardPlayerInfo(curPlayer)
|
| | | # 活动ID 相同的话不处理
|
| | | if cfgID == playerLoginAwardID:
|
| | | #GameWorld.DebugLog("登录奖励活动ID不变,不处理!", curPlayer.GetPlayerID())
|
| | | return
|
| | | actWorldLVList = actLoginAwardInfo.get(ShareDefine.ActKey_WorldLVList, [])
|
| | | # 未领取的奖励邮件发放
|
| | | __SendLoginAwardMail(curPlayer, playerLoginAwardID)
|
| | | if playerLoginAwardID:
|
| | | __SendLoginAwardMail(curPlayer, playerLoginAwardID)
|
| | |
|
| | | if not cfgID:
|
| | | GameWorld.DebugLog(' 登录奖励活动重置!')
|
| | | curPlayer.ClearNomalDict(ChConfig.Def_PDictType_LoginAward)
|
| | | #if not cfgID:
|
| | | GameWorld.DebugLog(' 登录奖励活动重置!')
|
| | | curPlayer.ClearNomalDict(ChConfig.Def_PDictType_LoginAward)
|
| | |
|
| | | GameWorld.DebugLog("登录奖励变更! state=%s,cfgID=%s,playerLoginAwardID=%s" % (state, cfgID, playerLoginAwardID), playerID)
|
| | | GameWorld.DebugLog("登录奖励变更! state=%s,cfgID=%s,playerLoginAwardID=%s,actWorldLVList=%s" % (state, cfgID, playerLoginAwardID, actWorldLVList), playerID)
|
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoginAwardID, cfgID, ChConfig.Def_PDictType_LoginAward)
|
| | | for i, actWorldLV in enumerate(actWorldLVList):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoginAwardWorldLV % i, actWorldLV, ChConfig.Def_PDictType_LoginAward)
|
| | |
|
| | | SyncLoginAwardInfo(curPlayer)
|
| | | return True
|
| | |
| | |
|
| | | def __SendLoginAwardMail(curPlayer, cfgID):
|
| | | # 未领取的奖励邮件发放
|
| | | actBossIpyData = IpyGameDataPY.GetIpyGameData("ActLoginAward", cfgID)
|
| | | if not actBossIpyData:
|
| | | actIpyData = IpyGameDataPY.GetIpyGameData("ActLoginAward", cfgID)
|
| | | if not actIpyData:
|
| | | return
|
| | | templateIDList = actBossIpyData.GetTemplateID()
|
| | | templateIDList = actIpyData.GetTemplateID()
|
| | | if not templateIDList:
|
| | | return
|
| | |
|
| | | totalItemDict = {}
|
| | | for day, tidList in enumerate(templateIDList):
|
| | | playerWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoginAwardWorldLV % day, 0, ChConfig.Def_PDictType_LoginAward)
|
| | |
|
| | | for tid in tidList:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData('LoginAward', tid)
|
| | | if not ipyData:
|
| | |
| | | canGotCnt = (curTimes - gotTimes) / singleTimes
|
| | | if not canGotCnt:
|
| | | continue
|
| | | itemDict = __GetAwardItem(curPlayer, ipyData, canGotCnt)
|
| | | itemDict = __GetAwardItem(curPlayer, ipyData, playerWorldLV, canGotCnt)
|
| | | GameWorld.AddDictValue(totalItemDict, itemDict)
|
| | |
|
| | | if not totalItemDict:
|
| | | return
|
| | | totalItemList = [[itemID, itemCnt, 1] for itemID, itemCnt in totalItemDict.items()]
|
| | | PlayerControl.SendMailByKey('SecondWeekReward', [curPlayer.GetID()], totalItemList)
|
| | | PlayerControl.SendMailByKey('LoginAward_1', [curPlayer.GetID()], totalItemList)
|
| | | return
|
| | |
|
| | |
|
| | | def AddLoginAwardActionCnt(curPlayer, actionID, addCnt=1, isAdd=True):
|
| | | def AddLoginAwardActionCnt(curPlayer, actionID, addCnt=1, isAdd=True, isSync=True):
|
| | | '''增加登录奖励相关活动完成次数'''
|
| | | #判断活动是否开启
|
| | | if not addCnt:
|
| | |
| | |
|
| | | if not state or not cfgID:
|
| | | return
|
| | | actBossIpyData = IpyGameDataPY.GetIpyGameData("ActLoginAward", cfgID)
|
| | | if not actBossIpyData:
|
| | | actIpyData = IpyGameDataPY.GetIpyGameData("ActLoginAward", cfgID)
|
| | | if not actIpyData:
|
| | | return
|
| | | templateIDList = actBossIpyData.GetTemplateID()
|
| | | templateIDList = actIpyData.GetTemplateID()
|
| | | dayIndex = actLoginAwardInfo.get(ShareDefine.ActKey_DayIndex, 0)
|
| | | if dayIndex >= len(templateIDList):
|
| | | return
|
| | |
| | | return
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoginAwardCurTimes % (dayIndex, findTid), updTimes, ChConfig.Def_PDictType_LoginAward)
|
| | | GameWorld.DebugLog(' 增加登录奖励相关活动完成次数 dayIndex=%s, findTid=%s, realAddCnt=%s' % (dayIndex, findTid, realAddCnt))
|
| | | SyncLoginAwardPlayerInfo(curPlayer, dayIndex, findTid)
|
| | | if isSync:
|
| | | SyncLoginAwardPlayerInfo(curPlayer, dayIndex, findTid)
|
| | | return True
|
| | |
|
| | |
|
| | |
| | | gotTimes = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoginAwardGotTimes % (day, templateID), 0, ChConfig.Def_PDictType_LoginAward)
|
| | | if curTimes - gotTimes < singleTimes:
|
| | | return
|
| | | |
| | | playerWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoginAwardWorldLV % day, 0, ChConfig.Def_PDictType_LoginAward)
|
| | | #给奖励
|
| | | awardDict = __GetAwardItem(curPlayer, ipyData)
|
| | | awardDict = __GetAwardItem(curPlayer, ipyData, playerWorldLV)
|
| | | # 检查背包
|
| | | needSpace = len(awardDict)
|
| | | packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
|
| | |
| | | #GameWorld.Log(' actionID=%s,curTimes=%s,gotTimes=%s,singleTimes=%s,newGotTimes=%s'%(actionID, curTimes, gotTimes,singleTimes, newGotTimes))
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoginAwardGotTimes % (day, templateID), newGotTimes, ChConfig.Def_PDictType_LoginAward)
|
| | | for itemID, itemCnt in awardDict.items():
|
| | | ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 1, [IPY_GameWorld.rptItem])
|
| | | ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])
|
| | | SyncLoginAwardPlayerInfo(curPlayer, day, templateID)
|
| | | return
|
| | |
|
| | |
|
| | |
|
| | | def __GetAwardItem(curPlayer, ipyData, times=1):
|
| | | awardDict = {}
|
| | | for itemID, itemCnt, isbind in ipyData.GetReward():
|
| | | def __GetAwardItem(curPlayer, ipyData, worldLV, times=1):
|
| | | awardItemDict = {}
|
| | | awardDict = eval(ipyData.GetReward())
|
| | | wlvList = [int(lv) for lv in awardDict]
|
| | | wlvList.sort()
|
| | | findWlv = wlvList[-1]
|
| | | for wlv in wlvList:
|
| | | if worldLV <= wlv:
|
| | | findWlv = wlv
|
| | | break
|
| | | itemList = awardDict[str(findWlv)]
|
| | | for itemID, itemCnt, isbind in itemList:
|
| | | if not itemID or not itemCnt:
|
| | | continue
|
| | | awardDict[itemID] = awardDict.get(itemID, 0) + itemCnt * times
|
| | | awardItemDict[itemID] = awardItemDict.get(itemID, 0) + itemCnt * times
|
| | |
|
| | | return awardDict
|
| | | return awardItemDict
|
| | |
|
| | |
|
| | | def SyncLoginAwardPlayerInfo(curPlayer, day=-1, templateID=-1):
|
| | |
| | | cfgID = actLoginAwardInfo.get(ShareDefine.ActKey_CfgID, 0)
|
| | | if not state or not cfgID:
|
| | | return
|
| | | actBossIpyData = IpyGameDataPY.GetIpyGameData("ActLoginAward", cfgID)
|
| | | if not actBossIpyData:
|
| | | actIpyData = IpyGameDataPY.GetIpyGameData("ActLoginAward", cfgID)
|
| | | if not actIpyData:
|
| | | return
|
| | | templateIDList = actBossIpyData.GetTemplateID()
|
| | | templateIDList = actIpyData.GetTemplateID()
|
| | | if not templateIDList:
|
| | | return
|
| | | if day != -1:
|
| | |
| | | cfgID = actLoginAwardInfo.get(ShareDefine.ActKey_CfgID, 0)
|
| | | if not cfgID:
|
| | | return
|
| | | actBossIpyData = IpyGameDataPY.GetIpyGameData("ActLoginAward", cfgID)
|
| | | if not actBossIpyData:
|
| | | actIpyData = IpyGameDataPY.GetIpyGameData("ActLoginAward", cfgID)
|
| | | if not actIpyData:
|
| | | return
|
| | | templateIDList = actBossIpyData.GetTemplateID()
|
| | | templateIDList = actIpyData.GetTemplateID()
|
| | | if not templateIDList:
|
| | | return
|
| | | actWorldLVList = actLoginAwardInfo.get(ShareDefine.ActKey_WorldLVList, [])
|
| | | openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
|
| | | actInfo = ChPyNetSendPack.tagMCActLoginAwardInfo()
|
| | | actInfo.Clear()
|
| | | actInfo.StartDate = GameWorld.GetOperationActionDateStr(actBossIpyData.GetStartDate(), openServerDay)
|
| | | actInfo.EndtDate = GameWorld.GetOperationActionDateStr(actBossIpyData.GetEndDate(), openServerDay)
|
| | | actInfo.AdvanceMinutes = actBossIpyData.GetAdvanceMinutes()
|
| | | actInfo.IsDayReset = actBossIpyData.GetIsDayReset()
|
| | | actInfo.ResetType = actBossIpyData.GetResetType()
|
| | | actInfo.LimitLV = actBossIpyData.GetLVLimit()
|
| | | actInfo.StartDate = GameWorld.GetOperationActionDateStr(actIpyData.GetStartDate(), openServerDay)
|
| | | actInfo.EndtDate = GameWorld.GetOperationActionDateStr(actIpyData.GetEndDate(), openServerDay)
|
| | | actInfo.AdvanceMinutes = actIpyData.GetAdvanceMinutes()
|
| | | actInfo.IsDayReset = actIpyData.GetIsDayReset()
|
| | | actInfo.ResetType = actIpyData.GetResetType()
|
| | | actInfo.LimitLV = actIpyData.GetLVLimit()
|
| | | actInfo.DayInfoList = []
|
| | | tidList = []
|
| | | for day, dayActList in enumerate(templateIDList):
|
| | |
| | | for tid in dayActList:
|
| | | if tid not in tidList:
|
| | | tidList.append(tid)
|
| | | |
| | | dayInfo.WorldLV = actWorldLVList[day] if day < len(actWorldLVList) else 0
|
| | | actInfo.DayInfoList.append(dayInfo)
|
| | | actInfo.DayCnt = len(actInfo.DayInfoList)
|
| | | actInfo.ActionInfo = []
|
| | |
| | | tInfo.ActionType = ipyData.GetActionType()
|
| | | tInfo.TotalTimes = ipyData.GetTotalTimes()
|
| | | tInfo.SingleTimes = ipyData.GetSingleTimes()
|
| | | tInfo.ItemInfo = []
|
| | | for itemID, itemCnt, isBind in ipyData.GetReward():
|
| | | awardItem = ChPyNetSendPack.tagMCActLoginAwardItem()
|
| | | awardItem.ItemID = itemID
|
| | | awardItem.ItemCnt = itemCnt
|
| | | awardItem.IsBind = isBind
|
| | | tInfo.ItemInfo.append(awardItem)
|
| | | tInfo.ItemInfo = ipyData.GetReward()
|
| | | tInfo.Count = len(tInfo.ItemInfo)
|
| | | actInfo.ActionInfo.append(tInfo)
|
| | | actInfo.TCount = len(actInfo.ActionInfo)
|