|  |  | 
 |  |  | 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)
 | 
 |  |  |     if state:
 | 
 |  |  | 
 |  |  |     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
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | 
 |  |  |     
 | 
 |  |  |     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
 | 
 |  |  | 
 |  |  |     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)
 |