Files
pixelheros/assets/script/game/common/config/ICardSet.ts
panFD ac0891ccdd feat: 实现药水卡限时强化功能,支持自定义数值覆写
1. 新增Buff数值覆写机制,支持药水卡自定义buff效果数值
2. 重构属性计算逻辑,支持读取药水卡传递的覆写值
3. 新增多组限时强化Buff与药水卡配置
4. 优化UI数值显示,实时展示最终属性值
5. 新增多维度调试日志方便排查问题
2026-07-23 23:00:49 +08:00

132 lines
5.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file ICardSet.ts
* @description 商品/药品卡池独立配置
*
* 职责:
* 定义所有商品/药品卡的静态数据与技能卡池SCardSet和装备卡池EquipSet分离。
* 商品/药品为一次性消耗品,购买后立即触发一次 buff 效果(如治疗、护盾、属性强化等)。
*
* 设计:
* - 参考 SCardSet.ts 结构,但商品是"只触发一次的 buff 技能",而非"多次触发的攻击技能"。
* - trigger_type 统一为 Instant即时触发
* - t_times 固定为 1只触发一次
* - kind 为 CKind.Potion药水类
*
* 依赖:
* - CardSet —— CardConfig / CardType / CKind / CardLV / CardTriggerType
* - SkillSet —— SkillOverrides
*/
import { CardConfig, CardType, CardLV, CKind, CardTriggerType } from "./CardSet";
import { SkillOverrides } from "./SkillSet";
/** 商品/药品卡原始数据(平铺字段,构建后转为 CardConfig */
interface ItemCardRaw {
uuid: number;
skill: number; // 关联的技能 UUIDbuff 技能)
name: string;
info: string;
cost: number; // 购买价格
weight: number; // 抽取权重
overrides?: SkillOverrides; // 技能参数覆写(如自定义治疗量、护盾值等)
}
const ItemCardData: ItemCardRaw[] = [
// ==================== 一次性回血(计时性 HoT5s ====================
{ uuid: 9101, skill: 6502, name: "再生药水", info: "全体友方每秒回复生命,持续 5 秒", cost: 0, weight: 20 },
// ==================== 计时性强化(统一 5s ====================
{ uuid: 9102, skill: 6503, name: "攻击药水", info: "全体友方攻击力提升 50%,持续 5 秒", cost: 0, weight: 15 },
{ uuid: 9103, skill: 6504, name: "暴击药水", info: "全体友方暴击率提升 30%,持续 5 秒", cost: 0, weight: 15 },
{ uuid: 9104, skill: 6505, name: "击退药水", info: "全体友方击退概率提升 30%,持续 5 秒", cost: 0, weight: 12 },
{ uuid: 9105, skill: 6506, name: "穿透药水", info: "全体友方穿透概率提升 30%,持续 5 秒", cost: 0, weight: 12 },
{ uuid: 9106, skill: 6507, name: "攻速药水", info: "全体友方攻击速度提升 40%,持续 5 秒", cost: 0, weight: 15 },
{ uuid: 9107, skill: 6508, name: "风怒药水", info: "全体友方风怒概率提升 20%,持续 5 秒", cost: 0, weight: 12 },
{ uuid: 9108, skill: 6509, name: "击晕药水", info: "全体友方击晕概率提升 30%,持续 5 秒", cost: 0, weight: 12 },
{ uuid: 9109, skill: 6510, name: "击晕抗性药水", info: "全体友方击晕抗性提升 50%,持续 5 秒", cost: 4, weight: 10 },
{ uuid: 9110, skill: 6511, name: "冰冻抗性药水", info: "全体友方冰冻抗性提升 50%,持续 5 秒", cost: 4, weight: 10 },
// ==================== 高级档buff_value 覆写,复用同一技能底座) ====================
{ uuid: 9201, skill: 6502, name: "高级再生药水", info: "全体友方每秒回复 25 生命,持续 5 秒", cost: 0, weight: 8, overrides: { buff_value: 25 } },
{ uuid: 9202, skill: 6503, name: "高级攻击药水", info: "全体友方攻击力提升 80%,持续 5 秒", cost: 0, weight: 8, overrides: { buff_value: 80 } },
{ uuid: 9203, skill: 6504, name: "高级暴击药水", info: "全体友方暴击率提升 50%,持续 5 秒", cost: 0, weight: 8, overrides: { buff_value: 50 } },
{ uuid: 9206, skill: 6507, name: "高级攻速药水", info: "全体友方攻击速度提升 70%,持续 5 秒", cost: 0, weight: 8, overrides: { buff_value: 70 } },
];
/**
* 商品/药品卡池(已构建为标准 CardConfig[])。
* 所有商品卡统一配置:
* - type: Skill复用技能卡体系由 MissSkillsComp 统一处理)
* - kind: Potion药水类用于区分
* - trigger_type: Instant即时触发只生效一次
* - t_times: 1只触发一次
* - is_inst: true即时起效
*/
export const ItemCardList: CardConfig[] = ItemCardData.map(data => ({
uuid: data.uuid,
skill: data.skill,
type: CardType.Skill,
cost: data.cost,
weight: data.weight,
pool_lv: CardLV.LV1,
kind: CKind.Potion,
card_lv: 1,
name: data.name,
info: data.info,
is_inst: true,
t_times: 1,
t_inv: 0,
keep_waves: 0,
overrides: data.overrides,
trigger_type: CardTriggerType.Instant,
}));
/**
* 按权重抽取一张商品卡(带权重随机)。
*/
function weightedPick(cards: CardConfig[]): CardConfig | null {
if (cards.length === 0) return null;
const totalWeight = cards.reduce((total, card) => total + (card.weight ?? 0), 0);
let random = Math.random() * totalWeight;
for (const card of cards) {
random -= (card.weight ?? 0);
if (random <= 0) return card;
}
return cards[cards.length - 1];
}
/**
* 按权重抽取 N 张商品卡unique 保证一次刷新内不重复,不足时允许重复补齐)。
* @param count 需要抽取的数量
*/
export function drawItemCards(count: number): CardConfig[] {
const safeCount = Math.max(0, Math.floor(count));
if (ItemCardList.length === 0 || safeCount <= 0) return [];
const picked: CardConfig[] = [];
let available = [...ItemCardList];
while (picked.length < safeCount) {
if (available.length === 0) break;
const pick = weightedPick(available);
if (!pick) break;
picked.push(pick);
available = available.filter(c => c.uuid !== pick.uuid);
}
// 不足时允许重复补齐
const filled = [...picked];
while (filled.length < safeCount) {
const fallback = weightedPick(ItemCardList);
if (!fallback) break;
filled.push(fallback);
}
return filled;
}
/**
* 按 UUID 查找商品卡配置
* @param uuid 商品卡 UUID
*/
export function findItemCardByUuid(uuid: number): CardConfig | undefined {
return ItemCardList.find(e => e.uuid === uuid);
}