Unciv/tests
Oskar Niesen f1ceaa216a
Get distance to nearest enemy rework (#10481)
* Initial refactor

* Moved checking if a tile has an enemy to a new method

* Rewrote getDistanceToEnemyUnit

* changed the position of the logic of checking if the enemy is still there

* Changed some of the other methods to use the ThreatManager getClosestEnemy()

* Added a new getTilesWithEnemyUnitsInDistance method

* Added a new getEnemyMilitaryUnitsInDistance method

* Converted a few lines to use ThreatManager

* Changed Air units to use threat manager

* Fixed tileWithEnemy error

* distanceToClosestEnemyTiles now clears at the start of every turn

* Added blank lines to end of ThreatManager.kt

* Renamed tilesInRange to tilesWithEnemyUnitsInRange

* Changed ArrayList return to a MutableList

* Removed ClosestEnemyTileData being a data class

* Improved commenting

* Improved commenting2

* getEnemyMilitaryUnitsInDistance now uses a flatMap and moved getDangerousTiles to threat manager

* Created a new helper method getEnemyUnitsOnTiles

* Renamed clearThreatData to clear

* Added shortcut if maxDist is less than or equal to distanceSearched

* Fixed distanceWithNoEnemies in getTilesWithEnemyUnitsInDistance

* Fixed notFoundDistance being higher than maxDistance when takeLargerValues is false

* Added some ThreatManager tests

* Added some more ThreatManager tests

* Removed visible map after use

* getTilesWithEnemyUnitsInDistance doesn't search distances <= tileData.distanceSearched (previously was <)

* Added 3 more tests

---------

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
2023-11-25 20:11:10 +02:00
..
src/com/unciv Get distance to nearest enemy rework (#10481) 2023-11-25 20:11:10 +02:00
build.gradle.kts