From 40f2e314ff6df3d45e643419c6f155bb665b78dc Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期六, 14 九月 2024 13:34:19 +0800
Subject: [PATCH] 10249 【越南】【砍树】【英文】仙宫(增加获得气运提示;)
---
ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py | 125 +++++++++++++++++++++++++++++------------
1 files changed, 89 insertions(+), 36 deletions(-)
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py
index ae36d67..a7b31dd 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/Player/PlayerCompensation.py
@@ -43,13 +43,14 @@
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 # 未审核
@@ -412,7 +413,7 @@
# @return GUID
# @remarks addItemList支持append字典
def SendPersonalItemMail(title, content, limitTime, playerIDList, addItemList, gold = 0, goldPaper = 0, silver = 0,
- detail="", moneySource=ChConfig.Def_GiveMoney_Mail, crossMail=False):
+ detail="", moneySource=ChConfig.Def_GiveMoney_Mail, crossMail=False, mailType=0):
if not playerIDList:
return ""
@@ -442,20 +443,24 @@
startIndex = i*perMailItemCnt
GUID = str(uuid.uuid1())
AddPersonalItem(GUID, addItemDictList[startIndex:startIndex + perMailItemCnt], playerIDList,
- limitTime, "%s<$_$>%s<$_$>%s" % (ChConfig.Def_Mail_SenderSys, title, content),
+ limitTime, GetMailText(title, content, mailType),
gold, goldPaper, silver, detail, moneySource, crossMail)
return GUID
## 发送纯文字个人补偿
# @param limitTime 可以传空
# @return None
-def SendPersonalAsTextMail(PlayerID, title, content, limitTime):
+def SendPersonalAsTextMail(PlayerID, title, content, limitTime, mailType=0):
if GameWorld.IsCrossServer():
return
GUID = str(uuid.uuid1())
PyAddPersonalCompensation(GUID, PlayerID, GameWorld.GetCurrentDataTimeStr(), limitTime,
- "%s<$_$>%s<$_$>%s" % (ChConfig.Def_Mail_SenderSys,title, content))
+ GetMailText(title, content, mailType))
return
+
+def GetMailText(title, content, mailType=0, sender=ChConfig.Def_Mail_SenderSys):
+ ## 获取邮件字段 Text 内容
+ return "%s<$_$>%s<$_$>%s<$_$>%s" % (sender, title, content, mailType)
def GetEntireCompensationInfo(checkState, limitLVType, limitLV):
return checkState * 1000000 + limitLVType * 100000 + limitLV
@@ -480,9 +485,10 @@
compensation = compensationMgr.PersonalCompensationAt(playerID, i)
contentList = compensation.Text.split("<$_$>")
- if len(contentList) != 3:
+ if len(contentList) < 3:
continue
- sender, title, content = contentList
+ sender, title, content = contentList[:3]
+ mailType = GameWorld.ToIntDef(contentList[3]) if len(contentList) > 3 else 0
if tempSign in content and tempSignEnd in content:
title = content[content.index(tempSign) + len(tempSign):content.index(tempSignEnd)]
@@ -501,7 +507,7 @@
recState = compensationMgr.FindPlayerRecState(playerID, GUID)
infoDict = {"GUID":GUID, "Gold":compensation.Gold, "GoldPaper":compensation.GoldPaper, "Silver":compensation.Silver,
- "Sender":sender, "Title":title, "Content":content, "RecState":recState,
+ "Sender":sender, "Title":title, "Content":content, "RecState":recState, "MailType":mailType,
"CreateTime":compensation.CreateTime, "LimitTime":compensation.LimitTime, "ItemList":itemList}
retList.append(infoDict)
@@ -550,9 +556,10 @@
return
contentList = compensation.Text.split("<$_$>")
- if len(contentList) != 3:
+ if len(contentList) < 3:
return
- sender, title, content = contentList
+ sender, title, content = contentList[:3]
+ mailType = GameWorld.ToIntDef(contentList[3]) if len(contentList) > 3 else 0
if searchTitle and searchTitle not in title:
return
@@ -574,7 +581,7 @@
continue
itemList.append([itemID, curItem.Count, curItem.IsBind, curItem.UserData])
- compensationDict = {"GUID":GUID, "CheckState":checkState, "LimitLVType":limitLVType, "LimitLV":limitLV,
+ compensationDict = {"GUID":GUID, "CheckState":checkState, "LimitLVType":limitLVType, "LimitLV":limitLV, "MailType":mailType,
"Gold":compensation.Gold, "GoldPaper":compensation.GoldPaper, "Silver":compensation.Silver,
"PlayerJob":compensation.PlayerJob, "Sender":sender, "Title":title, "Content":content, "OnlyServerID":compensation.ServerID,
"CreateTime":compensation.CreateTime, "LimitTime":compensation.LimitTime, "ItemList":itemList}
@@ -639,7 +646,7 @@
return successGUIDList
def SendEntireMail(mailTypeKey, getDays, limitLV, limitLVType, addItemList=[], paramList=[], \
- gold=0, goldPaper=0, silver=0, detail="", moneySource=ChConfig.Def_GiveMoney_Mail, GUID=""):
+ gold=0, goldPaper=0, silver=0, detail="", moneySource=ChConfig.Def_GiveMoney_Mail, GUID="", mailType=0):
''' 发送全服邮件
@param mailTypeKey: 邮件模板key
@param getDays: 有效天数
@@ -675,7 +682,7 @@
PlayerJob = 127 # 默认全职业可领
serverID = 0 # 默认所有服务器ID
- AddEntireItem(GUID, addItemDictList, limitTime, mailInfo, PlayerJob, "%s<$_$>%s<$_$>%s" % (sender, title, content),
+ AddEntireItem(GUID, addItemDictList, limitTime, mailInfo, PlayerJob, GetMailText(title, content, mailType, sender),
gold, goldPaper, silver, detail, serverID)
return
@@ -950,6 +957,11 @@
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
@@ -986,9 +998,9 @@
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)
@@ -997,6 +1009,11 @@
SetPrizeState(curPlayerID, curRequire.GUID, Disable_State, readState)
continue
+ if limitLVType == LimitLVType_Not and curPlayer.GetCreateRoleTime() > curRequire.CreateTime:
+ #GameWorld.DebugLog("升级后不可领取的邮件发送时间后创角的玩家默认不可领取! CreateRoleTime=%s > %s" % (curPlayer.GetCreateRoleTime(), curRequire.CreateTime))
+ SetPrizeState(curPlayerID, curRequire.GUID, Disable_State, readState)
+ continue
+
if limitLV > curLV:
#等级不足
if limitLVType == LimitLVType_Not:
@@ -1015,7 +1032,7 @@
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))
@@ -1038,7 +1055,11 @@
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()
@@ -1052,6 +1073,24 @@
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
@@ -1074,7 +1113,7 @@
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")
@@ -1097,6 +1136,15 @@
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)
@@ -1106,13 +1154,6 @@
#---------
#在全服补偿中
- 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:
#不再全服补偿中,删除记录
@@ -1219,15 +1260,20 @@
##玩家领取补偿物品发放成功
# @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:
@@ -1278,7 +1324,7 @@
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:
@@ -1362,8 +1408,9 @@
#在个人补偿中
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
@@ -1382,12 +1429,13 @@
#全服邮件
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
@@ -1395,7 +1443,12 @@
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
--
Gitblit v1.8.0