Reject overlapping live battle save units
This commit is contained in:
@@ -219,6 +219,7 @@ function isAttackIntentArray(value: unknown, options: BattleSaveValidationOption
|
||||
|
||||
function areSavedBattleUnitsValid(units: unknown[], options: BattleSaveValidationOptions) {
|
||||
const seenUnitIds = new Set<string>();
|
||||
const seenLiveTileKeys = new Set<string>();
|
||||
|
||||
for (const unit of units) {
|
||||
if (!isSavedBattleUnitState(unit, options) || seenUnitIds.has(unit.id)) {
|
||||
@@ -226,6 +227,13 @@ function areSavedBattleUnitsValid(units: unknown[], options: BattleSaveValidatio
|
||||
}
|
||||
|
||||
seenUnitIds.add(unit.id);
|
||||
if (unit.hp > 0) {
|
||||
const tileKey = `${unit.x}:${unit.y}`;
|
||||
if (seenLiveTileKeys.has(tileKey)) {
|
||||
return false;
|
||||
}
|
||||
seenLiveTileKeys.add(tileKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.validUnitIds) {
|
||||
|
||||
Reference in New Issue
Block a user