Files
pixelheros/assets/script/game/common/config/ICardSet.ts
pan eb4b370533 refactor: 重构击退机制,将概率改为距离增量
1. 调整近战默认攻击距离从150改为100
2. 将击退相关属性从概率改为击退距离增量,同步更新所有配置、UI显示和技能描述
3. 移除旧的击退概率判定逻辑,改为直接应用击退距离增量
4. 优化受击击退的处理流程,统一参数传递
2026-08-13 11:09:37 +08:00

133 lines
6.3 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 / CardTriggerType
* - SkillSet —— SkillOverrides
*/
import { CardConfig, CardType, CKind, CardTriggerType } from "./CardSet";
import { SkillOverrides } from "./SkillSet";
/** 商品/药品卡原始数据(平铺字段,构建后转为 CardConfig */
interface ItemCardRaw {
uuid: number;
skill: number; // 关联的技能 UUIDbuff 技能)
name: string;
info: string;
icon?: string; // 图标ID对应 ui6 图集 frame 名)
cost: number; // 购买价格
weight: number; // 抽取权重
overrides?: SkillOverrides; // 技能参数覆写(如自定义治疗量、护盾值等)
}
const ItemCardData: ItemCardRaw[] = [
// ==================== 一次性回血(计时性 HoT5s ====================
{ uuid: 9101, skill: 6502, icon: "Sub_Item-FA_WP_Sub_Potion_001_Green", name: "再生药水", info: "全体友方持续回复生命", cost: 0, weight: 20 },
// ==================== 计时性强化(统一 5s ====================
{ uuid: 9102, skill: 6503, icon: "Sub_Item-FA_WP_Sub_Potion_001_Red", name: "攻击药水", info: "全体友方攻击力提升", cost: 0, weight: 15 },
{ uuid: 9103, skill: 6504, icon: "Sub_Item-FA_WP_Sub_Potion_001_Yellow", name: "暴击药水", info: "全体友方暴击率提升", cost: 0, weight: 15 },
{ uuid: 9104, skill: 6505, icon: "Sub_Item-FA_WP_Sub_Potion_001_Purple", name: "击退药水", info: "全体友方击退距离提升", cost: 0, weight: 12 },
{ uuid: 9105, skill: 6506, icon: "Sub_Item-FA_WP_Sub_Potion_001_Blue", name: "穿透药水", info: "全体友方穿透概率提升", cost: 0, weight: 12 },
{ uuid: 9106, skill: 6507, icon: "Sub_Item-FA_WP_Sub_Potion_001_Red", name: "攻速药水", info: "全体友方攻击速度提升", cost: 0, weight: 15 },
{ uuid: 9107, skill: 6508, icon: "Sub_Item-FA_WP_Sub_Potion_001_Purple", name: "风怒药水", info: "全体友方风怒概率提升", cost: 0, weight: 12 },
{ uuid: 9108, skill: 6509, icon: "Sub_Item-FA_WP_Sub_Potion_001_Purple", name: "击晕药水", info: "全体友方击晕概率提升", cost: 0, weight: 12 },
{ uuid: 9109, skill: 6510, icon: "Sub_Item-FA_WP_Sub_Potion_001_Blue", name: "击晕抗性药水", info: "全体友方击晕抗性提升", cost: 4, weight: 10 },
{ uuid: 9110, skill: 6511, icon: "Sub_Item-FA_WP_Sub_Potion_001_Blue", name: "冰冻抗性药水", info: "全体友方冰冻抗性提升", cost: 4, weight: 10 },
// ==================== 高级档buff_value 覆写,复用同一技能底座) ====================
{ uuid: 9201, skill: 6502, icon: "Sub_Item-FA_WP_Sub_Potion_002_Green", name: "高级再生药水", info: "全体友方持续回复生命", cost: 0, weight: 8, overrides: { buff_value: 25 } },
{ uuid: 9202, skill: 6503, icon: "Sub_Item-FA_WP_Sub_Potion_002_Red", name: "高级攻击药水", info: "全体友方攻击力提升", cost: 0, weight: 8, overrides: { buff_value: 80 } },
{ uuid: 9203, skill: 6504, icon: "Sub_Item-FA_WP_Sub_Potion_002_Yellow", name: "高级暴击药水", info: "全体友方暴击率提升", cost: 0, weight: 8, overrides: { buff_value: 50 } },
{ uuid: 9206, skill: 6507, icon: "Sub_Item-FA_WP_Sub_Potion_002_Red", name: "高级攻速药水", info: "全体友方攻击速度提升", 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);
}