feat: add resonance follow-up attacks
This commit is contained in:
@@ -196,7 +196,7 @@ export function isValidBattleSaveState(state: unknown, options: BattleSaveValida
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!areAttackIntentsTargetingLiveUnits(attackIntents, units, options)) {
|
||||
if (!areAttackIntentsTargetingLiveUnits(attackIntents, state.actedUnitIds, units, options)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ function isSortieOrderId(value: unknown): value is SortieOrderId {
|
||||
return value === 'elite' || value === 'mobile' || value === 'siege';
|
||||
}
|
||||
|
||||
function isUnitIdArray(value: unknown, options: BattleSaveValidationOptions) {
|
||||
function isUnitIdArray(value: unknown, options: BattleSaveValidationOptions): value is string[] {
|
||||
return (
|
||||
Array.isArray(value) &&
|
||||
value.length <= unitReferenceLimit(options) &&
|
||||
@@ -348,14 +348,17 @@ function areSavedBattleUnitsValid(units: unknown[], options: BattleSaveValidatio
|
||||
|
||||
function areAttackIntentsTargetingLiveUnits(
|
||||
attackIntents: BattleSaveAttackIntent[],
|
||||
actedUnitIds: string[],
|
||||
units: SavedBattleUnitState[],
|
||||
options: BattleSaveValidationOptions
|
||||
) {
|
||||
const liveUnitIds = new Set(units.filter((unit) => unit.hp > 0).map((unit) => unit.id));
|
||||
const actedUnitIdSet = new Set(actedUnitIds);
|
||||
return attackIntents.every(
|
||||
(intent) =>
|
||||
liveUnitIds.has(intent.attackerId) &&
|
||||
liveUnitIds.has(intent.targetId) &&
|
||||
actedUnitIdSet.has(intent.attackerId) &&
|
||||
(!options.validAllyUnitIds || options.validAllyUnitIds.has(intent.attackerId)) &&
|
||||
(!options.validEnemyUnitIds || options.validEnemyUnitIds.has(intent.targetId))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user