Update BarbarianManager.kt

This commit is contained in:
GeorgCantor 2025-09-13 22:26:12 +03:00 committed by GitHub
parent 132195ad1a
commit 9b878bef6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,13 +54,15 @@ class BarbarianManager : IsPartOfGameInfoSerialization {
fun updateEncampments() {
// Check if camps were destroyed
for (encampment in encampments.toList()) { // tolist to avoid concurrent modification
val iterator = encampments.iterator()
while (iterator.hasNext()) {
val encampment = iterator.next()
if (tileMap[encampment.position].improvement != Constants.barbarianEncampment) {
encampment.wasDestroyed()
}
// Check if the ghosts are ready to depart
if (encampment.destroyed && encampment.countdown == 0)
encampments.remove(encampment)
iterator.remove()
}
// Possibly place a new encampment