refactor(map): 移除卡牌购买限购逻辑,改为可重复购买
1. 重构SCardComp、ItemListComp、EquipListComp的isPurchased注释与逻辑,不再用于限制重复购买 2. 删除MissionCardComp中的跨波次购买记录集合与相关监听、标记逻辑 3. 调整购买按钮逻辑,购买后保持可见不再隐藏
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user