From bd9dce2d66b5086712596b8dac6d9116be65bafd Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 11 十二月 2025 16:53:47 +0800
Subject: [PATCH] 129 【战斗】战斗系统-服务端(去除常规功能封包对象池使用;)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py | 178 +++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 113 insertions(+), 65 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py
index f38164d..19ffda5 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py
@@ -20,11 +20,12 @@
import ShareDefine
import NetPackCommon
import PlayerControl
+import OpenServerActivity
import ChPyNetSendPack
+import IPY_GameWorld
import ItemControler
import IpyGameDataPY
import PyGameData
-import ObjPool
#成就奖励是否已领取
def GetSuccHasGot(curPlayer, succID):
@@ -35,10 +36,10 @@
#成就完成进度
def GetSuccValue(curPlayer, succType, conds):
- condition = "" if not conds else str(conds).replace(" ", "")[1:-1]
+ condition = "" if not conds else str(list(conds)).replace(" ", "")[1:-1]
return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuccessValue % (succType, condition))
def SetSuccValue(curPlayer, succType, conds, value):
- condition = "" if not conds else str(conds).replace(" ", "")[1:-1]
+ condition = "" if not conds else str(list(conds)).replace(" ", "")[1:-1]
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_SuccessValue % (succType, condition), value)
return
@@ -47,72 +48,119 @@
SyncSuccessAwardRecord(curPlayer)
return
-def ResetSuccessByType(curPlayer, succType, ignoreFinish=True):
+def ResetSuccessByTypes(curPlayer, succTypeList, ignoreFinish=True, isNotify=True):
+ ## 重置成就
+ for succType in succTypeList:
+ ResetSuccessByType(curPlayer, succType, ignoreFinish, isNotify)
+ return
+
+def ResetSuccessByType(curPlayer, succType, ignoreFinish=True, isNotify=True):
#重置某类型成就进度,一般用于先重置次数再重新计数,或者活动类
ipyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("Success", succType)
if not ipyDataList:
return
+ succIDList = []
+ syncTypeCondList = []
for ipyData in ipyDataList:
succID = ipyData.GetSuccID()
if ignoreFinish and GetSuccHasGot(curPlayer, succID):
continue
conds = ipyData.GetCondition()
SetSuccValue(curPlayer, succType, conds, 0)
+ SetSuccHasGot(curPlayer, succID, 0)
+ succIDList.append(succID)
+ if [succType, conds] not in syncTypeCondList:
+ syncTypeCondList.append([succType, conds])
+ if isNotify:
+ succIDList and SyncSuccessAwardRecord(curPlayer, succIDList, True)
+ syncTypeCondList and SyncSuccessInfo(curPlayer, syncTypeCondList, True)
return
-#def UpdateSuccessProgressByConditions(curPlayer, successType, conditionCountDict):
-# ## 根据多种条件更新进度,如装备多品质的
-# ipyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("Success", successType)
-# if not ipyDataList:
-# return
-# updIDList = []
-# updsuccDataList = []
-# updConditionDict = {}
-#
-# for condition, newCount in conditionCountDict.items():
-# addCondList = [] # 不同的成就ID条件可能相同,只是最大进度不同,故传入的条件计数针对相同成就条件只能累加一次
-# for ipyData in ipyDataList:
-# succID = ipyData.GetSuccID()
-# conds = ipyData.GetCondition()
-# needCnt = ipyData.GetNeedCnt()
-#
-# tupleCond = tuple(conds) # 作为字典key用
-#
-# if tupleCond not in updConditionDict:
-# updConditionDict[tupleCond] = [conds, 0, 0] # [条件, 更新值, 最大进度值]
-# updInfo = updConditionDict[tupleCond]
-# if updInfo[2] < needCnt:
-# updInfo[2] = needCnt
-#
-# if not __CheckCanAddSuccess(curPlayer, ipyData, list(condition)):
-# continue
-#
-# if succID not in updIDList:
-# updIDList.append(succID)
-# updsuccDataList.append(ipyData)
-#
-# if tupleCond not in addCondList:
-# addCondList.append(tupleCond)
-# updConditionDict[tupleCond][1] = updConditionDict[tupleCond][1] + newCount # 更新进度值
-#
-# # 没有找到更新目标不处理
-# #GameWorld.DebugLog(" updConditionDict=%s" % updConditionDict)
-# #GameWorld.DebugLog(" updIDList=%s" % updIDList)
-# if not updIDList:
-# return
-#
-# # 先更新成就记录值后再判断完成与否
-# for cond, updCnt, maxCnt in updConditionDict.values():
-# if not updCnt:
-# continue
-# updCnt = min(maxCnt, updCnt)
-# if GetSuccValue(curPlayer, successType, cond) == updCnt:
-# continue
-# SetSuccValue(curPlayer, successType, cond, updCnt)
-# SyncSuccessInfo(curPlayer, syncTypeCondList)
-# return
+def UpdateEquipSuccess(curPlayer):
+ # 装备相关成就
+
+ colorCountDict = {}
+ equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
+ for equipPlace in ChConfig.Def_MainEquipPlaces:
+ equipIndex = equipPlace - 1
+ if equipIndex < 0 or equipIndex >= equipPack.GetCount():
+ continue
+ curEquip = equipPack.GetAt(equipIndex)
+ if not curEquip or curEquip.IsEmpty():
+ continue
+ itemColor = curEquip.GetItemColor()
+ condKey = (itemColor, )
+ colorCountDict[condKey] = colorCountDict.get(condKey, 0) + 1
+
+ UpdateSuccessProgressByConditions(curPlayer, ShareDefine.SuccType_OSAEquipColor, colorCountDict)
+ return
+
+def UpdateSuccessProgressByConditions(curPlayer, successType, conditionCountDict):
+ ## 根据多种条件更新进度,如装备多品质的
+ # @param conditionCountDict: 条件对应件数,条件需用元组为key {(c, ...):cnt, ..}
+ if successType in ShareDefine.OSASuccTypeList:
+ if OpenServerActivity.GetOSACelebrationState(curPlayer) > 1:
+ return
+ ipyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("Success", successType)
+ if not ipyDataList:
+ return
+
+ updIDList = []
+ updsuccDataList = []
+ updConditionDict = {}
+
+ for condition, newCount in conditionCountDict.items():
+ addCondList = [] # 不同的成就ID条件可能相同,只是最大进度不同,故传入的条件计数针对相同成就条件只能累加一次
+ for ipyData in ipyDataList:
+ succID = ipyData.GetSuccID()
+ conds = ipyData.GetCondition()
+ needCnt = ipyData.GetNeedCnt()
+
+ tupleCond = tuple(conds) # 作为字典key用
+
+ if tupleCond not in updConditionDict:
+ updConditionDict[tupleCond] = [conds, 0, 0] # [条件, 更新值, 最大进度值]
+ updInfo = updConditionDict[tupleCond]
+ if updInfo[2] < needCnt:
+ updInfo[2] = needCnt
+
+ if not __CheckCanAddSuccess(curPlayer, ipyData, list(condition)):
+ continue
+
+ if succID not in updIDList:
+ updIDList.append(succID)
+ updsuccDataList.append(ipyData)
+
+ if tupleCond not in addCondList:
+ addCondList.append(tupleCond)
+ updConditionDict[tupleCond][1] = updConditionDict[tupleCond][1] + newCount # 更新进度值
+
+ # 没有找到更新目标不处理
+ #GameWorld.DebugLog(" conditionCountDict=%s" % conditionCountDict)
+ #GameWorld.DebugLog(" updConditionDict=%s" % updConditionDict)
+ #GameWorld.DebugLog(" updIDList=%s" % updIDList)
+ if not updIDList:
+ return
+
+ # 先更新成就记录值后再判断完成与否
+ syncTypeCondList = []
+ for conds, updCnt, maxCnt in updConditionDict.values():
+ if not updCnt:
+ continue
+ updCnt = min(maxCnt, updCnt)
+ if GetSuccValue(curPlayer, successType, conds) == updCnt:
+ continue
+ SetSuccValue(curPlayer, successType, conds, updCnt)
+ if [successType, conds] not in syncTypeCondList:
+ syncTypeCondList.append([successType, conds])
+ #GameWorld.DebugLog(" syncTypeCondList=%s" % syncTypeCondList)
+ syncTypeCondList and SyncSuccessInfo(curPlayer, syncTypeCondList, True)
+ return
def UptateSuccessProgress(curPlayer, successType, newCnt, condition=[]):
+ if successType in ShareDefine.OSASuccTypeList:
+ if OpenServerActivity.GetOSACelebrationState(curPlayer) > 1:
+ return
ipyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("Success", successType)
if not ipyDataList:
return
@@ -226,7 +274,9 @@
return
if successType not in ShareDefine.SuccessTypeList:
return
-
+ if successType in ShareDefine.OSASuccTypeList:
+ if OpenServerActivity.GetOSACelebrationState(curPlayer) > 1:
+ return
ipyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("Success", successType)
if not ipyDataList:
GameWorld.DebugLog("找不到成就数据successType=%s" % successType)
@@ -274,7 +324,7 @@
needCnt = ipyData.GetNeedCnt()
curValue = GetSuccValue(curPlayer, succType, conds)
if curValue < needCnt:
- GameWorld.DebugLog("该成就未完成! succID=%s,curValue=%s < %s" % (succID, curValue, needCnt))
+ GameWorld.DebugLog("该成就未完成! succID=%s,succType=%s,conds=%s,curValue=%s < %s" % (succID, succType, conds, curValue, needCnt))
return
SetSuccHasGot(curPlayer, succID)
@@ -292,8 +342,8 @@
for index in range(ipyDataMgr.GetSuccessCount()):
ipyData = ipyDataMgr.GetSuccessByIndex(index)
# 已领取的不发
- if GetSuccHasGot(curPlayer, ipyData.GetSuccID()):
- continue
+ #if GetSuccHasGot(curPlayer, ipyData.GetSuccID()):
+ # continue
succType = ipyData.GetSuccType()
conds = ipyData.GetCondition()
tcList = [succType, conds]
@@ -302,13 +352,12 @@
syncTypeCondList.append(tcList)
successInfoList = []
- objPoolMgr = ObjPool.GetPoolMgr()
for succType, conds in syncTypeCondList:
curValue = GetSuccValue(curPlayer, succType, conds)
# 不发送为0的数据
if not isSendZero and curValue <= 0:
continue
- succInfo = objPoolMgr.acquire(ChPyNetSendPack.tagSCSuccessInfo)
+ succInfo = ChPyNetSendPack.tagSCSuccessInfo()
succInfo.SuccType = succType
succInfo.Conds = conds
succInfo.CLen = len(succInfo.Conds)
@@ -318,7 +367,7 @@
if not successInfoList:
return
- clientPack = objPoolMgr.acquire(ChPyNetSendPack.tagSCSuccessInfoList)
+ clientPack = ChPyNetSendPack.tagSCSuccessInfoList()
clientPack.SuccessInfoList = successInfoList
clientPack.Count = len(clientPack.SuccessInfoList)
NetPackCommon.SendFakePack(curPlayer, clientPack)
@@ -340,13 +389,12 @@
maxSuccID = ipyDataMgr.GetSuccessByIndex(succCnt - 1).GetSuccID()
recordIndexList = xrange(maxSuccID / 31 + 1)
- objPoolMgr = ObjPool.GetPoolMgr()
recordList = []
for i in recordIndexList:
awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_SuccessAward % i)
if not isSyncZero and not awardRecord:
continue
- recordInfo = objPoolMgr.acquire(ChPyNetSendPack.tagSCSuccessAwardRecord)
+ recordInfo = ChPyNetSendPack.tagSCSuccessAwardRecord()
recordInfo.RecordIndex = i
recordInfo.Record = awardRecord
recordList.append(recordInfo)
@@ -354,7 +402,7 @@
if not recordList:
return
- clientPack = objPoolMgr.acquire(ChPyNetSendPack.tagSCSuccessAwardRecordList)
+ clientPack = ChPyNetSendPack.tagSCSuccessAwardRecordList()
clientPack.RecordList = recordList
clientPack.RecordCnt = len(clientPack.RecordList)
NetPackCommon.SendFakePack(curPlayer, clientPack)
--
Gitblit v1.8.0