/** * @file ICardSet.ts * @description 商品/药品卡池独立配置 * * 职责: * 定义所有商品/药品卡的静态数据,与技能卡池(SCardSet)和装备卡池(EquipSet)分离。 * 商品/药品为一次性消耗品,购买后立即触发一次 buff 效果(如治疗、护盾、属性强化等)。 * * 设计: * - 参考 SCardSet.ts 结构,但商品是"只触发一次的 buff 技能",而非"多次触发的攻击技能"。 * - trigger_type 统一为 Instant(即时触发)。 * - t_times 固定为 1(只触发一次)。 * - kind 为 CKind.Potion(药水类)。 * * 依赖: * - CardSet —— CardConfig / CardType / CKind / CardTriggerType * - SkillSet —— SkillOverrides */ import { CardConfig, CardType, CKind, CardTriggerType } from "./CardSet"; import { SkillOverrides } from "./SkillSet"; /** 商品/药品卡原始数据(平铺字段,构建后转为 CardConfig) */ interface ItemCardRaw { uuid: number; skill: number; // 关联的技能 UUID(buff 技能) name: string; info: string; icon?: string; // 图标ID(对应 ui6 图集 frame 名) cost: number; // 购买价格 weight: number; // 抽取权重 overrides?: SkillOverrides; // 技能参数覆写(如自定义治疗量、护盾值等) } const ItemCardData: ItemCardRaw[] = [ // ==================== 一次性回血(计时性 HoT,5s) ==================== { uuid: 9101, skill: 6502, icon: "Sub_Item-FA_WP_Sub_Potion_001_Green", name: "再生药水", info: "全体友方每秒回复生命,持续 5 秒", cost: 0, weight: 20 }, // ==================== 计时性强化(统一 5s) ==================== { uuid: 9102, skill: 6503, icon: "Sub_Item-FA_WP_Sub_Potion_001_Red", name: "攻击药水", info: "全体友方攻击力提升 50%,持续 5 秒", cost: 0, weight: 15 }, { uuid: 9103, skill: 6504, icon: "Sub_Item-FA_WP_Sub_Potion_001_Yellow", name: "暴击药水", info: "全体友方暴击率提升 30%,持续 5 秒", cost: 0, weight: 15 }, { uuid: 9104, skill: 6505, icon: "Sub_Item-FA_WP_Sub_Potion_001_Purple", name: "击退药水", info: "全体友方击退概率提升 30%,持续 5 秒", cost: 0, weight: 12 }, { uuid: 9105, skill: 6506, icon: "Sub_Item-FA_WP_Sub_Potion_001_Blue", name: "穿透药水", info: "全体友方穿透概率提升 30%,持续 5 秒", cost: 0, weight: 12 }, { uuid: 9106, skill: 6507, icon: "Sub_Item-FA_WP_Sub_Potion_001_Red", name: "攻速药水", info: "全体友方攻击速度提升 40%,持续 5 秒", cost: 0, weight: 15 }, { uuid: 9107, skill: 6508, icon: "Sub_Item-FA_WP_Sub_Potion_001_Purple", name: "风怒药水", info: "全体友方风怒概率提升 20%,持续 5 秒", cost: 0, weight: 12 }, { uuid: 9108, skill: 6509, icon: "Sub_Item-FA_WP_Sub_Potion_001_Purple", name: "击晕药水", info: "全体友方击晕概率提升 30%,持续 5 秒", cost: 0, weight: 12 }, { uuid: 9109, skill: 6510, icon: "Sub_Item-FA_WP_Sub_Potion_001_Blue", name: "击晕抗性药水", info: "全体友方击晕抗性提升 50%,持续 5 秒", cost: 4, weight: 10 }, { uuid: 9110, skill: 6511, icon: "Sub_Item-FA_WP_Sub_Potion_001_Blue", name: "冰冻抗性药水", info: "全体友方冰冻抗性提升 50%,持续 5 秒", cost: 4, weight: 10 }, // ==================== 高级档(buff_value 覆写,复用同一技能底座) ==================== { uuid: 9201, skill: 6502, icon: "Sub_Item-FA_WP_Sub_Potion_002_Green", name: "高级再生药水", info: "全体友方每秒回复 25 生命,持续 5 秒", cost: 0, weight: 8, overrides: { buff_value: 25 } }, { uuid: 9202, skill: 6503, icon: "Sub_Item-FA_WP_Sub_Potion_002_Red", name: "高级攻击药水", info: "全体友方攻击力提升 80%,持续 5 秒", cost: 0, weight: 8, overrides: { buff_value: 80 } }, { uuid: 9203, skill: 6504, icon: "Sub_Item-FA_WP_Sub_Potion_002_Yellow", name: "高级暴击药水", info: "全体友方暴击率提升 50%,持续 5 秒", cost: 0, weight: 8, overrides: { buff_value: 50 } }, { uuid: 9206, skill: 6507, icon: "Sub_Item-FA_WP_Sub_Potion_002_Red", 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, kind: CKind.Potion, card_lv: 1, icon: data.icon, 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); }