Warning now only shows when humans are in the selection.

This commit is contained in:
PeekabooSteam 2023-05-24 21:38:35 +01:00
parent 4a93c1eead
commit 4e9eab2cce

View File

@ -330,8 +330,17 @@ export class UnitsManager {
/***********************************************/
#onKeyUp(event: KeyboardEvent) {
if (!keyEventWasInInput(event) && event.key === "Delete" && confirm( "Are you sure you want to delete?" ) ) {
this.selectedUnitsDelete();
if (!keyEventWasInInput(event) && event.key === "Delete" ) {
const selectedUnits = this.getSelectedUnits();
const selectionContainsAHuman = selectedUnits.some( ( unit:Unit ) => {
return unit.getBaseData().AI === false;
});
if ( !selectionContainsAHuman || confirm( "Your selection includes a human player. Deleting humans causes their vehicle to crash.\n\nAre you sure you want to do this?" ) ) {
this.selectedUnitsDelete();
}
}
}