From e243b7410ed4537b8807097e13e69999780df75d Mon Sep 17 00:00:00 2001 From: humingxing <930621236@qq.com> Date: Fri, 16 Oct 2026 19:46:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prefab/weapon/宝石掉落.prefab | 4 +- assets/bundles/first/config/Text.json | 4 +- .../script/battle/ai/decision/AiBoardProbe.ts | 6 ++- assets/script/battle/bag/BattleBagSession.ts | 35 ++++++++++++-- .../script/battle/view/MapDragGuideHelper.ts | 48 +++++++++++++++++-- assets/script/ui/BattleGame/UIBattleGame.ts | 35 ++++++++++++++ 6 files changed, 118 insertions(+), 14 deletions(-) diff --git a/assets/bundles/battleHero/prefab/weapon/宝石掉落.prefab b/assets/bundles/battleHero/prefab/weapon/宝石掉落.prefab index 15dcb6c..218f304 100644 --- a/assets/bundles/battleHero/prefab/weapon/宝石掉落.prefab +++ b/assets/bundles/battleHero/prefab/weapon/宝石掉落.prefab @@ -49,8 +49,8 @@ }, "_lscale": { "__type__": "cc.Vec3", - "x": 1, - "y": 1, + "x": 0.5, + "y": 0.5, "z": 1 }, "_mobility": 0, diff --git a/assets/bundles/first/config/Text.json b/assets/bundles/first/config/Text.json index 95e805a..345862e 100644 --- a/assets/bundles/first/config/Text.json +++ b/assets/bundles/first/config/Text.json @@ -135,12 +135,12 @@ "id": 3001, "type": 12, "level": 0, - "weight": 150 + "weight": 15 }, { "id": 3002, "type": 13, "level": 0, - "weight": 50 + "weight": 5 } ] \ No newline at end of file diff --git a/assets/script/battle/ai/decision/AiBoardProbe.ts b/assets/script/battle/ai/decision/AiBoardProbe.ts index f4a5377..6a2b542 100644 --- a/assets/script/battle/ai/decision/AiBoardProbe.ts +++ b/assets/script/battle/ai/decision/AiBoardProbe.ts @@ -283,17 +283,19 @@ export class AiBoardProbe { } } + const mapOwner = toolType === 13 ? session.resolveOpponentBagSession() : session; + if (!mapOwner) continue; const grids = this._listActiveGrids(map); for (let g = 0; g < grids.length; g++) { const mg = grids[g]; - const tile = session.merge.map.getTile(mg.Index); - if (!tile || tile.battleCardKind) continue; const ownCamp = session.validator.isAllowedCampForPlace(mg.Index); if (toolType === 13) { if (ownCamp) continue; } else if (!ownCamp) { continue; } + const tile = mapOwner.merge.map.getTile(mg.Index); + if (!tile || tile.battleCardKind) continue; if (!this._isBagToolDigitTarget(provider, tile.weapon2Id, tile.level ?? 1, toolType)) continue; const score = this._scoreBattleCardTarget(provider, tile.weapon2Id, tile.level ?? 1, true, mg.Index); if (!best || score > best.score) { diff --git a/assets/script/battle/bag/BattleBagSession.ts b/assets/script/battle/bag/BattleBagSession.ts index 8f15dd8..7433d0e 100644 --- a/assets/script/battle/bag/BattleBagSession.ts +++ b/assets/script/battle/bag/BattleBagSession.ts @@ -109,6 +109,12 @@ export class BattleBagSession { * @param unlockCount 本阵营已完成解锁次数(含本次) */ onBattleBuffSelect: ((ownerPlayerId: number, unlockCount: number) => void) | null = null; + /** + * 功能符改写对方地图字后通知表现(DeploySync / AiMapText)。 + * @param peerOwnerPlayerId 对方 playerId + * @param gridIndex 地图格 + */ + onPeerMapToolApplied: ((peerOwnerPlayerId: number, gridIndex: number) => void) | null = null; constructor(map: MapManager, chapterId: number, session?: import('db://assets/mx/module/battle').BattleSession, bagSlotCount = 5, opts?: { /** 字池所用段位 id;缺省玩家当前段位 */ @@ -156,6 +162,16 @@ export class BattleBagSession { return this._ownerPlayerId; } + /** + * 对方阵营地图字所在 bag(衰弱符等跨阵营工具)。 + */ + resolveOpponentBagSession(): BattleBagSession | null { + const battle = gg.game.CurentBattle; + if (!battle) return null; + const peerId = this._ownerPlayerId === 0 ? 1 : 0; + return battle.getPlayer(peerId)?.bagSession ?? null; + } + /** * 合成升级解除牛魔王损毁。 * @param event 合成事件 @@ -1299,7 +1315,7 @@ export class BattleBagSession { if (!dst) return 'skip'; return this._applyBagToolToBag(source.slotIndex, target.slotIndex, toolType); } - if (!this.merge.map.getTile(target.gridIndex)) { + if (toolType !== 13 && !this.merge.map.getTile(target.gridIndex)) { return PlaceRejectReason.InvalidMerge; } return this._applyBagToolToMap(source.slotIndex, target.gridIndex, toolType); @@ -1334,20 +1350,26 @@ export class BattleBagSession { } /** - * 功能符拖到地图数字(衰弱符仅对方阵营)。 + * 功能符拖到地图数字(衰弱符仅对方阵营,改写对端 merge)。 * @param fromSlot 符槽 * @param gridIndex 目标格 * @param toolType Text.type */ private _applyBagToolToMap(fromSlot: number, gridIndex: number, toolType: number): PlaceRejectReason | null { - const tile = this.merge.map.getTile(gridIndex); - if (!tile || tile.battleCardKind) return PlaceRejectReason.InvalidMerge; const ownCamp = this.validator.isAllowedCampForPlace(gridIndex); if (toolType === 13) { if (ownCamp) return PlaceRejectReason.InvalidMerge; } else if (!ownCamp) { return PlaceRejectReason.WrongCampArea; } + const peer = toolType === 13 ? this.resolveOpponentBagSession() : null; + const mapOwner = peer ?? this; + if (toolType === 13 && !peer) { + console.warn('[BattleBagSession] 衰弱符无对端 bag', this._ownerPlayerId, gridIndex); + return PlaceRejectReason.InvalidMerge; + } + const tile = mapOwner.merge.map.getTile(gridIndex); + if (!tile || tile.battleCardKind) return PlaceRejectReason.InvalidMerge; const level = Math.max(1, Math.floor(Number(tile.level) || 1)); const resolved = this._resolveBagToolResult(Number(tile.weapon2Id) || 0, level, toolType); if (resolved.reason) return resolved.reason; @@ -1356,9 +1378,12 @@ export class BattleBagSession { this.merge.bag.clearSlot(fromSlot); return null; } - const err = this.merge.applyBattleCardToMapTile(gridIndex, resolved.weapon2Id, resolved.level); + const err = mapOwner.merge.applyBattleCardToMapTile(gridIndex, resolved.weapon2Id, resolved.level); if (err) return err; this.merge.bag.clearSlot(fromSlot); + if (peer) { + this.onPeerMapToolApplied?.(peer.ownerPlayerId, gridIndex); + } return null; } diff --git a/assets/script/battle/view/MapDragGuideHelper.ts b/assets/script/battle/view/MapDragGuideHelper.ts index 90bce12..24b1469 100644 --- a/assets/script/battle/view/MapDragGuideHelper.ts +++ b/assets/script/battle/view/MapDragGuideHelper.ts @@ -197,6 +197,10 @@ export class MapDragGuideHelper { if (source && MapDragGuideHelper._canSwapDropOnGrid(session, mg.Index, source)) { return ''; } + if (source) { + const toolMsg = MapDragGuideHelper._bagToolDropFailMessage(session, mg.Index, source); + if (toolMsg) return toolMsg; + } return MapDragGuideHelper.getBlockedDropMessage(session, w2Type, mg); } @@ -394,7 +398,7 @@ export class MapDragGuideHelper { } /** - * Text 功能符可落到合法阵营已占五行字上(衰弱符仅对方)。 + * Text 功能符可落到合法阵营已占五行字上(衰弱符仅对方,读对端 merge)。 * @param session 背包会话 * @param gridIndex 地图格 * @param source 拖拽来源 @@ -408,14 +412,16 @@ export class MapDragGuideHelper { WeaponComposeConfigProvider.instance.load(); const toolType = Math.floor(WeaponComposeConfigProvider.instance.getWeapon2Type(source.weapon2Id)); if (!isBagToolTextType(toolType)) return false; - const tile = session.merge.map.getTile(gridIndex); - if (!tile || tile.battleCardKind) return false; const ownCamp = session.validator.isAllowedCampForPlace(gridIndex); if (toolType === 13) { if (ownCamp) return false; } else if (!ownCamp) { return false; } + const mapOwner = toolType === 13 ? session.resolveOpponentBagSession() : session; + if (!mapOwner) return false; + const tile = mapOwner.merge.map.getTile(gridIndex); + if (!tile || tile.battleCardKind) return false; const dstType = Math.floor(WeaponComposeConfigProvider.instance.getWeapon2Type(tile.weapon2Id)); if (!isElementGlyphType(dstType)) return false; const lv = Math.max(1, Math.floor(Number(tile.level) || 1)); @@ -426,6 +432,42 @@ export class MapDragGuideHelper { return true; } + /** + * 功能符落点失败文案;非功能符或不适用返回空串。 + * @param session 背包会话 + * @param gridIndex 地图格 + * @param source 拖拽来源 + */ + private static _bagToolDropFailMessage( + session: BattleBagSession, + gridIndex: number, + source: DragTileSourceInfo, + ): string { + if (Math.floor(Number(source.battleCardKind) || 0) > 0) return ''; + WeaponComposeConfigProvider.instance.load(); + const toolType = Math.floor(WeaponComposeConfigProvider.instance.getWeapon2Type(source.weapon2Id)); + if (!isBagToolTextType(toolType)) return ''; + const ownCamp = session.validator.isAllowedCampForPlace(gridIndex); + if (toolType === 13) { + if (ownCamp) return rejectReasonToMessage(PlaceRejectReason.InvalidMerge); + } else if (!ownCamp) { + return rejectReasonToMessage(PlaceRejectReason.WrongCampArea); + } + const mapOwner = toolType === 13 ? session.resolveOpponentBagSession() : session; + if (!mapOwner) return rejectReasonToMessage(PlaceRejectReason.InvalidMerge); + const tile = mapOwner.merge.map.getTile(gridIndex); + if (!tile || tile.battleCardKind) return rejectReasonToMessage(PlaceRejectReason.WrongCellKind); + const dstType = Math.floor(WeaponComposeConfigProvider.instance.getWeapon2Type(tile.weapon2Id)); + if (!isElementGlyphType(dstType)) return rejectReasonToMessage(PlaceRejectReason.InvalidMerge); + const lv = Math.max(1, Math.floor(Number(tile.level) || 1)); + if (toolType === 13 && lv <= 1) return '数字已是最小值,无法使用'; + if ((toolType === 10 || toolType === 11) + && lv >= WeaponComposeConfigProvider.instance.getElementMaxLevel(dstType)) { + return '数字已达上限,无法使用!'; + } + return rejectReasonToMessage(PlaceRejectReason.InvalidMerge); + } + private static _canUpgradeDropOnGrid( session: BattleBagSession, gridIndex: number, diff --git a/assets/script/ui/BattleGame/UIBattleGame.ts b/assets/script/ui/BattleGame/UIBattleGame.ts index 3cb8f85..807d256 100644 --- a/assets/script/ui/BattleGame/UIBattleGame.ts +++ b/assets/script/ui/BattleGame/UIBattleGame.ts @@ -422,6 +422,7 @@ export class UIBattleGame extends Auto_BattleGame { } this._bindUnlockCoinFly(battle); this._bindBattleBuffSelect(battle); + this._bindPeerMapToolApplied(battle); this._campHpBar.bind(battle, map); getBattleGameMonsterCrisisHintPresenter().bind(battle, map); this._firstGuide.bind(this.ui_guide, battle.bagSession, this.btnRefresh); @@ -879,6 +880,38 @@ export class UIBattleGame extends Auto_BattleGame { } } + /** + * 衰弱符等改写对方地图后:刷新对端 DeploySync / 字块视图。 + * @param battle 战斗 + */ + private _bindPeerMapToolApplied(battle: ProjectBattleHandle): void { + const handler = this._onPeerMapToolApplied; + if (battle.bagSession) { + battle.bagSession.onPeerMapToolApplied = handler; + } + const aiBag = AiBattleBridge.inst.aiBagSession; + if (aiBag) { + aiBag.onPeerMapToolApplied = handler; + } + } + + /** + * @param peerOwnerPlayerId 被改写方 playerId + * @param gridIndex 地图格 + */ + private readonly _onPeerMapToolApplied = (peerOwnerPlayerId: number, gridIndex: number): void => { + if (peerOwnerPlayerId === AiHeadlessBagHost.AI_PLAYER_ID) { + const bridge = AiBattleBridge.inst; + bridge.aiDeploySync?.reconcileFromMerge('bagToolWeaken'); + bridge.notifyAiBoardChanged(); + return; + } + // 本机盘面由 peer.merge 的 MapUpgraded 驱动 CocosBagBoardView + if (!(gridIndex >= 0)) { + console.warn('[UIBattleGame] 衰弱符对端格无效', peerOwnerPlayerId, gridIndex); + } + }; + /** * @param ownerPlayerId 归属 * @param unlockCount 解锁次数 @@ -1297,11 +1330,13 @@ export class UIBattleGame extends Auto_BattleGame { if (this._battle?.bagSession) { this._battle.bagSession.onUnlockCoinFly = null; this._battle.bagSession.onBattleBuffSelect = null; + this._battle.bagSession.onPeerMapToolApplied = null; } const aiBagTeardown = AiBattleBridge.inst.aiBagSession; if (aiBagTeardown) { aiBagTeardown.onUnlockCoinFly = null; aiBagTeardown.onBattleBuffSelect = null; + aiBagTeardown.onPeerMapToolApplied = null; } this._killPeach?.unbind(); this._killPeach = null;