From c902d9ca0a67af00b23491238f1a7e2670fab417 Mon Sep 17 00:00:00 2001 From: panw Date: Fri, 30 Jan 2026 16:46:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor(CardSet):=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E5=8D=A1=E7=89=8C=E6=B1=A0=E9=85=8D=E7=BD=AE=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E7=A7=BB=E9=99=A4=E5=8A=A8=E6=80=81=E6=9D=83=E9=87=8D?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将多等级权重累积逻辑改为仅使用符合条件的最大等级配置 - 移除基于解锁等级的动态权重计算,统一使用默认权重 - 保持99级配置的兜底机制,确保低等级时的正常功能 --- assets/script/game/common/config/CardSet.ts | 52 +++++++-------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/assets/script/game/common/config/CardSet.ts b/assets/script/game/common/config/CardSet.ts index b7fa6511..2c6e7fa9 100644 --- a/assets/script/game/common/config/CardSet.ts +++ b/assets/script/game/common/config/CardSet.ts @@ -172,51 +172,33 @@ function getDefaultPool(type: CardType, level: number = 1): IPoolItem[] { } if (configMap) { - // 收集所有已解锁的ID (去重) - const unlockedIds = new Set(); - - // 1. 遍历所有等级配置,收集 <= level 的项 + // 1. 找到符合条件的最大等级 Key (<= level 且 != 99) + let targetKey = -1; + let maxLv = -1; + Object.keys(configMap).forEach(lvlStr => { const lv = parseInt(lvlStr); - // 忽略 99 (默认全开) 这种特殊标记,只处理正常等级逻辑 - if (lv <= level && lv !== 99) { - const ids = configMap![lv]; - if (ids) { - // 计算权重:等级越高,权重越高 - // 基础权重 defaultWeight - // 额外权重:(解锁等级 / 当前等级) * 基础权重 * 2 - // 例如:当前10级 - // 1级卡权重: 100 + (1/10)*200 = 120 - // 9级卡权重: 100 + (9/10)*200 = 280 - // 这样新解锁的卡牌出现概率显著高于旧卡牌 - const extraWeight = Math.floor((lv / Math.max(1, level)) * defaultWeight * 2); - const finalWeight = defaultWeight + extraWeight; - - ids.forEach(id => { - // 如果已经存在(可能在低等级也配置了),取最大权重 - const existing = items.find(i => i.id === id); - if (existing) { - existing.weight = Math.max(existing.weight, finalWeight); - } else { - items.push({ id, weight: finalWeight }); - } - unlockedIds.add(id); - }); + if (lv !== 99 && lv <= level) { + if (lv > maxLv) { + maxLv = lv; + targetKey = lv; } } }); - // 2. 如果当前等级没有任何解锁项,且存在 99 号默认配置,则回退使用 99 号配置 - // 这种行为保持了原有逻辑的"兜底"特性,但更智能 - if (unlockedIds.size === 0 && configMap[99]) { + // 2. 如果找到了目标等级配置,则使用该配置 + if (targetKey !== -1 && configMap[targetKey]) { + const ids = configMap[targetKey]; + ids.forEach(id => { + items.push({ id, weight: defaultWeight }); + }); + } + // 3. 如果没找到(等级过低),且存在 99 号默认配置,则使用 99 号配置 + else if (configMap[99]) { configMap[99].forEach(id => { items.push({ id, weight: defaultWeight }); - unlockedIds.add(id); }); } - - // 3. 构建结果 (items 已经在循环中构建好了,这里不需要再从 unlockedIds 重新构建) - // unlockedIds.forEach(id => items.push({ id, weight: defaultWeight })); } else { // 兜底逻辑:如果该类型没有配置表 (理论上不应发生,除非新增类型未配置) // 这里保留原有的全量兜底逻辑作为最后的防线