From e189acf934e55670b1050428848f039e7154be9a Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期三, 17 十二月 2025 09:43:06 +0800
Subject: [PATCH] 121 【武将】武将系统-服务端(心愿物品选择支持取消操作;)
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTreasure.py | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTreasure.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTreasure.py
index 0a70f09..0d0d6e2 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTreasure.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTreasure.py
@@ -186,11 +186,12 @@
GameWorld.DebugLog("需要激活本体的武将未激活不可选择!itemID=%s" % itemID)
return
+ GameWorld.DebugLog("重选心愿库对应ID汇总: %s" % selectLibItemDict)
hisOutDict = {} # 历史选择已产出过的心愿物品记录 {wishID:outCnt, ...}
for libIDStr, wishCnt in wishLibSelect.items():
libID = int(libIDStr)
selectLibWishIDList = selectLibItemDict.get(libID, [])
- if len(selectLibWishIDList) != wishCnt:
+ if selectLibWishIDList and len(selectLibWishIDList) != wishCnt:
GameWorld.DebugLog("选择心愿库的物品数量与设定的心愿物品数量不一致!libID=%s,wishCnt=%s,selectCnt=%s,%s"
% (libID, wishCnt, len(selectLibWishIDList), selectLibWishIDList))
return
@@ -203,10 +204,14 @@
GameWorld.DebugLogEx("已经产出过的心愿物品不可从选择中去除! outCnt=%s,wishID=%s not in %s", outCnt, wishID, selectLibWishIDList)
return
hisOutDict[wishID] = outCnt
+ GameWorld.DebugLog("历史已产出心愿ID次数: %s" % hisOutDict)
# 验证通过,保存
- for libID, wishIDList in selectLibItemDict.items():
- for wishIndex, wishID in enumerate(wishIDList):
+ for libIDStr, wishCnt in wishLibSelect.items():
+ libID = int(libIDStr)
+ wishIDList = selectLibItemDict.get(libID, [])
+ for wishIndex in range(wishCnt):
+ wishID = wishIDList[wishIndex] if len(wishIDList) > wishIndex else 0
outCnt = hisOutDict.get(wishID, 0)
SetWishInfo(curPlayer, treasureType, libID, wishIndex, wishID, outCnt)
GameWorld.DebugLog("保存心愿选择: libID=%s,wishIndex=%s,wishID=%s,outCnt=%s" % (libID, wishIndex, wishID, outCnt))
@@ -387,19 +392,15 @@
gridLibInfoDict = ipyData.GetGridLibInfo() # 格子编号对应库ID {"编号":物品库ID, ...}
# 心愿
- wishSelectState = False # 心愿物品是否已选择
canOutWishDict = {} # 还可产出的心愿物品 {libID:{wishID:[wishIndex, canOut], ...}, ...}
wishOutputRule = setIpyData.GetWishOutput() # 心愿产出规则:心愿产出完毕后: 0 - 可继续产出该库物品; 1 - 不可再产出该库物品
wishLibSelect = setIpyData.GetWishLibSelect()
for libIDStr, selectCnt in wishLibSelect.items():
libID = int(libIDStr)
- if libID not in canOutWishDict:
- canOutWishDict[libID] = {}
for wishIndex in range(selectCnt):
wishID, outCnt = GetWishInfo(curPlayer, treasureType, libID, wishIndex)
if not wishID:
continue
- wishSelectState = True
libItemIpyData = IpyGameDataPY.GetIpyGameDataByCondition("TreasureItemLib", {"ID":wishID}, False)
if not libItemIpyData:
continue
@@ -407,17 +408,19 @@
if not outCntLimit:
# 非心愿物品
continue
+ if libID not in canOutWishDict:
+ canOutWishDict[libID] = {}
if outCnt >= outCntLimit:
# 该心愿物品产出次数已用完
continue
libWishCanOutDict = canOutWishDict[libID]
canOut = outCntLimit - outCnt
libWishCanOutDict[wishID] = [wishIndex, canOut]
- if canOutWishDict:
- if not wishSelectState:
+ if wishLibSelect:
+ if not canOutWishDict:
GameWorld.DebugLog("心愿物品还未选择!", playerID)
else:
- GameWorld.DebugLog("还可产出的心愿库对应WishID还可产出次数: %s" % canOutWishDict, playerID)
+ GameWorld.DebugLog("已选的还可产出的心愿库对应WishID还可产出次数: %s" % canOutWishDict, playerID)
# 单抽产出优先级: 幸运物品 > 必出 > 保底 > 普通
# 连抽没有优先级限制,只要满足条件即可产出
--
Gitblit v1.8.0