From d7f44d8d871a90c818bdb3ffe9a60af875b7100a Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期二, 30 九月 2025 10:12:23 +0800
Subject: [PATCH] 135 【挑战】战锤秘境-服务端(白骨盈野;副本基础;副本扫荡;广告奖励支持;)

---
 ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py |  371 +++++++++++++++-------------------------------------
 1 files changed, 111 insertions(+), 260 deletions(-)

diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py
index 7891538..76ade25 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldGift.py
@@ -2,172 +2,153 @@
 # -*- coding: GBK -*-
 #-------------------------------------------------------------------------------
 #
-#-------------------------------------------------------------------------------
+##@package Player.PlayerGoldGift
 #
-##@package PlayerGoldGift
-#
-# @todo: 记录玩家的充值豪礼奖励信息,二进制位标示,目前用了一个字典
+# @todo:充值礼包
 # @author hxp
-# @date 2013-10-16 17:00
+# @date 2025-09-28
+# @version 1.0
 #
-# @version 3.0
-# 简要说明:
-# 详细描述: 
-# @change: "2013-10-22 11:10" hxp 修改读取奖励物品表方式
-# @change: "2013-11-12 17:00" hxp 增加首充奖励领取逻辑
-# @change: "2013-12-09 18:00" hxp 增加领奖全服广播mark
-# @change: "2014-05-11 14:35" xcc 增加mark如果为空,就不提示
-# @change: "2014-06-06 20:30" hxp 领奖全服广播修改
-# @change: "2014-06-12 21:00" hxp 增加天天首充
-# @change: "2014-08-22 12:00" hxp 去除多余全服广播
-# @change: "2014-10-09 14:00" hxp 首充/天天首充规则修改,天天首充一天只能领取一次
-# @change: "2014-12-16 18:00" hxp 发送充值豪礼发送邮件
-# @change: "2014-12-22 14:00" hxp 增加单日充值多选一礼包
-# @change: "2015-02-06 10:30" hxp 单日充值多选一礼包支持配置星期几
-# @change: "2015-02-11 18:30" hxp 单日充值多选一礼包开服前几天不开启的仅限制星期几的活动
-# @change: "2015-04-23 12:00" hxp 当日充值多选一礼包支持多个钻石档奖励
-# @change: "2015-04-28 16:00" hxp 增加每日充值元宝数通知
-# @change: "2015-05-21 14:30" hxp 增加当日充值无限领取礼包
-# @change: "2015-06-09 20:30" hxp 奖励名称改为客户端配置
-# @change: "2016-01-26 15:00" hxp PY表支持重读
-# @change: "2016-06-27 14:00" hxp 首充支持可配置额度
-#------------------------------------------------------------------------------ 
-#"""Version = 2017-05-12 18:00"""
-#------------------------------------------------------------------------------ 
+# 详细描述: 充值礼包,主要一些常用、通用的
+#
+#-------------------------------------------------------------------------------
+#"""Version = 2025-09-28 14:30"""
+#-------------------------------------------------------------------------------
+
+import ChConfig
 import GameWorld
 import IPY_GameWorld
 import ItemControler
-import ChConfig
-import ItemCommon
 import PlayerControl
-import ShareDefine
 import DataRecordPack
 import ChPyNetSendPack
-import PlayerFamilyRedPacket
 import NetPackCommon
 import IpyGameDataPY
-import PlayerTJG
+import ShareDefine
 import CommFunc
-import ChEquip
+import ObjPool
 
 import time
 
+def OnDay(curPlayer):
+    DoDailyPackBuyGiftOnDay(curPlayer)
+    return
+
+def OnLogin(curPlayer):
+    Sync_FirstChargeInfo(curPlayer)
+    Sync_HistoryChargeAwardGetRecordInfo(curPlayer)
+    Sync_DailyPackBuyGiftInfo(curPlayer)
+    return
+
+def OnGiftByCTGID(curPlayer, ctgID):
+    OnActFirstCharge(curPlayer, ctgID)
+    OnActiviteDailyPackBuyGift(curPlayer, ctgID)  
+    return
+
 ##------------------------------------------------------------------------------
-def DoFirstGoldOpen(curPlayer):
-    ## 首充开启  记录提示剩余时间
-    if curPlayer.GetChangeCoinPointTotal():
+
+def ClearFirstCharge(curPlayer):
+    ## 重置首充 - 一般是GM用
+    resetCTGIDList = []
+    ipyDataMgr = IpyGameDataPY.IPY_Data()
+    for index in range(ipyDataMgr.GetFirstChargeCount()):
+        ipyData = ipyDataMgr.GetFirstChargeByIndex(index)
+        firstID = ipyData.GetFirstID()
+        ctgID = ipyData.GetNeedCTGID()
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstChargeTime % firstID, 0)
+        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstChargeRecord % firstID, 0)
+        resetCTGIDList.append(ctgID)
+    Sync_FirstChargeInfo(curPlayer)
+    return
+
+def OnActFirstCharge(curPlayer, ctgID):
+    ## 激活首充档位
+    firstIpyData = None
+    ipyDataMgr = IpyGameDataPY.IPY_Data()
+    for index in range(ipyDataMgr.GetFirstChargeCount()):
+        ipyData = ipyDataMgr.GetFirstChargeByIndex(index)
+        if ipyData.GetNeedCTGID() == ctgID:
+            firstIpyData = ipyData
+            break
+        
+    if not firstIpyData:
         return
-    showSysTime = IpyGameDataPY.GetFuncCfg("FirstGold", 3)
-    if not showSysTime:
-        return
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldRemainTime, showSysTime)
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, int(time.time()))
     
-    Sync_FirstGoldTime(curPlayer)
+    firstID = firstIpyData.GetFirstID()
+    chargeTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstChargeTime % firstID)
+    if chargeTime:
+        GameWorld.DebugLog("该首充档位已经激活过了,不重复激活: ctgID=%s,chargeTime=%s" % (ctgID, chargeTime))
+        return
+    
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstChargeTime % firstID, int(time.time()))
+    GameWorld.DebugLog("记录首充档位充值时间戳: ctgID=%s" % ctgID)
+    Sync_FirstChargeInfo(curPlayer)
     return
 
-def UpdateFirstGoldTime(curPlayer):
-    #更新首充提示剩余时间
-    if PlayerTJG.GetIsTJG(curPlayer):
-        return
-    remainTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldRemainTime)
-    if not remainTime:
-        return
-    if curPlayer.GetChangeCoinPointTotal():
-        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldRemainTime, 0)
-        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, 0)
-    else:
-        curTime = int(time.time())
-        startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldTipStartTime)
-        remainTime = max(0, remainTime - (curTime - startTime))
-        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldRemainTime, remainTime)
-        if not remainTime:
-            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, 0)
-    return
-
-def Sync_FirstGoldTime(curPlayer):
-    ##通知首充提示剩余时间
-    showSysTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldRemainTime)
-    if not showSysTime:
-        return
-    sendPack = ChPyNetSendPack.tagMCFirstGoldTime()
-    sendPack.Clear()
-    sendPack.FirstGoldRemainTime = showSysTime
-    NetPackCommon.SendFakePack(curPlayer, sendPack)
-    return
-
-
-def GetPlayerGoldGiftFirst(curPlayer, giftDay):
+def GetPlayerFirstCharge(curPlayer, giftDay, firstIDStr):
     '''领取玩家首充奖励
     @param dayIndex: 首充第几天奖励
     '''
-    
-    if not giftDay:
+    firstID = GameWorld.ToIntDef(firstIDStr)
+    if not firstID or not giftDay:
         return
     
-    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
-    firstGoldServerDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldServerDay)
-    if not firstGoldServerDay:
-        GameWorld.DebugLog("还未充值过!firstGoldServerDay=%s" % firstGoldServerDay)
+    playerID = curPlayer.GetPlayerID()
+    chargeTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstChargeTime % firstID)
+    if not chargeTime:
+        GameWorld.DebugLog("该档位未首充! firstID=%s" % firstID, playerID)
         return
-    canGetMaxDay = openServerDay - firstGoldServerDay + 1
+    
+    canGetMaxDay = GameWorld.GetDiff_Day(int(time.time()), chargeTime) + 1
     if giftDay > canGetMaxDay:
-        GameWorld.DebugLog("还未到可领取的首充天,无法领取!openServerDay=%s,firstGoldServerDay=%s,canGetMaxDay=%s < giftDay=%s" 
-                           % (openServerDay, firstGoldServerDay, canGetMaxDay, giftDay))
+        GameWorld.DebugLog("还未到可领取的首充天,无法领取!chargeTime=%s,giftDay=%s > %s" 
+                           % (GameWorld.ChangeTimeNumToStr(chargeTime), giftDay, canGetMaxDay), playerID)
         return
-    dayIndex = giftDay - 1
-    getRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord)
-    if getRecord & pow(2, dayIndex):
-        GameWorld.DebugLog("已经领取过首充奖励!giftDay=%s" % giftDay, curPlayer.GetPlayerID())
+    getRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstChargeRecord % firstID)
+    if getRecord & pow(2, giftDay):
+        GameWorld.DebugLog("已经领取过首充奖励!firstID=%s,giftDay=%s,getRecord=%s" % (firstID, giftDay, getRecord), playerID)
         return
     
-    if not curPlayer.GetChangeCoinPointTotal():
-        GameWorld.DebugLog("没有充值过,无法领取首充奖励!", curPlayer.GetPlayerID())
-        return
-    
-    ipyData = IpyGameDataPY.GetIpyGameData("FirstGold", giftDay)
+    ipyData = IpyGameDataPY.GetIpyGameData("FirstCharge", firstID)
     if not ipyData:
-        return    
-    jobItemInfoDict = ipyData.GetJobItemInfo()
-    commItemList = ipyData.GetCommItemList()
-    
-    rewardItemList = []
-    jobStr = str(curPlayer.GetJob())
-    if jobStr in jobItemInfoDict:
-        rewardItemList += jobItemInfoDict[jobStr]
-    rewardItemList += commItemList
-    
-    if not rewardItemList:
         return
-    needSpace = len(rewardItemList)
+    if not hasattr(ipyData, "GetAwardListDay%s" % giftDay):
+        return
+    awardList = getattr(ipyData, "GetAwardListDay%s" % giftDay)()
     
-    # 检查背包
-    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, needSpace)
-    if needSpace > packSpace:
-        PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")
+    if not ItemControler.CheckPackSpaceEnough(curPlayer, [itemInfo[:2] for itemInfo in awardList]):
         return
     
     # 更新已领取成功标记
-    updGetRecord = getRecord | pow(2, dayIndex)
-    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_GoldGiftFirstRecord, updGetRecord)
-    GameWorld.DebugLog("领取首充奖励: giftDay=%s,getRecord=%s,updGetRecord=%s, %s" % (giftDay, getRecord, updGetRecord, rewardItemList))
+    updGetRecord = getRecord | pow(2, giftDay)
+    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstChargeRecord % firstID, updGetRecord)
+    GameWorld.DebugLog("领取首充奖励: firstID=%s,giftDay=%s,getRecord=%s,updGetRecord=%s, %s" % (firstID, giftDay, getRecord, updGetRecord, awardList))
+    Sync_FirstChargeInfo(curPlayer)
     
-    # 给物品
-    isAuctionItem = False
-    for itemID, itemCount in rewardItemList:        
-        ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem])
-    ItemControler.NotifyGiveAwardInfo(curPlayer, rewardItemList, "GoldGiftFirst")
-    
-    # 全服提示
-    if len(rewardItemList) >= 2:
-        PlayerControl.WorldNotify(0, "FirstPayReward1", [curPlayer.GetPlayerName(), rewardItemList[0][0], rewardItemList[1][0], giftDay])
-        
-    # 记录领取事件
-    infoDict = {"GiftDay":giftDay, "ItemList":rewardItemList}
-    DataRecordPack.DR_GoldGiftGiveItem(curPlayer, "FirstGoldGift", infoDict)
-    
-    # 通知客户端
-    Sync_FirstGoldInfo(curPlayer)
+    isAuctionItem = 0
+    notifyAwardList = []
+    for itemID, itemCount, appointID in awardList:
+        setAttrDict = {ShareDefine.Def_CItemKey_AppointID:appointID} if appointID else {}
+        if not ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, event=["FirstCharge", False, {}], setAttrDict=setAttrDict):
+            continue
+        notifyAwardList.append([itemID, itemCount, isAuctionItem])
+    ItemControler.NotifyGiveAwardInfo(curPlayer, notifyAwardList, "FirstCharge")
+    return
+
+def Sync_FirstChargeInfo(curPlayer):
+    ## 通知首充信息
+    clientPack = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagSCFirstChargeInfo)
+    clientPack.FirstChargeList = []
+    ipyDataMgr = IpyGameDataPY.IPY_Data()
+    for index in range(ipyDataMgr.GetFirstChargeCount()):
+        ipyData = ipyDataMgr.GetFirstChargeByIndex(index)
+        firstID = ipyData.GetFirstID()
+        firstCharge = ObjPool.GetPoolMgr().acquire(ChPyNetSendPack.tagSCFirstCharge)
+        firstCharge.ChargeTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstChargeTime % firstID)
+        firstCharge.AwardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstChargeRecord % firstID)
+        clientPack.FirstChargeList.append(firstCharge)
+    clientPack.Count = len(clientPack.FirstChargeList)
+    NetPackCommon.SendFakePack(curPlayer, clientPack)
     return
 
 ################################ 每日打包直购礼包 ###################################
@@ -345,135 +326,6 @@
 
 ###################################################################
 
-## 充值豪礼OnDay
-#  @param curPlayer: 玩家
-#  @return: None
-def OnDay(curPlayer):
-    DoDailyPackBuyGiftOnDay(curPlayer)
-    return
-
-## 充值豪礼OnLogin
-#  @param curPlayer: 玩家
-#  @return: None
-def OnLogin(curPlayer):
-    Sync_FirstGoldInfo(curPlayer)
-    
-    Sync_FirstGoldTime(curPlayer)
-    Sync_HistoryChargeAwardGetRecordInfo(curPlayer)
-    #更新首充提示开始计时时间
-    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldRemainTime):
-        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTipStartTime, int(time.time()))
-    Sync_DailyPackBuyGiftInfo(curPlayer)
-    return
-
-## 玩家充值元宝
-#  @param curPlayer: 玩家
-#  @param addGold: 充元宝数
-#  @return: None
-def OnPlayerChargeGold(curPlayer):
-    return
-
-def OnGiftByCTGID(curPlayer, ctgID):
-    
-    firstGoldCTGIDList = IpyGameDataPY.GetFuncEvalCfg("FirstGold", 4)
-    if ctgID in firstGoldCTGIDList:
-        OnActiviteFirstGold(curPlayer)
-        
-    OnActiviteDailyPackBuyGift(curPlayer, ctgID)  
-    return
-
-def OnActiviteFirstGold(curPlayer):
-    firstGoldServerDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldServerDay)
-    if not firstGoldServerDay:
-        recordServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
-        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldServerDay, recordServerDay)
-        GameWorld.DebugLog("记录首充开服天: recordServerDay=%s" % recordServerDay)
-        Sync_FirstGoldInfo(curPlayer)
-        
-    return
-
-def Sync_FirstGoldInfo(curPlayer):
-    ## 通知首充信息
-    sendPack = ChPyNetSendPack.tagMCFirstGoldInfo()
-    sendPack.Clear()
-    sendPack.FirstGoldRewardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GoldGiftFirstRecord)
-    sendPack.FirstGoldTry = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldTry)
-    sendPack.FirstGoldServerDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldServerDay)
-    NetPackCommon.SendFakePack(curPlayer, sendPack)
-    return
-
-#// A5 11 试用首充武器 #tagCMTryFirstGoldItem
-#
-#struct    tagCMTryFirstGoldItem
-#
-#{
-#    tagHead        Head;
-#};
-def OnTryFirstGoldItem(index, clientData, tick):
-    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
-    if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FirstGoldTry) != 1:
-        return
-    tryItemDict = IpyGameDataPY.GetFuncEvalCfg('FirstGoldTryItem', 1, {})
-    tryItemID = tryItemDict.get(curPlayer.GetJob(), 0)
-    if not tryItemID:
-        return
-    
-    
-    #先卸下主手武器(若背包满则发邮件),再穿上送的武器
-    equipPlace = ShareDefine.retWeapon
-    curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
-    curItem = curPack.GetAt(equipPlace)
-    if ItemCommon.CheckItemCanUse(curItem):
-        spaceIndex = ItemControler.GetItemPackSpaceIndex(curPlayer, IPY_GameWorld.rptItem)
-        if spaceIndex == -1:
-            itemObj = ItemCommon.GetMailItemDict(curItem)
-            PlayerControl.SendMailByKey('', [curPlayer.GetID()], [itemObj])
-            ItemCommon.DelItem(curPlayer, curItem, 1, False)
-        else:
-            result = ItemControler.PlayerItemControler(curPlayer).UnEquipItem(equipPlace, spaceIndex)
-            if not result:
-                GameWorld.Log('    试用首充武器 卸下原装备失败!!', curPlayer.GetID())
-                return
-    tryItem = ItemControler.GetOutPutItemObj(tryItemID)
-    if ChEquip.DoPlayerEquipItem(curPlayer, tryItem, ItemCommon.GetEquipPackIndex(tryItem), tick):
-        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FirstGoldTry, 2)
-    else:
-        curItem.clear()
-        GameWorld.Log('    试用首充武器 试穿失败!!tryItemID=%s'%tryItemID, curPlayer.GetID())
-    Sync_FirstGoldInfo(curPlayer)
-    return
-
-def FirstGoldTryItemOutTime(curPlayer):
-    ##首充试用物品过期了 若背包仓库没武器则送一把
-    
-    haveEquip = False #是否有可穿的武器
-    playerItemControl = ItemControler.PlayerItemControler(curPlayer)
-    for packIndex in [IPY_GameWorld.rptItem, IPY_GameWorld.rptWarehouse]:
-        curPack = curPlayer.GetItemManager().GetPack(packIndex)
-        for i in range(0, curPack.GetCount()):
-            curItem = curPack.GetAt(i)
-            if not ItemCommon.CheckItemCanUse(curItem):
-                continue
-            if curItem.GetEquipPlace() != ShareDefine.retWeapon:
-                continue
-            if not ItemCommon.CheckItemCanUseByExpireTime(curItem):
-                # 过期
-                continue
-            if not playerItemControl.PlayerCanEquipItem(curItem, False):
-                continue
-            haveEquip = True
-            break
-    if not haveEquip:
-        giveItemDict = IpyGameDataPY.GetFuncEvalCfg('FirstGoldTryItem', 2, {})
-        giveItemID = giveItemDict.get(curPlayer.GetJob(), 0)
-        if not giveItemID:
-            return
-        GameWorld.DebugLog('首充试用物品过期了 背包仓库没武器则送一把giveItemID=%s'%giveItemID, curPlayer.GetID())
-        if not ItemControler.GivePlayerItem(curPlayer, giveItemID, 1, 0, [IPY_GameWorld.rptItem]):
-            GameWorld.DebugLog('首充试用物品过期了 背包仓库没武器则送一把 没给成功!!giveItemID=%s'%giveItemID, curPlayer.GetID())
-            
-    return
-
 def OnGetHistoryRechargeAward(curPlayer, awardID):
     # 领取历史充值奖励
     
@@ -526,7 +378,6 @@
     DataRecordPack.SendEventPack("HistoryRechargeAward", {'awardID':awardID, 'needCoin':needCoin}, curPlayer)
     return
 
-
 ## 通知等级奖励领取记录信息
 #  @param None
 #  @return None
@@ -535,4 +386,4 @@
     sendPack.Clear()
     sendPack.AwardGetRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HistoryChargeAwardGetRecord, 0)
     NetPackCommon.SendFakePack(curPlayer, sendPack)
-    return
\ No newline at end of file
+    return

--
Gitblit v1.8.0