master
humingxing 17 hours ago
parent 63499c05a1
commit e243b7410e
  1. 4
      assets/bundles/battleHero/prefab/weapon/宝石掉落.prefab
  2. 4
      assets/bundles/first/config/Text.json
  3. 6
      assets/script/battle/ai/decision/AiBoardProbe.ts
  4. 35
      assets/script/battle/bag/BattleBagSession.ts
  5. 48
      assets/script/battle/view/MapDragGuideHelper.ts
  6. 35
      assets/script/ui/BattleGame/UIBattleGame.ts

@ -49,8 +49,8 @@
}, },
"_lscale": { "_lscale": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 1, "x": 0.5,
"y": 1, "y": 0.5,
"z": 1 "z": 1
}, },
"_mobility": 0, "_mobility": 0,

@ -135,12 +135,12 @@
"id": 3001, "id": 3001,
"type": 12, "type": 12,
"level": 0, "level": 0,
"weight": 150 "weight": 15
}, },
{ {
"id": 3002, "id": 3002,
"type": 13, "type": 13,
"level": 0, "level": 0,
"weight": 50 "weight": 5
} }
] ]

@ -283,17 +283,19 @@ export class AiBoardProbe {
} }
} }
const mapOwner = toolType === 13 ? session.resolveOpponentBagSession() : session;
if (!mapOwner) continue;
const grids = this._listActiveGrids(map); const grids = this._listActiveGrids(map);
for (let g = 0; g < grids.length; g++) { for (let g = 0; g < grids.length; g++) {
const mg = grids[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); const ownCamp = session.validator.isAllowedCampForPlace(mg.Index);
if (toolType === 13) { if (toolType === 13) {
if (ownCamp) continue; if (ownCamp) continue;
} else if (!ownCamp) { } else if (!ownCamp) {
continue; 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; if (!this._isBagToolDigitTarget(provider, tile.weapon2Id, tile.level ?? 1, toolType)) continue;
const score = this._scoreBattleCardTarget(provider, tile.weapon2Id, tile.level ?? 1, true, mg.Index); const score = this._scoreBattleCardTarget(provider, tile.weapon2Id, tile.level ?? 1, true, mg.Index);
if (!best || score > best.score) { if (!best || score > best.score) {

@ -109,6 +109,12 @@ export class BattleBagSession {
* @param unlockCount 本阵营已完成解锁次数(含本次) * @param unlockCount 本阵营已完成解锁次数(含本次)
*/ */
onBattleBuffSelect: ((ownerPlayerId: number, unlockCount: number) => void) | null = null; 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?: { constructor(map: MapManager, chapterId: number, session?: import('db://assets/mx/module/battle').BattleSession, bagSlotCount = 5, opts?: {
/** 字池所用段位 id;缺省玩家当前段位 */ /** 字池所用段位 id;缺省玩家当前段位 */
@ -156,6 +162,16 @@ export class BattleBagSession {
return this._ownerPlayerId; 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 合成事件 * @param event 合成事件
@ -1299,7 +1315,7 @@ export class BattleBagSession {
if (!dst) return 'skip'; if (!dst) return 'skip';
return this._applyBagToolToBag(source.slotIndex, target.slotIndex, toolType); 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 PlaceRejectReason.InvalidMerge;
} }
return this._applyBagToolToMap(source.slotIndex, target.gridIndex, toolType); return this._applyBagToolToMap(source.slotIndex, target.gridIndex, toolType);
@ -1334,20 +1350,26 @@ export class BattleBagSession {
} }
/** /**
* 功能符拖到地图数字(衰弱符仅对方阵营)。 * 功能符拖到地图数字(衰弱符仅对方阵营,改写对端 merge)。
* @param fromSlot 符槽 * @param fromSlot 符槽
* @param gridIndex 目标格 * @param gridIndex 目标格
* @param toolType Text.type * @param toolType Text.type
*/ */
private _applyBagToolToMap(fromSlot: number, gridIndex: number, toolType: number): PlaceRejectReason | null { 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); const ownCamp = this.validator.isAllowedCampForPlace(gridIndex);
if (toolType === 13) { if (toolType === 13) {
if (ownCamp) return PlaceRejectReason.InvalidMerge; if (ownCamp) return PlaceRejectReason.InvalidMerge;
} else if (!ownCamp) { } else if (!ownCamp) {
return PlaceRejectReason.WrongCampArea; 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 level = Math.max(1, Math.floor(Number(tile.level) || 1));
const resolved = this._resolveBagToolResult(Number(tile.weapon2Id) || 0, level, toolType); const resolved = this._resolveBagToolResult(Number(tile.weapon2Id) || 0, level, toolType);
if (resolved.reason) return resolved.reason; if (resolved.reason) return resolved.reason;
@ -1356,9 +1378,12 @@ export class BattleBagSession {
this.merge.bag.clearSlot(fromSlot); this.merge.bag.clearSlot(fromSlot);
return null; 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; if (err) return err;
this.merge.bag.clearSlot(fromSlot); this.merge.bag.clearSlot(fromSlot);
if (peer) {
this.onPeerMapToolApplied?.(peer.ownerPlayerId, gridIndex);
}
return null; return null;
} }

@ -197,6 +197,10 @@ export class MapDragGuideHelper {
if (source && MapDragGuideHelper._canSwapDropOnGrid(session, mg.Index, source)) { if (source && MapDragGuideHelper._canSwapDropOnGrid(session, mg.Index, source)) {
return ''; return '';
} }
if (source) {
const toolMsg = MapDragGuideHelper._bagToolDropFailMessage(session, mg.Index, source);
if (toolMsg) return toolMsg;
}
return MapDragGuideHelper.getBlockedDropMessage(session, w2Type, mg); return MapDragGuideHelper.getBlockedDropMessage(session, w2Type, mg);
} }
@ -394,7 +398,7 @@ export class MapDragGuideHelper {
} }
/** /**
* Text 功能符可落到合法阵营已占五行字上(衰弱符仅对方)。 * Text 功能符可落到合法阵营已占五行字上(衰弱符仅对方,读对端 merge)。
* @param session 背包会话 * @param session 背包会话
* @param gridIndex 地图格 * @param gridIndex 地图格
* @param source 拖拽来源 * @param source 拖拽来源
@ -408,14 +412,16 @@ export class MapDragGuideHelper {
WeaponComposeConfigProvider.instance.load(); WeaponComposeConfigProvider.instance.load();
const toolType = Math.floor(WeaponComposeConfigProvider.instance.getWeapon2Type(source.weapon2Id)); const toolType = Math.floor(WeaponComposeConfigProvider.instance.getWeapon2Type(source.weapon2Id));
if (!isBagToolTextType(toolType)) return false; if (!isBagToolTextType(toolType)) return false;
const tile = session.merge.map.getTile(gridIndex);
if (!tile || tile.battleCardKind) return false;
const ownCamp = session.validator.isAllowedCampForPlace(gridIndex); const ownCamp = session.validator.isAllowedCampForPlace(gridIndex);
if (toolType === 13) { if (toolType === 13) {
if (ownCamp) return false; if (ownCamp) return false;
} else if (!ownCamp) { } else if (!ownCamp) {
return false; 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)); const dstType = Math.floor(WeaponComposeConfigProvider.instance.getWeapon2Type(tile.weapon2Id));
if (!isElementGlyphType(dstType)) return false; if (!isElementGlyphType(dstType)) return false;
const lv = Math.max(1, Math.floor(Number(tile.level) || 1)); const lv = Math.max(1, Math.floor(Number(tile.level) || 1));
@ -426,6 +432,42 @@ export class MapDragGuideHelper {
return true; 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( private static _canUpgradeDropOnGrid(
session: BattleBagSession, session: BattleBagSession,
gridIndex: number, gridIndex: number,

@ -422,6 +422,7 @@ export class UIBattleGame extends Auto_BattleGame {
} }
this._bindUnlockCoinFly(battle); this._bindUnlockCoinFly(battle);
this._bindBattleBuffSelect(battle); this._bindBattleBuffSelect(battle);
this._bindPeerMapToolApplied(battle);
this._campHpBar.bind(battle, map); this._campHpBar.bind(battle, map);
getBattleGameMonsterCrisisHintPresenter().bind(battle, map); getBattleGameMonsterCrisisHintPresenter().bind(battle, map);
this._firstGuide.bind(this.ui_guide, battle.bagSession, this.btnRefresh); 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 ownerPlayerId 归属
* @param unlockCount 解锁次数 * @param unlockCount 解锁次数
@ -1297,11 +1330,13 @@ export class UIBattleGame extends Auto_BattleGame {
if (this._battle?.bagSession) { if (this._battle?.bagSession) {
this._battle.bagSession.onUnlockCoinFly = null; this._battle.bagSession.onUnlockCoinFly = null;
this._battle.bagSession.onBattleBuffSelect = null; this._battle.bagSession.onBattleBuffSelect = null;
this._battle.bagSession.onPeerMapToolApplied = null;
} }
const aiBagTeardown = AiBattleBridge.inst.aiBagSession; const aiBagTeardown = AiBattleBridge.inst.aiBagSession;
if (aiBagTeardown) { if (aiBagTeardown) {
aiBagTeardown.onUnlockCoinFly = null; aiBagTeardown.onUnlockCoinFly = null;
aiBagTeardown.onBattleBuffSelect = null; aiBagTeardown.onBattleBuffSelect = null;
aiBagTeardown.onPeerMapToolApplied = null;
} }
this._killPeach?.unbind(); this._killPeach?.unbind();
this._killPeach = null; this._killPeach = null;

Loading…
Cancel
Save