|
|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|