feat(天赋系统): 实现天赋效果并应用至相关游戏系统

- 在 MissionCardComp 中应用 RefreshDiscount 天赋以减少刷新消耗
- 在 CardComp 中应用 BuyDiscount 天赋以减少英雄购买消耗
- 在 HInfoComp 中应用 SellBonus 天赋以增加英雄出售收益
- 统一 TalentType 枚举类型,增强类型安全性
- 更新 SingletonModuleComp 中 talents 数据结构以支持类型化
- 修改 HeroAttrsComp.getTalentValue 方法参数类型为 TalentType
This commit is contained in:
panw
2026-04-28 15:34:58 +08:00
parent 1a45c87e70
commit 95ea36651e
7 changed files with 52 additions and 26 deletions

View File

@@ -30,6 +30,8 @@ import { GameEvent } from "../common/config/GameEvent";
import { oops } from "db://oops-framework/core/Oops";
import { smc } from "../common/SingletonModuleComp";
import { UIID } from "../common/config/GameUIConfig";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { TalentType } from "../common/config/TalentSet";
@@ -272,7 +274,14 @@ export class CardComp extends CCComp {
this.cardData = data;
this.card_uuid = data.uuid;
this.card_type = data.type;
this.card_cost = data.cost;
let baseCost = data.cost ?? 0;
if (this.card_type === CardType.Hero) {
const discount = HeroAttrsComp.getTalentValue(TalentType.BuyDiscount);
baseCost = Math.max(0, baseCost - discount);
}
this.card_cost = Math.floor(baseCost);
this.node.active = true;
this.isEnlarged = false;
this.applyCardUI();
@@ -300,7 +309,7 @@ export class CardComp extends CCComp {
*/
useCard(): CardConfig | null {
if (!this.cardData || this.isUsing) return null;
const cardCost = Math.max(0, Math.floor(this.cardData.cost ?? 0));
const cardCost = this.card_cost;
const currentCoin = this.getMissionCoin();
// 金币不足 → 提示并回弹
if (currentCoin < cardCost) {