From 4e9eab2cce1bf8b2459931d7458e70d74abc13ab Mon Sep 17 00:00:00 2001 From: PeekabooSteam Date: Wed, 24 May 2023 21:38:35 +0100 Subject: [PATCH] Warning now only shows when humans are in the selection. --- client/src/units/unitsmanager.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/client/src/units/unitsmanager.ts b/client/src/units/unitsmanager.ts index 9c05e34b..80699b05 100644 --- a/client/src/units/unitsmanager.ts +++ b/client/src/units/unitsmanager.ts @@ -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(); + } + } }