refactor(map): 移除卡牌购买限购逻辑,改为可重复购买

1. 重构SCardComp、ItemListComp、EquipListComp的isPurchased注释与逻辑,不再用于限制重复购买
2. 删除MissionCardComp中的跨波次购买记录集合与相关监听、标记逻辑
3. 调整购买按钮逻辑,购买后保持可见不再隐藏
This commit is contained in:
pan
2026-08-03 17:25:31 +08:00
parent d12f545060
commit 3fe6325830
4 changed files with 20 additions and 80 deletions

View File

@@ -70,7 +70,7 @@ export class EquipListComp extends CCComp {
/** 当前装备的卡牌配置 */
private cardData: CardConfig | null = null;
/** 是否已购买 */
/** 购买/逝去动画播放中标记(仅用于跳过新卡的普通逝去动画,不影响再次购买 */
private isPurchased: boolean = false;
/** 透明度组件(用于淡入淡出动画) */
private opacityComp: UIOpacity | null = null;
@@ -312,15 +312,15 @@ export class EquipListComp extends CCComp {
/**
* 购买点击处理:
* 1. 扣除金币(失败则提示并中止)。
* 2. 派发 UseSkillCard 事件,触发与技能卡相同的生效流程。
* 3. 标记已购买,隐藏购买按钮
* 2. 派发 UseEquipCard 事件,触发装备生效流程。
* 3. 播放购买动画,购买后可继续购买(购买按钮保持可见)
*
* 装备生效链路:
* UseSkillCard → MissSkillsComp.addSkill() → SBox ECS 实体 → SkillBoxComp(Field 类型)
* UseEquipCard → MissEquipComp.addSkill() → SBox ECS 实体 → SkillBoxComp(Field 类型)
* → FieldSkillHelper.getFieldSkillTotalValue() 全局聚合属性加成
*/
private onBuyClick() {
if (!this.cardData || this.isPurchased) return;
if (!this.cardData) return;
// 播放按钮点击回弹动画
this.playBtnClickAnim();
@@ -342,13 +342,8 @@ export class EquipListComp extends CCComp {
// 派发 UseEquipCard装备生效流程由 MissEquipComp 接收处理
oops.message.dispatchEvent(GameEvent.UseEquipCard, this.cardData);
// 标记已购买
this.isPurchased = true;
if (this.buy_node) {
this.buy_node.active = false;
}
// 播放购买动画(卡牌放大 + 淡出)
this.isPurchased = true;
this.playPurchaseAnim();
// 派发 CardUsed 事件,触发整池刷新
@@ -360,12 +355,9 @@ export class EquipListComp extends CCComp {
});
}
/** 标记为已购买状态(用于跨波次保持购买记录 */
/** 标记购买动画播放中(供外部在刷新前保持动画状态,不再用于限购 */
setPurchased(): void {
this.isPurchased = true;
if (this.buy_node) {
this.buy_node.active = false;
}
}
/** ECS 组件移除时销毁节点 */

View File

@@ -72,7 +72,7 @@ export class ItemListComp extends CCComp {
/** 当前商品的卡牌配置 */
private cardData: CardConfig | null = null;
/** 是否已购买 */
/** 购买/逝去动画播放中标记(仅用于跳过新卡的普通逝去动画,不影响再次购买 */
private isPurchased: boolean = false;
/** 透明度组件(用于淡入淡出动画) */
private opacityComp: UIOpacity | null = null;
@@ -330,10 +330,10 @@ export class ItemListComp extends CCComp {
* 2. 根据卡牌类型派发对应事件:
* - 装备卡trigger_type=Field→ UseEquipCard → MissEquipComp
* - 商品/药品卡kind=Potion→ UseItemCard → MissSkillsComp一次性 buff 技能)
* 3. 标记已购买,隐藏购买按钮
* 3. 播放购买动画,购买后可继续购买(购买按钮保持可见)
*/
private onBuyClick() {
if (!this.cardData || this.isPurchased) return;
if (!this.cardData) return;
// 播放按钮点击回弹动画
this.playBtnClickAnim();
@@ -380,25 +380,17 @@ export class ItemListComp extends CCComp {
});
}
// 标记已购买
this.isPurchased = true;
if (this.buy_node) {
this.buy_node.active = false;
}
// 播放购买动画(卡牌放大 + 淡出)
this.isPurchased = true;
this.playPurchaseAnim();
// 派发 CardUsed 事件,触发整池刷新
oops.message.dispatchEvent(GameEvent.CardUsed, this);
}
/** 标记为已购买状态(用于跨波次保持购买记录 */
/** 标记购买动画播放中(供外部在刷新前保持动画状态,不再用于限购 */
setPurchased(): void {
this.isPurchased = true;
if (this.buy_node) {
this.buy_node.active = false;
}
}
/** ECS 组件移除时销毁节点 */

View File

@@ -178,10 +178,6 @@ export class MissionCardComp extends CCComp {
private itemCardComps: ItemListComp[] = [];
/** 是否已召唤过英雄(用于控制其他面板按钮是否可点击) */
private hasCalledHero: boolean = false;
/** 已购买装备的 UUID 集合(跨波次保持,防止重复购买) */
private purchasedEquipUuids: Set<number> = new Set();
/** 已购买商品的 UUID 集合(跨波次保持,防止重复购买) */
private purchasedItemUuids: Set<number> = new Set();
// ======================== 面板轮播状态 ========================
@@ -297,15 +293,13 @@ export class MissionCardComp extends CCComp {
});
this.dispatchCardsToSlots(cards);
// 重置购买记录并填充装备商店
this.purchasedEquipUuids.clear();
// 填充装备商店(不限购)
this.populateEquipments();
// 填充技能卡槽英雄三槽模式sCardPrefab 实例化 3 个槽位)
this.populateSkillCards();
// 重置商品购买记录并填充商品商店
this.purchasedItemUuids.clear();
// 填充商品商店(不限购)
this.populateShopItems();
// 重置英雄召唤状态(游戏刚开始时其他面板不可点击)
@@ -373,10 +367,6 @@ export class MissionCardComp extends CCComp {
oops.message.on(GameEvent.HeroSell, this.onHeroSell, this);
oops.message.on(GameEvent.HeroLvUp, this.onHeroLvUp, this);
oops.message.on(GameEvent.UseHeroCard, this.onUseHeroCard, this);
// 监听装备购买事件,追踪已购记录
oops.message.on(GameEvent.UseEquipCard, this.onUseEquipCard, this);
// 监听商品购买事件,追踪已购记录
oops.message.on(GameEvent.UseItemCard, this.onUseItemCard, this);
oops.message.on(GameEvent.UseSpecialCard, this.onUseSpecialCard, this);
oops.message.on(GameEvent.ShowSmallTip, this.onShowSmallTip, this);
oops.message.on(GameEvent.CardUsed, this.onCardUsed, this);
@@ -556,10 +546,6 @@ export class MissionCardComp extends CCComp {
if (i < targetCount) {
comp.applyCardData(items[i]);
// 已购买的商品标记为已购
if (this.purchasedItemUuids.has(items[i].uuid)) {
comp.setPurchased();
}
} else {
// 多余槽位清空
comp.applyCardData(null as unknown as CardConfig);
@@ -613,21 +599,7 @@ export class MissionCardComp extends CCComp {
}
}
/** 装备购买事件回调:记录已购 UUID防止重复购买 */
private onUseEquipCard(event: string, args: any) {
const usedCard = args as CardConfig;
if (usedCard) {
this.purchasedEquipUuids.add(usedCard.uuid);
}
}
/** 商品购买事件回调:记录已购 UUID防止重复购买 */
private onUseItemCard(event: string, args: any) {
const usedCard = args as CardConfig;
if (usedCard) {
this.purchasedItemUuids.add(usedCard.uuid);
}
}
// ======================== 装备/商品购买事件已移除限购逻辑 ========================
/** 解除按钮监听,避免节点销毁后回调泄漏 */
private unbindEvents() {
@@ -638,8 +610,6 @@ export class MissionCardComp extends CCComp {
oops.message.off(GameEvent.HeroSell, this.onHeroSell, this);
oops.message.off(GameEvent.HeroLvUp, this.onHeroLvUp, this);
oops.message.off(GameEvent.UseHeroCard, this.onUseHeroCard, this);
oops.message.off(GameEvent.UseEquipCard, this.onUseEquipCard, this);
oops.message.off(GameEvent.UseItemCard, this.onUseItemCard, this);
oops.message.off(GameEvent.UseSpecialCard, this.onUseSpecialCard, this);
oops.message.off(GameEvent.ShowSmallTip, this.onShowSmallTip, this);
oops.message.off(GameEvent.CardUsed, this.onCardUsed, this);
@@ -1109,10 +1079,6 @@ export class MissionCardComp extends CCComp {
if (i < targetCount) {
comp.applyCardData(equips[i]);
// 已购买的装备标记为已购
if (this.purchasedEquipUuids.has(equips[i].uuid)) {
comp.setPurchased();
}
} else {
// 多余槽位清空
comp.applyCardData(null as unknown as CardConfig);
@@ -1970,8 +1936,6 @@ export class MissionCardComp extends CCComp {
this.cardComps = [];
this.heroBoxComps = [];
this.skillCardComps = [];
this.purchasedEquipUuids.clear();
this.purchasedItemUuids.clear();
if (this.node && this.node.isValid) {
this.node.destroy();

View File

@@ -71,7 +71,7 @@ export class SCardComp extends CCComp {
/** 当前技能的卡牌配置 */
private cardData: CardConfig | null = null;
/** 是否已购买 */
/** 购买/逝去动画播放中标记(仅用于跳过新卡的普通逝去动画,不影响再次购买 */
private isPurchased: boolean = false;
/** 透明度组件(用于淡入淡出动画) */
private opacityComp: UIOpacity | null = null;
@@ -354,10 +354,10 @@ export class SCardComp extends CCComp {
* 购买点击处理:
* 1. 扣除金币(失败则提示并中止)。
* 2. 派发 UseSkillCard 事件,触发技能生效流程。
* 3. 标记已购买,隐藏购买按钮
* 3. 播放购买动画,购买后可继续购买(购买按钮保持可见)
*/
private onBuyClick() {
if (!this.cardData || this.isPurchased) return;
if (!this.cardData) return;
// 播放按钮点击回弹动画
this.playBtnClickAnim();
@@ -381,13 +381,8 @@ export class SCardComp extends CCComp {
// 派发 UseSkillCard技能生效流程由 MissSkillsComp 接收处理
oops.message.dispatchEvent(GameEvent.UseSkillCard, this.cardData);
// 标记已购买
this.isPurchased = true;
if (this.buy_node) {
this.buy_node.active = false;
}
// 播放购买动画(卡牌放大 + 淡出)
this.isPurchased = true;
this.playPurchaseAnim();
// 派发 CardUsed 事件,通知 MissionCardComp 刷新技能卡池
@@ -399,12 +394,9 @@ export class SCardComp extends CCComp {
});
}
/** 标记为已购买状态 */
/** 标记购买动画播放中(供外部在刷新前保持动画状态,不再用于限购) */
setPurchased(): void {
this.isPurchased = true;
if (this.buy_node) {
this.buy_node.active = false;
}
}
/**