refactor(map): 移除所有卡牌购买的扣费逻辑,改为免费获取
统一调整四个卡牌组件的购买流程,删除MissionEconomy导入和扣费校验代码,更新注释说明当前为免费购买模式,简化日志输出内容
This commit is contained in:
@@ -25,10 +25,6 @@ import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { FieldSkillType } from "../common/config/SkillSet";
|
||||
import { FieldSkillHelper } from "../hero/FieldSkillHelper";
|
||||
import { MissionEconomy } from "./MissionEconomy";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
@@ -538,10 +534,11 @@ export class CHeroComp extends CCComp {
|
||||
* 购买点击处理:
|
||||
* 1. 播放按钮点击回弹动画。
|
||||
* 2. 英雄卡先通过 UseHeroCard 事件做数量上限校验(guard 模式,可被取消)。
|
||||
* 3. 扣除金币(失败则提示并中止)。
|
||||
* 4. 按卡牌类型分发效果:英雄卡 → CallHero 召唤英雄;特殊卡 → UseSpecialCard。
|
||||
* 5. 派发 CardUsed 通知 MissionCardComp 刷新英雄卡池。
|
||||
* 6. 标记已购买,隐藏购买按钮。
|
||||
* 3. 按卡牌类型分发效果:英雄卡 → CallHero 召唤英雄;特殊卡 → UseSpecialCard。
|
||||
* 4. 派发 CardUsed 通知 MissionCardComp 刷新英雄卡池。
|
||||
* 5. 标记已购买,隐藏购买按钮。
|
||||
*
|
||||
* 注:购买不花费金币(免费获取),原扣费逻辑已移除。
|
||||
*/
|
||||
private onBuyClick() {
|
||||
if (!this.cardData || this.isPurchased) return;
|
||||
@@ -564,22 +561,6 @@ export class CHeroComp extends CCComp {
|
||||
if (guard.cancel) return;
|
||||
}
|
||||
|
||||
// 扣费(英雄卡享受驻场"购买优惠"折扣)
|
||||
let cost = this.cardData.cost ?? 0;
|
||||
if (this.cardData.type === CardType.Hero) {
|
||||
const discount = FieldSkillHelper.getFieldSkillTotalValue(FieldSkillType.BuyDiscount);
|
||||
cost = Math.max(0, cost - discount);
|
||||
}
|
||||
const success = MissionEconomy.spendCoin(Math.floor(cost));
|
||||
if (!success) {
|
||||
oops.message.dispatchEvent(GameEvent.ShowSmallTip, "buy_coin");
|
||||
mLogger.log(this.debugMode, "CHeroComp", "purchase failed: not enough coin", {
|
||||
uuid: this.cardData.uuid,
|
||||
cost
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
smc.vmdata.scores.refresh_hit_count++;
|
||||
|
||||
const used = this.cardData;
|
||||
@@ -609,8 +590,7 @@ export class CHeroComp extends CCComp {
|
||||
|
||||
mLogger.log(this.debugMode, "CHeroComp", "hero card purchased", {
|
||||
uuid: used.uuid,
|
||||
type: used.type,
|
||||
cost
|
||||
type: used.type
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import { buildEquipRich } from "../common/config/HeroSkillDesc";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { getCardIconId, setSpriteFrame } from "../common/CardIconHelper";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { MissionEconomy } from "./MissionEconomy";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -327,19 +326,7 @@ export class EquipListComp extends CCComp {
|
||||
|
||||
oops.audio.playEffect("music/button");
|
||||
|
||||
// 扣费
|
||||
const cost = this.cardData.cost ?? 0;
|
||||
const success = MissionEconomy.spendCoin(cost);
|
||||
if (!success) {
|
||||
oops.message.dispatchEvent(GameEvent.ShowSmallTip, "buy_coin");
|
||||
mLogger.log(this.debugMode, "EquipListComp", "purchase failed: not enough coin", {
|
||||
uuid: this.cardData.uuid,
|
||||
cost
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 派发 UseEquipCard,装备生效流程由 MissEquipComp 接收处理
|
||||
// 购买不花费金币(免费获取),直接派发装备生效事件
|
||||
oops.message.dispatchEvent(GameEvent.UseEquipCard, this.cardData);
|
||||
|
||||
// 播放购买动画(卡牌放大 + 淡出)
|
||||
@@ -350,8 +337,7 @@ export class EquipListComp extends CCComp {
|
||||
oops.message.dispatchEvent(GameEvent.CardUsed, this);
|
||||
|
||||
mLogger.log(this.debugMode, "EquipListComp", "equipment purchased", {
|
||||
uuid: this.cardData.uuid,
|
||||
cost
|
||||
uuid: this.cardData.uuid
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import { buildCardDescRich, buildEquipRich } from "../common/config/HeroSkillDes
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { getCardIconId, setSpriteFrame } from "../common/CardIconHelper";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { MissionEconomy } from "./MissionEconomy";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -340,19 +339,7 @@ export class ItemListComp extends CCComp {
|
||||
|
||||
oops.audio.playEffect("music/button");
|
||||
|
||||
// 扣费
|
||||
const cost = this.cardData.cost ?? 0;
|
||||
const success = MissionEconomy.spendCoin(cost);
|
||||
if (!success) {
|
||||
oops.message.dispatchEvent(GameEvent.ShowSmallTip, "buy_coin");
|
||||
mLogger.log(this.debugMode, "ItemListComp", "purchase failed: not enough coin", {
|
||||
uuid: this.cardData.uuid,
|
||||
cost
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据类型派发对应事件
|
||||
// 购买不花费金币(免费获取),直接根据类型派发对应事件
|
||||
const isEquip = this.cardData.trigger_type === CardTriggerType.Field;
|
||||
const isPotion = this.cardData.kind === CKind.Potion;
|
||||
|
||||
@@ -360,23 +347,20 @@ export class ItemListComp extends CCComp {
|
||||
// 装备:被动驻场,由 MissEquipComp 处理
|
||||
oops.message.dispatchEvent(GameEvent.UseEquipCard, this.cardData);
|
||||
mLogger.log(this.debugMode, "ItemListComp", "equipment purchased", {
|
||||
uuid: this.cardData.uuid,
|
||||
cost
|
||||
uuid: this.cardData.uuid
|
||||
});
|
||||
} else if (isPotion) {
|
||||
// 商品/药品:一次性 buff 技能,由 MissSkillsComp 处理
|
||||
oops.message.dispatchEvent(GameEvent.UseItemCard, this.cardData);
|
||||
mLogger.log(this.debugMode, "ItemListComp", "item purchased", {
|
||||
uuid: this.cardData.uuid,
|
||||
skill: this.cardData.skill,
|
||||
cost
|
||||
skill: this.cardData.skill
|
||||
});
|
||||
} else {
|
||||
// 默认走技能卡流程
|
||||
oops.message.dispatchEvent(GameEvent.UseSkillCard, this.cardData);
|
||||
mLogger.log(this.debugMode, "ItemListComp", "card purchased", {
|
||||
uuid: this.cardData.uuid,
|
||||
cost
|
||||
uuid: this.cardData.uuid
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import { oops } from "db://oops-framework/core/Oops";
|
||||
import { getCardIconId, setSpriteFrame } from "../common/CardIconHelper";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { MissionEconomy } from "./MissionEconomy";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -352,9 +351,10 @@ export class SCardComp extends CCComp {
|
||||
|
||||
/**
|
||||
* 购买点击处理:
|
||||
* 1. 扣除金币(失败则提示并中止)。
|
||||
* 2. 派发 UseSkillCard 事件,触发技能生效流程。
|
||||
* 3. 播放购买动画,购买后可继续购买(购买按钮保持可见)。
|
||||
* 1. 派发 UseSkillCard 事件,触发技能生效流程。
|
||||
* 2. 播放购买动画,购买后可继续购买(购买按钮保持可见)。
|
||||
*
|
||||
* 注:购买不花费金币(免费获取),原扣费逻辑已移除。
|
||||
*/
|
||||
private onBuyClick() {
|
||||
if (!this.cardData) return;
|
||||
@@ -364,18 +364,6 @@ export class SCardComp extends CCComp {
|
||||
|
||||
oops.audio.playEffect("music/button");
|
||||
|
||||
// 扣费
|
||||
const cost = this.cardData.cost ?? 0;
|
||||
const success = MissionEconomy.spendCoin(cost);
|
||||
if (!success) {
|
||||
oops.message.dispatchEvent(GameEvent.ShowSmallTip, "buy_coin");
|
||||
mLogger.log(this.debugMode, "SCardComp", "purchase failed: not enough coin", {
|
||||
uuid: this.cardData.uuid,
|
||||
cost
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
smc.vmdata.scores.refresh_hit_count++;
|
||||
|
||||
// 派发 UseSkillCard,技能生效流程由 MissSkillsComp 接收处理
|
||||
@@ -389,8 +377,7 @@ export class SCardComp extends CCComp {
|
||||
oops.message.dispatchEvent(GameEvent.CardUsed, this);
|
||||
|
||||
mLogger.log(this.debugMode, "SCardComp", "skill card purchased", {
|
||||
uuid: this.cardData.uuid,
|
||||
cost
|
||||
uuid: this.cardData.uuid
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user