From 4263dbe6adb69acd0c6814f647d9cbdbc6a61e00 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期四, 13 六月 2024 16:13:56 +0800
Subject: [PATCH] 10178 【越南】【香港】【主干】挂机奖励(集字活动、垃圾分类活动支持掉落活动物品; 终身卡免费领取快速挂机收益;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActGarbageSorting.py |   63 +++++++++++++++
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGuaji.py             |   38 ++++++++-
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py                |    8 +-
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py                  |    6 +
 PySysDB/PySysDBPY.h                                                                                   |    1 
 ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py                                     |    8 +-
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py                       |    2 
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActCollectWords.py   |   68 +++++++++++++++++
 8 files changed, 180 insertions(+), 14 deletions(-)

diff --git a/PySysDB/PySysDBPY.h b/PySysDB/PySysDBPY.h
index 50a7ad4..c533973 100644
--- a/PySysDB/PySysDBPY.h
+++ b/PySysDB/PySysDBPY.h
@@ -1799,6 +1799,7 @@
 	BYTE		LastDayOnlyExchange;	//最后一天是否仅兑换
 	WORD		TemplateID;	//兑换模板编号
 	WORD		DropDiffLVLimit;	//掉落等级差值限制
+	list		GuajiAwardSet;	//挂机收益设置,x秒|x次小怪掉率
 	list		DropItemRateList;	//小怪掉落饼图概率
 	list		DropItemRateListBoss;	//Boss掉落饼图概率
 };
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
index 2e703fc..eb80339 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -45196,7 +45196,7 @@
     ExpPoint = 0    #(DWORD ExpPoint)// 已累计经验,整除亿部分
     MoneyInfoLen = 0    #(BYTE MoneyInfoLen)
     MoneyInfo = ""    #(String MoneyInfo)// 已累计货币 [[货币类型, 货币值], ...]
-    ItemInfoLen = 0    #(BYTE ItemInfoLen)
+    ItemInfoLen = 0    #(WORD ItemInfoLen)
     ItemInfo = ""    #(String ItemInfo)// 已累计物品 [[物品ID, 个数], ...]
     data = None
 
@@ -45216,7 +45216,7 @@
         self.ExpPoint,_pos = CommFunc.ReadDWORD(_lpData, _pos)
         self.MoneyInfoLen,_pos = CommFunc.ReadBYTE(_lpData, _pos)
         self.MoneyInfo,_pos = CommFunc.ReadString(_lpData, _pos,self.MoneyInfoLen)
-        self.ItemInfoLen,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+        self.ItemInfoLen,_pos = CommFunc.ReadWORD(_lpData, _pos)
         self.ItemInfo,_pos = CommFunc.ReadString(_lpData, _pos,self.ItemInfoLen)
         return _pos
 
@@ -45246,7 +45246,7 @@
         length += 4
         length += 1
         length += len(self.MoneyInfo)
-        length += 1
+        length += 2
         length += len(self.ItemInfo)
 
         return length
@@ -45261,7 +45261,7 @@
         data = CommFunc.WriteDWORD(data, self.ExpPoint)
         data = CommFunc.WriteBYTE(data, self.MoneyInfoLen)
         data = CommFunc.WriteString(data, self.MoneyInfoLen, self.MoneyInfo)
-        data = CommFunc.WriteBYTE(data, self.ItemInfoLen)
+        data = CommFunc.WriteWORD(data, self.ItemInfoLen)
         data = CommFunc.WriteString(data, self.ItemInfoLen, self.ItemInfo)
         return data
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index 663a9da..dd4571a 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -3958,6 +3958,7 @@
 #集字活动
 Def_PDict_CollectWordsID = "CollectWordsID_%s"  # 玩家身上的活动ID,唯一标识,取活动开始日期time值,参数(活动编号 1 或  2)
 Def_PDict_CollectWordsExchangeCount = "CollectWordsCount_%s_%s"  # 兑换编号对应已兑换次数,参数(活动编号, 兑换编号)
+Def_PDict_CollectWordsGJSeconds = "CollectWordsGJSeconds_%s"  # 挂机未处理收益的秒数,参数(活动编号)
 
 #BOSS复活
 Def_PDict_BossRebornID = "BossRebornID"  # 玩家身上的BOSS复活活动ID,唯一标识,取活动开始日期time值
@@ -4105,6 +4106,7 @@
 Def_PDict_GarbageTaskValue = "ActGSTaskValue_%s_%s" # 任务总进度值,参数(活动编号, 任务ID)
 Def_PDict_GarbageTaskFinishCount = "ActGSTaskFinishCount_%s_%s" # 任务已完成次数,参数(活动编号, 任务ID)
 Def_PDict_GarbageEnvironmentValue = "ActGSEnvValue_%s" # 活动累计获得环保值,参数(活动编号)
+Def_PDict_GarbageGJSeconds = "ActGSGJSeconds_%s"  # 挂机未处理收益的秒数,参数(活动编号)
 
 #仙匣秘境活动
 Def_PDict_XianXiaMJID = "ActXXMJID_%s"  # 玩家身上的活动ID,唯一标识,取活动开始日期time值,参数:(活动编号)
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
index 2e703fc..eb80339 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -45196,7 +45196,7 @@
     ExpPoint = 0    #(DWORD ExpPoint)// 已累计经验,整除亿部分
     MoneyInfoLen = 0    #(BYTE MoneyInfoLen)
     MoneyInfo = ""    #(String MoneyInfo)// 已累计货币 [[货币类型, 货币值], ...]
-    ItemInfoLen = 0    #(BYTE ItemInfoLen)
+    ItemInfoLen = 0    #(WORD ItemInfoLen)
     ItemInfo = ""    #(String ItemInfo)// 已累计物品 [[物品ID, 个数], ...]
     data = None
 
@@ -45216,7 +45216,7 @@
         self.ExpPoint,_pos = CommFunc.ReadDWORD(_lpData, _pos)
         self.MoneyInfoLen,_pos = CommFunc.ReadBYTE(_lpData, _pos)
         self.MoneyInfo,_pos = CommFunc.ReadString(_lpData, _pos,self.MoneyInfoLen)
-        self.ItemInfoLen,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+        self.ItemInfoLen,_pos = CommFunc.ReadWORD(_lpData, _pos)
         self.ItemInfo,_pos = CommFunc.ReadString(_lpData, _pos,self.ItemInfoLen)
         return _pos
 
@@ -45246,7 +45246,7 @@
         length += 4
         length += 1
         length += len(self.MoneyInfo)
-        length += 1
+        length += 2
         length += len(self.ItemInfo)
 
         return length
@@ -45261,7 +45261,7 @@
         data = CommFunc.WriteDWORD(data, self.ExpPoint)
         data = CommFunc.WriteBYTE(data, self.MoneyInfoLen)
         data = CommFunc.WriteString(data, self.MoneyInfoLen, self.MoneyInfo)
-        data = CommFunc.WriteBYTE(data, self.ItemInfoLen)
+        data = CommFunc.WriteWORD(data, self.ItemInfoLen)
         data = CommFunc.WriteString(data, self.ItemInfoLen, self.ItemInfo)
         return data
 
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
index 3800279..e26552f 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
@@ -1440,6 +1440,7 @@
                         ("BYTE", "LastDayOnlyExchange", 0),
                         ("WORD", "TemplateID", 0),
                         ("WORD", "DropDiffLVLimit", 0),
+                        ("list", "GuajiAwardSet", 0),
                         ("list", "DropItemRateList", 0),
                         ("list", "DropItemRateListBoss", 0),
                         ),
@@ -4383,8 +4384,9 @@
     def GetLastDayOnlyExchange(self): return self.attrTuple[4] # 最后一天是否仅兑换 BYTE
     def GetTemplateID(self): return self.attrTuple[5] # 兑换模板编号 WORD
     def GetDropDiffLVLimit(self): return self.attrTuple[6] # 掉落等级差值限制 WORD
-    def GetDropItemRateList(self): return self.attrTuple[7] # 小怪掉落饼图概率 list
-    def GetDropItemRateListBoss(self): return self.attrTuple[8] # Boss掉落饼图概率 list
+    def GetGuajiAwardSet(self): return self.attrTuple[7] # 挂机收益设置,x秒|x次小怪掉率 list
+    def GetDropItemRateList(self): return self.attrTuple[8] # 小怪掉落饼图概率 list
+    def GetDropItemRateListBoss(self): return self.attrTuple[9] # Boss掉落饼图概率 list
 
 # 集字活动兑换模板表
 class IPY_CollectWordsExchange():
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActCollectWords.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActCollectWords.py
index 6ef8557..53aadfb 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActCollectWords.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActCollectWords.py
@@ -89,6 +89,7 @@
                 PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollectWordsExchangeCount % (actNum, exchangeNum), 0)
                 
     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollectWordsID % actNum, actID)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollectWordsGJSeconds % actNum, 0)
     GameWorld.DebugLog("集字活动重置! actNum=%s,cfgID=%s,templateID=%s,actID=%s" % (actNum, cfgID, templateID, actID), playerID)
     
     if state:
@@ -212,6 +213,73 @@
             
     return dropItemCountDict
 
+def OnGetGuajiAwardItemDict(curPlayer, awardSeconds, isQuick):
+    ## 获取挂机收益
+    
+    dropItemCountDict = {}
+    for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_CollectWords, {}).values():
+        actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
+        
+        if not actInfo.get(ShareDefine.ActKey_State):
+            continue
+        
+        cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
+        ipyData = IpyGameDataPY.GetIpyGameData("ActCollectWords", cfgID)
+        if not ipyData:
+            continue
+        
+        dropRateList = ipyData.GetDropItemRateList()
+        if not dropRateList:
+            continue
+        
+        guajiAwardSet = ipyData.GetGuajiAwardSet() # x秒x次
+        if not guajiAwardSet:
+            continue
+        doSeconds, doCount = guajiAwardSet
+        
+        if not isQuick:
+            unSeconds = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollectWordsGJSeconds % (actNum))
+            awardSeconds += unSeconds
+            
+            canDoCount = awardSeconds / doSeconds
+            killCount = canDoCount * doCount
+            
+            updUnSeconds = awardSeconds % doSeconds
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollectWordsGJSeconds % (actNum), updUnSeconds)
+            GameWorld.DebugLog("    挂机集字活动: actNum=%s,awardSeconds=%s,canDoCount=%s,killCount=%s,unSeconds=%s,updUnSeconds=%s" 
+                               % (actNum, awardSeconds, canDoCount, killCount, unSeconds, updUnSeconds))
+        else:
+            canDoCount = awardSeconds / doSeconds
+            killCount = canDoCount * doCount
+            GameWorld.DebugLog("    挂机集字活动: actNum=%s,awardSeconds=%s,canDoCount=%s,killCount=%s" 
+                               % (actNum, awardSeconds, canDoCount, killCount))
+        if killCount <= 0:
+            continue
+        
+        preRate = 0
+        maxRate = dropRateList[-1][0]
+        for rateInfo in dropRateList:
+            rate, dropItemID = rateInfo
+            curRate = rate - preRate
+            if not curRate:
+                break
+            preRate = rate
+            if not dropItemID:
+                continue
+            totalRate = curRate * killCount # 总概率
+            dropCount = totalRate / maxRate # 可掉落数
+            rateEx = totalRate % maxRate # 剩余概率
+            if GameWorld.CanHappen(rateEx, maxRate):
+                dropCount += 1
+            if not dropCount:
+                continue
+            
+            dropItemCountDict[dropItemID] = dropItemCountDict.get(dropItemID, 0) + dropCount
+            GameWorld.DebugLog("    挂机集字活动掉字: actNum=%s,dropItemID=%s,dropCount=%s,curRate=%s,totalRate=%s" 
+                               % (actNum, dropItemID, dropCount, curRate, totalRate))
+            
+    return dropItemCountDict
+
 #// AA 09 集字活动兑换 #tagCMActCollectWordsExchange
 #
 #struct    tagCMActCollectWordsExchange
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActGarbageSorting.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActGarbageSorting.py
index 29cca2d..2056fe4 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActGarbageSorting.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerActGarbageSorting.py
@@ -76,6 +76,7 @@
         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GarbageTaskValue % (actNum, taskID), 0)
         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GarbageTaskFinishCount % (actNum, taskID), 0)
     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GarbageEnvironmentValue % actNum, 0)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GarbageGJSeconds % actNum, 0)
     
     # 清除垃圾背包物品、重置环保值
     ItemControler.ClearPack(curPlayer, ShareDefine.rptGarbage)
@@ -196,6 +197,68 @@
     Sync_GarbageTaskInfo(curPlayer, actNum, taskID)
     return giveItemList
 
+def OnGetGuajiAwardItemDict(curPlayer, awardSeconds, isQuick):
+    ## 获取挂机收益
+        
+    dropItemCountDict = {}
+    guajiAwardSet = IpyGameDataPY.GetFuncEvalCfg("GarbageSorting", 3) # 挂机收益设置 x秒|x次执行数值4
+    if not guajiAwardSet:
+        return dropItemCountDict
+    doSeconds, doCount = guajiAwardSet
+    
+    dropRateList = IpyGameDataPY.GetFuncEvalCfg("GarbageSorting", 4) # 挂机收益概率饼图 [[概率, [物品ID,个数,是否拍品]], ...]
+    
+    for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_GarbageSorting, {}).values():
+        actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
+        
+        if not actInfo.get(ShareDefine.ActKey_State):
+            continue
+        
+        if not isQuick:
+            unSeconds = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GarbageGJSeconds % (actNum))
+            awardSeconds += unSeconds
+            
+            canDoCount = awardSeconds / doSeconds
+            killCount = canDoCount * doCount
+            
+            updUnSeconds = awardSeconds % doSeconds
+            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GarbageGJSeconds % (actNum), updUnSeconds)
+            GameWorld.DebugLog("    挂机垃圾分类: actNum=%s,awardSeconds=%s,canDoCount=%s,killCount=%s,unSeconds=%s,updUnSeconds=%s" 
+                               % (actNum, awardSeconds, canDoCount, killCount, unSeconds, updUnSeconds))
+        else:
+            canDoCount = awardSeconds / doSeconds
+            killCount = canDoCount * doCount
+            GameWorld.DebugLog("    挂机垃圾分类: actNum=%s,awardSeconds=%s,canDoCount=%s,killCount=%s" 
+                               % (actNum, awardSeconds, canDoCount, killCount))
+        if killCount <= 0:
+            continue
+        
+        preRate = 0
+        maxRate = dropRateList[-1][0]
+        for rateInfo in dropRateList:
+            rate, dropItemInfo = rateInfo
+            curRate = rate - preRate
+            if not curRate:
+                break
+            preRate = rate
+            if not dropItemInfo:
+                continue
+            totalRate = curRate * killCount # 总概率
+            dropCount = totalRate / maxRate # 可掉落数
+            rateEx = totalRate % maxRate # 剩余概率
+            if GameWorld.CanHappen(rateEx, maxRate):
+                dropCount += 1
+            if not dropCount:
+                continue
+            dropItemID, itemCount, _ = dropItemInfo
+            dropItemCount = itemCount * dropCount
+            
+            dropItemCountDict[dropItemID] = dropItemCountDict.get(dropItemID, 0) + dropItemCount
+            GameWorld.DebugLog("    挂机垃圾分类产出: actNum=%s,dropItemID=%s,dropCount=%s,dropItemCount=%s,curRate=%s,totalRate=%s" 
+                               % (actNum, dropItemID, dropCount, dropItemCount, curRate, totalRate))
+            
+    return dropItemCountDict
+
 #// AA 14 垃圾分类活动分类垃圾 #tagCMActGarbageSorting
 #
 #struct    tagCMActGarbageSorting
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGuaji.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGuaji.py
index a27282c..123b6c9 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGuaji.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGuaji.py
@@ -20,6 +20,9 @@
 import PlayerControl
 import ChPyNetSendPack
 import PlayerWorldAverageLv
+import PlayerActGarbageSorting
+import PlayerActCollectWords
+import PlayerGoldInvest
 import FormulaControl
 import NetPackCommon
 import IpyGameDataPY
@@ -294,6 +297,16 @@
             itemID, itemCount = itemInfo
             itemDict[itemID] = itemDict.get(itemID, 0) + itemCount
             
+    # 集字掉落
+    dropWordsCountDict = PlayerActCollectWords.OnGetGuajiAwardItemDict(curPlayer, awardSeconds, isQuick)
+    for itemID, dropCount in dropWordsCountDict.items():
+        itemDict[itemID] = itemDict.get(itemID, 0) + dropCount
+        
+    # 垃圾回收
+    giveGarbageItemList = PlayerActGarbageSorting.OnGetGuajiAwardItemDict(curPlayer, awardSeconds, isQuick)
+    for itemID, dropCount in giveGarbageItemList.items():
+        itemDict[itemID] = itemDict.get(itemID, 0) + dropCount
+        
     GameWorld.DebugLog("    itemDict=%s" % (itemDict), playerID)
     return addExp, moneyDict, itemDict
 
@@ -320,7 +333,7 @@
             GameWorld.DebugLog("快速挂机收益次数已达每日上限!  quickCountToday=%s" % quickCountToday, playerID)
             return
         
-        if quickCountToday >= quickCountFree:
+        if quickCountToday >= quickCountFree and not PlayerGoldInvest.GetInvestState(curPlayer, ChConfig.InvestType_Life):
             todayBuyCount = quickCountToday - quickCountFree # 今日已购买次数
             costMoneyType = IpyGameDataPY.GetFuncCfg("GuajiQuick", 3)
             costMoneyList = IpyGameDataPY.GetFuncEvalCfg("GuajiQuick", 4)
@@ -366,9 +379,26 @@
     for moneyType, moneyValue in moneyDict.items():
         PlayerControl.GiveMoney(curPlayer, moneyType, moneyValue, "Guaji")
         
-    giveItemList = [[itemID, itemCount, 0] for itemID, itemCount in itemDict.items()]
-    ItemControler.GivePlayerItemOrMail(curPlayer, giveItemList, event=["Guaji", False, {}])
-    
+    # 分背包放入
+    packTypeItemDict = {}
+    for itemID, itemCount in itemDict.items():
+        itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
+        if not itemData:
+            continue
+        packType = ChConfig.GetItemPackType(itemData)
+        if packType not in packTypeItemDict:
+            packTypeItemDict[packType] = []
+        giveItemList = packTypeItemDict[packType]
+        giveItemList.append([itemID, itemCount, 0])
+        
+    for packType, giveItemList in packTypeItemDict.items():
+        # 垃圾分类背包直接放入
+        if packType == ShareDefine.rptGarbage:
+            for itemID, itemCount, isAuctionItem in giveItemList:
+                ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [packType], event=["Guaji", False, {}])
+        else:
+            ItemControler.GivePlayerItemOrMail(curPlayer, giveItemList, event=["Guaji", False, {}])
+            
     Sync_GuajiAward(curPlayer, 1, awardSeconds, exp, moneyDict, itemDict)
     return
 

--
Gitblit v1.8.0