From ba9ac7c41060991bf34d8cad6db8f255561b712c Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 27 九月 2018 18:45:42 +0800
Subject: [PATCH] 3906 【后端】新增宝箱开启规则次数特定定制产出; 增加GM命令重置宝箱开启次数: SetChestsUseCount
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/Item_Chests.py | 48 ++++++++++++++--
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetChestsUseCount.py | 73 ++++++++++++++++++++++++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py | 3 +
PySysDB/PySysDBPY.h | 1
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py | 2
5 files changed, 121 insertions(+), 6 deletions(-)
diff --git a/PySysDB/PySysDBPY.h b/PySysDB/PySysDBPY.h
index 75d16ee..a4f34ce 100644
--- a/PySysDB/PySysDBPY.h
+++ b/PySysDB/PySysDBPY.h
@@ -982,6 +982,7 @@
list RandTimeList1; //随机次数饼图列表1
list RandItemList2; //随机物品饼图列表2
list RandTimeList2; //随机次数饼图列表2
+ dict RandItemByUseCount; //宝箱开启X次对应特殊产出,与饼图列表2互斥
list JobItemList; //职业物品列表
BYTE MoneyType; //货币类型
DWORD MoneyCount; //货币数量
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index 3f66de6..e05a9b9 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -3498,6 +3498,8 @@
Def_PDict_DownloadAwardState = "DownloadAwardState" # 分支下载奖励状态 0-未领 1-已领
+Def_PDict_ChestsOpenCount = "ChestsOpenCount_%s" # 宝箱已开启次数, 参数(宝箱ID), 只有有开启次数额外奖励的才会记录
+
# 跑环
Def_PDict_RunTaskAwardState = "RunTaskAwardState_%s" # 是否已领取跑环本轮结束奖励 参数任务类型
Def_PDict_RunTaskAwardRecord = "RunTaskAwardRecord_%s" # 跑环本轮结束奖励记录 参数任务类型
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetChestsUseCount.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetChestsUseCount.py
new file mode 100644
index 0000000..4400f24
--- /dev/null
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/SetChestsUseCount.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+# -*- coding: GBK -*-
+#-------------------------------------------------------------------------------
+#
+##@package GM.Commands.SetChestsUseCount
+#
+# @todo:设置宝箱开启次数
+# @author hxp
+# @date 2018-09-27
+# @version 1.0
+#
+# 详细描述: 设置宝箱开启次数
+#
+#-------------------------------------------------------------------------------
+#"""Version = 2018-09-27 19:00"""
+#-------------------------------------------------------------------------------
+
+import PlayerControl
+import IpyGameDataPY
+import GameWorld
+import ChConfig
+
+#---------------------------------------------------------------------
+#逻辑实现
+
+## GM命令执行入口
+# @param curPlayer 当前玩家
+# @param msgList 参数列表
+# @return None
+# @remarks 函数详细说明.
+def OnExec(curPlayer, msgList):
+ if not msgList:
+ GameWorld.DebugAnswer(curPlayer, "SetChestsUseCount 宝箱ID 次数")
+ GameWorld.DebugAnswer(curPlayer, "重置所有: SetChestsUseCount 0")
+ return
+
+ if len(msgList) == 1 and not msgList[0]:
+ resetIDList = []
+ ipyDataMgr = IpyGameDataPY.IPY_Data()
+ for i in xrange(ipyDataMgr.GetChestsAwardCount()):
+ ipyData = ipyDataMgr.GetChestsAwardByIndex(i)
+ chestsItemID = ipyData.GetChestsItemID()
+ if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ChestsOpenCount % chestsItemID):
+ continue
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChestsOpenCount % chestsItemID, 0)
+ resetIDList.append(chestsItemID)
+
+ GameWorld.DebugAnswer(curPlayer, "重置OK: %s" % resetIDList)
+ return
+
+ isNeedRecord = False
+ chestsItemID = msgList[0]
+ awardIpyDataList = IpyGameDataPY.GetIpyGameDataList("ChestsAward", chestsItemID)
+ if not awardIpyDataList:
+ GameWorld.DebugAnswer(curPlayer, "没有该宝箱产出配置:%s" % chestsItemID)
+ return
+
+ for ipyData in awardIpyDataList:
+ if ipyData.GetRandItemByUseCount():
+ isNeedRecord = True
+ break
+
+ if not isNeedRecord:
+ GameWorld.DebugAnswer(curPlayer, "没有配置开启次数特殊产出:%s" % chestsItemID)
+ return
+
+ useCount = msgList[1] if len(msgList) > 1 else 0
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChestsOpenCount % chestsItemID, useCount)
+ GameWorld.DebugAnswer(curPlayer, "设置宝箱开启次数(%s)=%s" % (chestsItemID, useCount))
+ return
+
+
+
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
index cd11c50..5e1a31c 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
@@ -797,6 +797,7 @@
("list", "RandTimeList1", 0),
("list", "RandItemList2", 0),
("list", "RandTimeList2", 0),
+ ("dict", "RandItemByUseCount", 0),
("list", "JobItemList", 0),
("BYTE", "MoneyType", 0),
("DWORD", "MoneyCount", 0),
@@ -2607,6 +2608,7 @@
self.RandTimeList1 = []
self.RandItemList2 = []
self.RandTimeList2 = []
+ self.RandItemByUseCount = {}
self.JobItemList = []
self.MoneyType = 0
self.MoneyCount = 0
@@ -2621,6 +2623,7 @@
def GetRandTimeList1(self): return self.RandTimeList1 # 随机次数饼图列表1
def GetRandItemList2(self): return self.RandItemList2 # 随机物品饼图列表2
def GetRandTimeList2(self): return self.RandTimeList2 # 随机次数饼图列表2
+ def GetRandItemByUseCount(self): return self.RandItemByUseCount # 宝箱开启X次对应特殊产出,与饼图列表2互斥
def GetJobItemList(self): return self.JobItemList # 职业物品列表
def GetMoneyType(self): return self.MoneyType # 货币类型
def GetMoneyCount(self): return self.MoneyCount # 货币数量
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/Item_Chests.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/Item_Chests.py
index d6572d0..9802a91 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/Item_Chests.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Item/UseItem/Item_Chests.py
@@ -62,9 +62,9 @@
awardInfo = GetChestsAwardInfo(curPlayer, chestsItemID, useCnt, exData)
if not awardInfo:
return
- needSpaceDict, jobAwardItemDict, moneyType, moneyCount, notifyItemList = awardInfo
- GameWorld.DebugLog(" needSpaceDict=%s,jobAwardItemDict=%s,moneyType=%s,moneyCount=%s,notifyItemList=%s"
- % (needSpaceDict, jobAwardItemDict, moneyType, moneyCount, notifyItemList))
+ needSpaceDict, jobAwardItemDict, moneyType, moneyCount, notifyItemList, updOpenCount = awardInfo
+ GameWorld.DebugLog(" needSpaceDict=%s,jobAwardItemDict=%s,moneyType=%s,moneyCount=%s,notifyItemList=%s,updOpenCount=%s"
+ % (needSpaceDict, jobAwardItemDict, moneyType, moneyCount, notifyItemList, updOpenCount))
for packType, needSpace in needSpaceDict.items():
packSpace = ItemCommon.GetItemPackSpace(curPlayer, packType, needSpace)
@@ -79,6 +79,11 @@
if costGoldTotal:
infoDict = {ChConfig.Def_Cost_Reason_SonKey:chestsItemID}
PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGoldTotal, ChConfig.Def_Cost_UseItem, infoDict)
+
+ # 更新开启次数
+ if updOpenCount:
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_ChestsOpenCount % chestsItemID, updOpenCount)
+ GameWorld.DebugLog(" 更新宝箱开启次数: %s" % updOpenCount)
saveDataDict = {"AwardItem":jobAwardItemDict}
ItemCommon.DelItem(curPlayer, curRoleItem, useCnt, True, ChConfig.ItemDel_Chests, saveDataDict)
@@ -157,9 +162,40 @@
if not __AddChestsRandAwardItem(curPlayer, chestsItemID, useCount, awardItemDict, awardIpyData.GetRandItemList1(), awardIpyData.GetRandTimeList1()):
return
+ # 根据宝箱开启次数特殊产出
+ updOpenCount = 0
+ randItemList2DoCount = useCount
+ randItemByUseCountDict = awardIpyData.GetRandItemByUseCount()
+ if randItemByUseCountDict:
+ maxOpenCount = max(randItemByUseCountDict)
+ hisOpenCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_ChestsOpenCount % chestsItemID)
+ if hisOpenCount < maxOpenCount:
+ updOpenCount = min(hisOpenCount + useCount, maxOpenCount)
+ for specUseCount, randItemList in randItemByUseCountDict.items():
+ if not (hisOpenCount < specUseCount <= updOpenCount):
+ GameWorld.DebugLog(" 不满足特殊次数产出: hisOpenCount=%s,specUseCount=%s,updOpenCount=%s"
+ % (hisOpenCount, specUseCount, updOpenCount))
+ continue
+ randItemList2DoCount -= 1
+ randItemInfo = GameWorld.GetResultByRandomList(randItemList)
+ GameWorld.DebugLog(" 根据开启次数特殊产出: specUseCount=%s, %s, randItemList2DoCount=%s"
+ % (specUseCount, randItemInfo, randItemList2DoCount))
+ if not randItemInfo:
+ continue
+ if len(randItemInfo) != 2:
+ GameWorld.ErrLog("宝箱开启次数特殊产出随机库配置错误!chestsItemID=%s" % chestsItemID)
+ return
+ itemID, itemCount = randItemInfo
+ if not itemID:
+ continue
+ __AddAwardItem(awardItemDict, itemID, itemCount)
+
+ if randItemList2DoCount != useCount:
+ GameWorld.DebugLog(" 随机物品库2执行次数: %s" % (randItemList2DoCount))
+
# 随机物品库2
- if awardIpyData.GetRandItemList2() and awardIpyData.GetRandTimeList2():
- if not __AddChestsRandAwardItem(curPlayer, chestsItemID, useCount, awardItemDict, awardIpyData.GetRandItemList2(), awardIpyData.GetRandTimeList2()):
+ if awardIpyData.GetRandItemList2() and awardIpyData.GetRandTimeList2() and randItemList2DoCount:
+ if not __AddChestsRandAwardItem(curPlayer, chestsItemID, randItemList2DoCount, awardItemDict, awardIpyData.GetRandItemList2(), awardIpyData.GetRandTimeList2()):
return
# 产出特殊物品广播
@@ -185,7 +221,7 @@
if itemID in needNotifyItemList or jobItemID in needNotifyItemList:
notifyItemList.append(jobItemID)
- return needSpaceDict, jobAwardItemDict, awardIpyData.GetMoneyType(), awardIpyData.GetMoneyCount() * useCount, notifyItemList
+ return needSpaceDict, jobAwardItemDict, awardIpyData.GetMoneyType(), awardIpyData.GetMoneyCount() * useCount, notifyItemList, updOpenCount
def __GetMaxRandTime(randTimeList):
if len(randTimeList) == 1 and type(randTimeList[0]) == int:
--
Gitblit v1.8.0