Resolved #9163 - Can again spectate games where not an original participant

This commit is contained in:
Yair Morgenstern 2023-04-13 17:51:11 +03:00
parent 2fbd24231f
commit e7653bd53d

View File

@ -204,7 +204,8 @@ class GameInfo : IsPartOfGameInfoSerialization, HasGameInfoSerializationVersion
val civMap by lazy { civilizations.associateBy { it.civName } }
/** Get a civ by name
* @throws NoSuchElementException if no civ of that name is in the game (alive or dead)! */
fun getCivilization(civName: String) = civMap.getValue(civName)
fun getCivilization(civName: String) = civMap[civName]
?: civilizations.first { it.civName == civName } // This is for spectators who are added in later, artificially
fun getCurrentPlayerCivilization() = currentPlayerCiv
fun getCivilizationsAsPreviews() = civilizations.map { it.asPreview() }.toMutableList()
/** Get barbarian civ