hxp
2025-11-24 3861b284c63fd8ba519c71e386a8f49dcad26dab
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerTreasure.py
@@ -33,6 +33,14 @@
import random
(
CostType_Money, # 消耗货币 0
CostType_DayFree, # 每日免费 1
CostType_Item, # 消耗道具 2
CostType_ADFree, # 广告免费 3
) = range(4)
CostFreeTypes = [CostType_DayFree, CostType_ADFree]
# 寻宝类型: >=100的为策划自行配置的自定义寻宝类型,<100的用于指定系统寻宝功能
TreasureTypeList = (
TreasureType_Jipin, # 极品寻宝 1
@@ -107,12 +115,15 @@
#};
def OnRequestTreasure(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerLV = curPlayer.GetLV()
    playerID = curPlayer.GetPlayerID()
    treasureType = clientData.TreasureType
    treasureIndex = clientData.TreasureIndex
    costType = clientData.CostType
    DoTreasure(curPlayer, treasureType, costType, treasureIndex)
    return
def DoTreasure(curPlayer, treasureType, costType, treasureIndex=0):
    playerLV = curPlayer.GetLV()
    playerID = curPlayer.GetPlayerID()
    GameWorld.DebugLog("玩家寻宝: treasureType=%s,treasureIndex=%s,costType=%s,playerLV=%s" 
                       % (treasureType, treasureIndex, costType, playerLV), playerID)
    
@@ -127,6 +138,9 @@
    if not treasureCountList:
        GameWorld.DebugLog("没有寻宝次数列表配置!", playerID)
        return
    if costType == CostType_ADFree:
        treasureIndex = 0
        GameWorld.DebugLog("广告寻宝强制设置: treasureIndex=%s" % treasureIndex, playerID)
    if treasureIndex < 0 or treasureIndex >= len(treasureCountList):
        GameWorld.ErrLog("寻宝次数索引不存在!treasureType=%s,treasureIndex=%s" % (treasureType, treasureIndex), playerID)
        return
@@ -149,7 +163,7 @@
            return
        
    # 免费次数
    if costType == 1:
    if costType == CostType_DayFree:
        dailyFreeCount = setIpyData.GetDailyFreeCount()
        if not dailyFreeCount:
            GameWorld.ErrLog("该寻宝类型索引不支持免费次数寻宝!treasureType=%s,treasureIndex=%s" % (treasureType, treasureIndex), playerID)
@@ -159,9 +173,11 @@
        if updFreeCountToday > dailyFreeCount:
            GameWorld.DebugLog("今日免费次数不足,无法使用免费寻宝! freeCountToday=%s + %s > %s" % (freeCountToday, treasureCount, dailyFreeCount), playerID)
            return
    # 广告免费
    elif costType == CostType_ADFree:
        pass
    # 寻宝道具, 目前默认消耗1个
    elif costType == 2:
    elif costType == CostType_Item:
        costItemID = setIpyData.GetCostItemID()
        costItemList = setIpyData.GetCostItemCountList() # 消耗道具物品ID列表
        if not costItemID or not costItemList or treasureIndex >= len(costItemList):
@@ -249,11 +265,9 @@
        beSureCountByIndexDict = beSureCountByIndexList[treasureIndex]
        maxIndexCount = min(9, max(beSureCountByIndexDict))
        curIndexCount = GameWorld.GetDataByDigitPlace(treasureCountEx, treasureIndex) + 1
    rateByIndexCount = 0 # 第x次x抽必出可产出个数
    rateByIndexCountList = []
    beSureCountByIndexCfg = []
    if curIndexCount <= maxIndexCount and curIndexCount in beSureCountByIndexDict:
        rateByIndexCountList = [[10000, beSureCountByIndexDict[curIndexCount]]]
        rateByIndexCount = 1 # 可扩展支持产出多个,暂定单次抽奖仅定制产出1个
        beSureCountByIndexCfg = beSureCountByIndexDict[curIndexCount]
        
    # 单抽产出优先级: 幸运物品 > 必出 > 保底 > 普通
    # 连抽没有优先级限制,只要满足条件即可产出
@@ -275,8 +289,17 @@
        
        curRateList = [] # 可能会改变饼图,每次抽奖使用新的饼图对象,不要改变配置的饼图概率
        
        # 第x次x抽必出,优先级最高,无视其他
        if not curRateList and beSureCountByIndexCfg:
            if tIndex == 0:
                curRateList = [[10000, beSureCountByIndexCfg[0]]]
            else:
                curRateList = beSureCountByIndexCfg[1]
            GameWorld.DebugLog("    【第x次x抽必出】: treasureIndex=%s,curIndexCount=%s,%s"
                               % (treasureIndex, curIndexCount, curRateList), playerID)
        # 满幸运必出
        if stageLuck and updLuck >= stageLuck and luckItemRateList:
        if not curRateList and stageLuck and updLuck >= stageLuck and luckItemRateList:
            curRateList = GetRemoveLimitGridRateList(luckItemRateList, gridNumCountInfo, gridNumMaxLimitInfo)
            GameWorld.DebugLog("    【满幸运必出饼图】: %s" % curRateList, playerID)
            
@@ -290,13 +313,6 @@
        if not curRateList and ensureCount and updTreasureCount % ensureCount == 0 and ensureRateList:
            curRateList = GetRemoveLimitGridRateList(ensureRateList, gridNumCountInfo, gridNumMaxLimitInfo)
            GameWorld.DebugLog("    【满%s次数必出饼图】: %s" % (ensureCount, curRateList), playerID)
        # 第x次x抽必出,优先级较低
        if not curRateList and rateByIndexCountList and rateByIndexCount > 0:
            rateByIndexCount -= 1
            curRateList = rateByIndexCountList
            GameWorld.DebugLog("    【第x次x抽必出】: treasureIndex=%s,curIndexCount=%s,rateByIndexCount=%s,%s"
                               % (treasureIndex, curIndexCount, rateByIndexCount, rateByIndexCountList), playerID)
            
        doCount = 0
        while doCount <= 50: # 限制最大次数
@@ -390,10 +406,12 @@
        treasureResult.append([gridNum, itemID, itemCount, isTrans])
        
    # 扣消耗
    if costType == 1:
    if costType == CostType_DayFree:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureFreeCount % (treasureType), updFreeCountToday)
        GameWorld.DebugLog("消耗免费次数,更新今日已使用免费次数: %s" % updFreeCountToday, playerID)
    elif costType == 2:
    elif costType == CostType_ADFree:
        GameWorld.DebugLog("广告寻宝免费", playerID)
    elif costType == CostType_Item:
        ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCostItemCount, ChConfig.ItemDel_Treasure)
        GameWorld.DebugLog("扣除寻宝道具,costItemID=%s,delCostItemCount=%s" % (costItemID, delCostItemCount), playerID)
        if lackCountCostMoney:
@@ -422,20 +440,6 @@
        
    if treasureType in [TreasureType_HeroComm, TreasureType_HeroHigh, TreasureType_HeroScore]:
        PlayerActivity.AddDailyTaskValue(curPlayer, ChConfig.DailyTask_HeroCall, treasureCount)
    #if treasureType == TreasureType_Rune:
    #    PlayerFeastTravel.AddFeastTravelTaskValue(curPlayer, ChConfig.Def_FeastTravel_RuneTreasure, treasureCount)
    #    PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_RuneTreasure, treasureCount)
    #    PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_TreasureRune, treasureCount)
    #elif treasureType == TreasureType_Jipin:
    #    PlayerFeastTravel.AddFeastTravelTaskValue(curPlayer, ChConfig.Def_FeastTravel_Treasure, treasureCount)
    #    PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_Treasure, treasureCount)
    #    PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_TreasureJipin, treasureCount)
    #elif treasureType == TreasureType_Jueshi:
    #    PlayerFeastTravel.AddFeastTravelTaskValue(curPlayer, ChConfig.Def_FeastTravel_JSTreasure, treasureCount)
    #    PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_JSTreasure, treasureCount)
    #    PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_TreasureJueshi, treasureCount)
    #elif treasureType == TreasureType_Gubao:
    #    PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_TreasureGubao, treasureCount)
        
    PlayerActLunhuidian.AddLunhuidianValue(curPlayer, PlayerActLunhuidian.AwardType_Treasure, treasureType, treasureCount)
    
@@ -534,7 +538,7 @@
def GetUpdLuckyItemRateList(ipyData, luckyGridNumList, curLuck, luckFormula, costType):
    # 获取幸运物品提升概率后的饼图
    treasureType = ipyData.GetTreasureType()
    srcPieList = ipyData.GetGridItemRateListFree() if costType == 1 else ipyData.GetGridItemRateList1()
    srcPieList = ipyData.GetGridItemRateListFree() if costType in CostFreeTypes else ipyData.GetGridItemRateList1()
    if not srcPieList:
        srcPieList = ipyData.GetGridItemRateList1()