| | |
| | | #-------------------------------------------------------------------------------
|
| | |
|
| | | import PyGameData
|
| | | import PlayerCoin
|
| | | import ShareDefine
|
| | | import PlayerControl
|
| | | import IpyGameDataPY
|
| | | import PlayerZhanling
|
| | | import ChPyNetSendPack
|
| | | import ItemControler
|
| | | import IPY_GameWorld
|
| | | import NetPackCommon
|
| | | import GameWorld
|
| | | import ChConfig
|
| | | import time
|
| | |
|
| | | def OnPlayerLogin(curPlayer):
|
| | |
|
| | |
| | | actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
| | | isReset = __CheckPlayerActLoginAction(curPlayer, actNum)
|
| | | # 活动中同步活动信息
|
| | | if not isReset and actInfo.get(ShareDefine.ActKey_State):
|
| | | if not isReset and actInfo.get(ShareDefine.ActKey_State) and curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewID % actNum):
|
| | | Sync_ActLoginActionInfo(curPlayer, actNum)
|
| | | Sync_ActLoginPlayerInfo(curPlayer, actNum)
|
| | |
|
| | | return
|
| | |
|
| | | def OnDay(curPlayer):
|
| | | OnCheckRelateFuncAct(curPlayer)
|
| | | return
|
| | |
|
| | | def OnCheckRelateFuncAct(curPlayer, openFuncIDList=None):
|
| | | ## 检查关联功能ID开启的活动
|
| | | for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_ActLoginNew, {}).values():
|
| | | if not actInfo.get(ShareDefine.ActKey_State):
|
| | | continue
|
| | | cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("ActLoginNew", cfgID)
|
| | | if not ipyData:
|
| | | continue
|
| | | if not hasattr(ipyData, "GetRelateFuncID"):
|
| | | continue
|
| | | relateFuncID = ipyData.GetRelateFuncID()
|
| | | if not relateFuncID:
|
| | | continue
|
| | | if openFuncIDList and relateFuncID not in openFuncIDList:
|
| | | continue
|
| | | actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
| | | __CheckPlayerActLoginAction(curPlayer, actNum)
|
| | | |
| | | return
|
| | |
|
| | | def RefreshActLoginActionInfo(actNum):
|
| | |
| | |
|
| | | playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewID % actNum) # 玩家身上的活动ID
|
| | |
|
| | | funcActInfo = GameWorld.GetActRelateFuncInfo(curPlayer, "ActLoginNew", actInfo, playerActID)
|
| | | if funcActInfo:
|
| | | isInAct, actID = funcActInfo
|
| | | if not isInAct:
|
| | | return
|
| | | |
| | | # 活动ID 相同的话不处理
|
| | | if actID == playerActID:
|
| | | GameWorld.DebugLog("新登录活动ID不变,不处理! actNum=%s,actID=%s" % (actNum, actID), curPlayer.GetPlayerID())
|
| | |
| | |
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActLoginNewID % actNum, actID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActLoginNewAward % actNum, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActLoginNewAwardEx % actNum, 0)
|
| | |
|
| | | if state:
|
| | | cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("ActLoginNew", cfgID)
|
| | | if ipyData:
|
| | | if ipyData.GetAwardExCTGID():
|
| | | PlayerCoin.DoResetCTGCountByIDList(curPlayer, "ActLoginNew", [ipyData.GetAwardExCTGID()])
|
| | | if ipyData.GetActZhanlingType():
|
| | | PlayerZhanling.ResetZhanling(curPlayer, ipyData.GetActZhanlingType())
|
| | | Sync_ActLoginActionInfo(curPlayer, actNum)
|
| | | Sync_ActLoginPlayerInfo(curPlayer, actNum)
|
| | | return True
|
| | |
| | | def OnGetActLoginAward(curPlayer, dayNum, actNum):
|
| | | ## 领取活动奖励
|
| | |
|
| | | isAwardEx = dayNum / 1000
|
| | | dayNum = dayNum % 1000
|
| | | actNum = GameWorld.ToIntDef(actNum)
|
| | |
|
| | | actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_ActLoginNew, actNum)
|
| | |
| | | GameWorld.DebugLog("非登录活动中! actNum=%s" % actNum)
|
| | | return
|
| | |
|
| | | curDayNum = actInfo.get(ShareDefine.ActKey_DayIndex) + 1
|
| | | playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewID % actNum)
|
| | | if not playerActID:
|
| | | return
|
| | | |
| | | curDayNum = GameWorld.GetDiff_Day(int(time.time()), playerActID) + 1
|
| | | if curDayNum < dayNum:
|
| | | GameWorld.DebugLog("未到可领取的登录天,无法领取! actNum=%s,curDayNum=%s < %s" % (actNum, curDayNum, dayNum))
|
| | | return
|
| | |
| | | if not findIpyData:
|
| | | GameWorld.DebugLog("找不到对应登录天奖励! actNum=%s,cfgID=%s,templateID=%s,dayNum=%s" % (actNum, cfgID, templateID, dayNum))
|
| | | return
|
| | | awardItemList = findIpyData.GetLoginAwardItemList()
|
| | | |
| | | if isAwardEx:
|
| | | awardExCTGID = ipyData.GetAwardExCTGID()
|
| | | if not awardExCTGID:
|
| | | GameWorld.DebugLog("该登录活动没有扩展奖励! actNum=%s,cfgID=%s" % (actNum, cfgID))
|
| | | return
|
| | | if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CTGGoodsBuyCount % awardExCTGID):
|
| | | GameWorld.DebugLog("该登录活动扩展奖励礼包未购买,无法领取! actNum=%s,cfgID=%s,awardExCTGID=%s" % (actNum, cfgID, awardExCTGID))
|
| | | return
|
| | | stateKey = ChConfig.Def_PDict_ActLoginNewAwardEx
|
| | | awardItemList = findIpyData.GetLoginAwardItemListEx()
|
| | | else:
|
| | | stateKey = ChConfig.Def_PDict_ActLoginNewAward
|
| | | awardItemList = findIpyData.GetLoginAwardItemList()
|
| | |
|
| | | awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewAward % actNum)
|
| | | if not awardItemList:
|
| | | return
|
| | | |
| | | awardRecord = curPlayer.NomalDictGetProperty(stateKey % actNum)
|
| | | if awardRecord & pow(2, dayNum):
|
| | | GameWorld.DebugLog("登录活动该天已领奖! actNum=%s,dayNum=%s,awardRecord=%s" % (actNum, dayNum, awardRecord))
|
| | | return
|
| | |
| | | return
|
| | |
|
| | | if costMoneyType and costMoneyValue:
|
| | | PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, "ActLoginNew", {"actNum":actNum, "dayNum":dayNum})
|
| | | PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, "ActLoginNew", {"actNum":actNum, "dayNum":dayNum, "isAwardEx":isAwardEx})
|
| | |
|
| | | updAwardRecord = awardRecord | pow(2, dayNum)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ActLoginNewAward % actNum, updAwardRecord)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, stateKey % actNum, updAwardRecord)
|
| | | Sync_ActLoginPlayerInfo(curPlayer, actNum)
|
| | |
|
| | | GameWorld.DebugLog("领取登录活动奖励! actNum=%s,dayNum=%s,awardItemList=%s" % (actNum, dayNum, awardItemList))
|
| | | GameWorld.DebugLog("领取登录活动奖励! actNum=%s,dayNum=%s,isAwardEx=%s,awardItemList=%s,curDayNum=%s" % (actNum, dayNum, isAwardEx, awardItemList, curDayNum))
|
| | |
|
| | | for itemID, itemCount, isAuctionItem in awardItemList:
|
| | | ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem], event=["ActLoginNew", False, {}])
|
| | |
| | | clientPack = ChPyNetSendPack.tagMCActLoginPlayerInfoNew()
|
| | | clientPack.ActNum = actNum
|
| | | clientPack.LoginAward = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewAward % actNum)
|
| | | clientPack.LoginAwardEx = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewAwardEx % actNum)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | |
| | | if not actInfo:
|
| | | return
|
| | | if not actInfo.get(ShareDefine.ActKey_State):
|
| | | return
|
| | | playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ActLoginNewID % actNum)
|
| | | if not playerActID:
|
| | | return
|
| | | cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("ActLoginNew", cfgID)
|
| | |
| | | if not dayIpyDataList:
|
| | | return
|
| | |
|
| | | startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData)
|
| | | if hasattr(ipyData, "GetRelateFuncID") and ipyData.GetRelateFuncID():
|
| | | startDateStr, endDateStr = GameWorld.GetActRelateFuncDate(ipyData, playerActID, True)
|
| | | else:
|
| | | startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData)
|
| | | actPack = ChPyNetSendPack.tagMCActLoginNew()
|
| | | actPack.Clear()
|
| | | actPack.ActNum = actNum
|
| | |
| | | actPack.LimitLV = ipyData.GetLVLimit()
|
| | | actPack.RepSignMoneyType = moneyType
|
| | | actPack.RepSignMoneyValue = moneyValue
|
| | | actPack.AwardExCTGID = ipyData.GetAwardExCTGID()
|
| | |
|
| | | actPack.AwardDayList = []
|
| | | for dayIpyData in dayIpyDataList:
|
| | |
| | | dayInfo.AwardItemList.append(itemInfo)
|
| | | dayInfo.Count = len(dayInfo.AwardItemList)
|
| | |
|
| | | dayInfo.AwardItemListEx = []
|
| | | for itemID, itemCount, isAuctionItem in dayIpyData.GetLoginAwardItemListEx():
|
| | | itemInfo = ChPyNetSendPack.tagMCActLoginNewItem()
|
| | | itemInfo.ItemID = itemID
|
| | | itemInfo.ItemCount = itemCount
|
| | | itemInfo.IsBind = isAuctionItem
|
| | | dayInfo.AwardItemListEx.append(itemInfo)
|
| | | dayInfo.CountEx = len(dayInfo.AwardItemListEx)
|
| | | |
| | | actPack.AwardDayList.append(dayInfo)
|
| | | actPack.DayCount = len(actPack.AwardDayList)
|
| | | NetPackCommon.SendFakePack(curPlayer, actPack)
|