| | |
| | | import math
|
| | | import json
|
| | | #领取状态 个位数标识 (可领取即已通知过玩家该封邮件,需要在邮件发生时和上线时设置状态
|
| | | #0 未通知,1 不可领取, 2 可领取, 3 已领取
|
| | | #0 未通知,1 不可领取, 2 可领取, 3 已领取,4 已删除
|
| | | (
|
| | | Unknown_State,
|
| | | Disable_State,
|
| | | Enable_State,
|
| | | Yet_State
|
| | | ) = range(4)
|
| | | Yet_State,
|
| | | Del_State
|
| | | ) = range(5)
|
| | |
|
| | | CheckState_OK = 0 # 已审核
|
| | | CheckState_No = 1 # 未审核
|
| | |
| | | def SetPrizeState(curPlayerID, GUID, prizeState, readState):
|
| | | state = readState*10 + prizeState
|
| | | GameWorld.GetCompensationMgr().AddPlayerRec(curPlayerID, GUID, state)
|
| | | return
|
| | |
|
| | | def GetPrizeGetState(curPlayerID, GUID):
|
| | | ## 获取领取状态
|
| | | return GameWorld.GetCompensationMgr().FindPlayerRecState(curPlayerID, GUID) % 10
|
| | |
|
| | | ##查找玩家可领取的补偿列表
|
| | | # @param curPlayer
|
| | |
| | | states = GameWorld.GetCompensationMgr().FindPlayerRecState(curPlayerID, curRequire.GUID)
|
| | | readState = states/10 # 可读
|
| | | curState = states%10 # 领取状态
|
| | | if curState in (Disable_State, Yet_State):
|
| | | if curState in (Disable_State, Del_State):
|
| | | #不可领 或 已领
|
| | | |
| | | #GameWorld.DebugLog("该玩家当前全服邮件状态不下发: curState=%s,GUID=%s" % (curState, curRequire.GUID), curPlayerID)
|
| | | continue
|
| | |
|
| | | limitTime = datetime.datetime.strptime(curRequire.LimitTime, ChConfig.TYPE_Time_Format)
|
| | |
| | | continue
|
| | |
|
| | | #可以用的奖励
|
| | | if Enable_State != curState:
|
| | | if Enable_State != curState and curState != Yet_State:
|
| | | SetPrizeState(curPlayerID, curRequire.GUID, Enable_State, readState)
|
| | | allList.append((curRequire.GUID, curRequire.Text, curRequire.CreateTime,
|
| | | curRequire.Gold, curRequire.GoldPaper, curRequire.Silver))
|
| | |
| | | subPack.Gold = gold
|
| | | subPack.GoldPaper = goldPaper
|
| | | subPack.Silver = silver
|
| | | subPack.IsRead = GameWorld.GetCompensationMgr().FindPlayerRecState(curPlayer.GetPlayerID(), GUID)/10
|
| | | resState = GameWorld.GetCompensationMgr().FindPlayerRecState(curPlayer.GetPlayerID(), GUID)
|
| | | if resState % 10 == Yet_State:
|
| | | subPack.IsRead = Yet_State # 已领取
|
| | | else:
|
| | | subPack.IsRead = resState / 10 # 是否已读
|
| | | for index in xrange(curGUIDItemCount):
|
| | | curItem = GameWorld.GetCompensationMgr().FindItemAt(GUID, index)
|
| | | subPackItem = ChPyNetSendPack.tagGCCompensationItem()
|
| | |
| | | sendPack.PackList.append(subPack)
|
| | | sendPack.Count = len(sendPack.PackList)
|
| | | NetPackCommon.SendFakePack(curPlayer, sendPack)
|
| | | return
|
| | |
|
| | | def SyncQueryCompensationResultByGUID(curPlayer, notifyGUIDList):
|
| | | curPlayerID = curPlayer.GetPlayerID()
|
| | | notifyList = []
|
| | | compensationMgr = GameWorld.GetCompensationMgr()
|
| | | for GUID in notifyGUIDList:
|
| | | findCompensation = compensationMgr.FindPersonalCompensation(curPlayerID, GUID)
|
| | | if findCompensation.PlayerID != curPlayerID:
|
| | | findCompensation = compensationMgr.FindEntireCompensation(GUID)
|
| | | if findCompensation.GUID != GUID:
|
| | | # 找不到邮件
|
| | | continue
|
| | | notifyList.append((findCompensation.GUID, findCompensation.Text, findCompensation.CreateTime, |
| | | findCompensation.Gold, findCompensation.GoldPaper, findCompensation.Silver))
|
| | | if not notifyList:
|
| | | return
|
| | | SyncQueryCompensationResult(curPlayer, notifyList)
|
| | | return
|
| | |
|
| | | ##03 03 玩家请求领取补偿#tagMGRequestCompensation
|
| | |
| | | GameWorld.DebugLog("Compensation### OnMGRequestCompensation myPlayerID %s GUID %s"%(myPlayerID, GUID))
|
| | |
|
| | | compensationType, curEntireRequire = CheckRequestCompensation(curPlayer, GUID)
|
| | | if compensationType == Unknow_CompensationType:
|
| | | if compensationType == Unknow_CompensationType or not curEntireRequire:
|
| | | #领取失败
|
| | | curPlayer.SetDict(Def_RequestState, 0)#解锁
|
| | | GameWorld.DebugLog("Compensation### OnMGRequestCompensation no found")
|
| | |
| | | def CheckRequestCompensation(curPlayer, GUID, isPersonnal = True):
|
| | | curPlayerID = curPlayer.GetID()
|
| | |
|
| | | states = GameWorld.GetCompensationMgr().FindPlayerRecState(curPlayerID, GUID)
|
| | | readState = states/10 # 可读 |
| | | curState = states%10 # 领取状态
|
| | | |
| | | if curState in (Disable_State, Yet_State, Del_State):
|
| | | #不可领 或 已领
|
| | | #GameWorld.DebugLog("当前邮件不可领取或已领: states=%s,curState=%s,GUID=%s" % (states, curState, GUID), curPlayerID)
|
| | | return Unknow_CompensationType, None
|
| | | |
| | | if isPersonnal:
|
| | | #在个人补偿中
|
| | | curPersonalCompensation = GameWorld.GetCompensationMgr().FindPersonalCompensation(curPlayerID, GUID)
|
| | |
| | |
|
| | | #---------
|
| | | #在全服补偿中
|
| | | states = GameWorld.GetCompensationMgr().FindPlayerRecState(curPlayerID, GUID)
|
| | | readState = states/10 # 可读 |
| | | curState = states%10 # 领取状态
|
| | | |
| | | if curState in (Disable_State, Yet_State):
|
| | | #不可领 或 已领
|
| | | return Unknow_CompensationType, None
|
| | | curEntireRequire = GameWorld.GetCompensationMgr().FindEntireCompensation(GUID)
|
| | | if curEntireRequire.GUID != GUID:
|
| | | #不再全服补偿中,删除记录
|
| | |
| | | ##玩家领取补偿物品发放成功
|
| | | # @param curPlayer, GUID
|
| | | # @return None
|
| | | def GiveCompensationSuccess(curPlayer, GUID, CompensationType):
|
| | | def GiveCompensationSuccess(curPlayer, GUID, CompensationType, isDel=False):
|
| | | curPlayerID = curPlayer.GetID()
|
| | | NotifyCompensationResult(curPlayer, GUID, 1)
|
| | | |
| | | SetPrizeState(curPlayerID, GUID, Yet_State, Read_State_Yes) # 设置为已领取
|
| | | #流向记录
|
| | | DataRecordPack.DR_GiveCompensationSuccess(curPlayerID, GUID)
|
| | | if not isDel:
|
| | | SyncQueryCompensationResultByGUID(curPlayer, [GUID])
|
| | | return
|
| | | |
| | | NotifyCompensationResult(curPlayer, GUID, 1)
|
| | | |
| | | #全服奖励领取记录变更为已领取
|
| | | if CompensationType == Entire_CompensationType:
|
| | | GameWorld.GetCompensationMgr().AddPlayerRec(curPlayerID, GUID, 10 + Yet_State)
|
| | | SetPrizeState(curPlayerID, GUID, Del_State, Read_State_Yes)
|
| | | return
|
| | | #个人奖励领取条目执行删除
|
| | | if CompensationType == Personal_CompensationType:
|
| | |
| | |
|
| | | mailText = curMail.Text
|
| | | # 通知类模板邮件,过天可直接删除
|
| | | if tempSign in mailText and tempSignEnd in mailText and CheckCanDelCompensation(curMail, curMail.GUID):
|
| | | if tempSign in mailText and tempSignEnd in mailText and CheckCanDelCompensation(curMail, curMail.GUID, curMail.PlayerID):
|
| | | tempKey = mailText[mailText.index(tempSign) + len(tempSign):mailText.index(tempSignEnd)]
|
| | | notClearMailKeyList = IpyGameDataPY.GetFuncEvalCfg("MailSet", 1)
|
| | | if tempKey not in notClearMailKeyList:
|
| | |
| | | #在个人补偿中
|
| | | curPersonalCompensation = GameWorld.GetCompensationMgr().FindPersonalCompensation(curPlayerID, GUID)
|
| | | if curPersonalCompensation.PlayerID == curPlayerID:
|
| | | if not CheckCanDelCompensation(curPersonalCompensation, GUID):
|
| | | if not CheckCanDelCompensation(curPersonalCompensation, GUID, curPlayerID):
|
| | | #有附件不可删除
|
| | | GameWorld.DebugLog("该个人邮件不可删除: %s" % GUID, curPlayerID)
|
| | | NotifyCompensationResult(curPlayer, GUID, 0)
|
| | | return
|
| | |
|
| | |
| | | #全服邮件
|
| | | curEntireRequire = GameWorld.GetCompensationMgr().FindEntireCompensation(GUID)
|
| | | if curEntireRequire.GUID == GUID:
|
| | | if not CheckCanDelCompensation(curEntireRequire, GUID):
|
| | | if not CheckCanDelCompensation(curEntireRequire, GUID, curPlayerID):
|
| | | #有附件不可删除
|
| | | GameWorld.DebugLog("该全服邮件不可删除: %s" % GUID, curPlayerID)
|
| | | NotifyCompensationResult(curPlayer, GUID, 0)
|
| | | return
|
| | |
|
| | | SetPrizeState(curPlayerID, GUID, Disable_State, GameWorld.GetCompensationMgr().FindPlayerRecState(curPlayerID, GUID)/10)
|
| | | SetPrizeState(curPlayerID, GUID, Del_State, GameWorld.GetCompensationMgr().FindPlayerRecState(curPlayerID, GUID)/10)
|
| | | NotifyCompensationResult(curPlayer, GUID, 1)
|
| | | #GameWorld.DebugLog("全服邮件OnDelCompensation:%s"%GUID)
|
| | | return
|
| | |
| | | NotifyCompensationResult(curPlayer, GUID, 0)
|
| | |
|
| | | # 有附件的情况玩家不可主动删除邮件,避免误操作;系统可删除不用调用此接口
|
| | | def CheckCanDelCompensation(mailObj, GUID):
|
| | | def CheckCanDelCompensation(mailObj, GUID, playerID=0):
|
| | | if playerID:
|
| | | if GetPrizeGetState(playerID, GUID) == Yet_State:
|
| | | #GameWorld.DebugLog("已领取的邮件可删除: %s" % GUID, playerID)
|
| | | return True
|
| | | |
| | | if mailObj.Gold or mailObj.GoldPaper or mailObj.Silver:
|
| | | # 有附加货币不可删除
|
| | | return False
|