mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-31 07:09:26 +07:00
Spy rank UI and fixes (#11551)
* Added spy rank to the spy table * Dead spies aren't allowed to move * Fixed AI spy automation * Fixed AI rank not being cloned * Removed rank fix (new fix is in MissingEspionageUniques)
This commit is contained in:
@ -8,7 +8,8 @@ import kotlin.random.Random
|
||||
|
||||
class EspionageAutomation(val civInfo: Civilization) {
|
||||
private val civsToStealFrom: List<Civilization> by lazy {
|
||||
civInfo.getKnownCivs().filter {otherCiv -> otherCiv.isMajorCiv() && otherCiv.cities.any { it.getCenterTile().isVisible(civInfo) }
|
||||
civInfo.getKnownCivs().filter {otherCiv -> otherCiv.isMajorCiv()
|
||||
&& otherCiv.cities.any { it.getCenterTile().isExplored(civInfo) && civInfo.espionageManager.getSpyAssignedToCity(it) == null }
|
||||
&& civInfo.espionageManager.getTechsToSteal(otherCiv).isNotEmpty() }.toList()
|
||||
}
|
||||
|
||||
@ -57,17 +58,19 @@ class EspionageAutomation(val civInfo: Civilization) {
|
||||
if (civsToStealFrom.isEmpty()) return false
|
||||
// We want to move the spy to the city with the highest science generation
|
||||
// Players can't usually figure this out so lets do highest population instead
|
||||
spy.moveTo(getCivsToStealFromSorted.first().cities.filter { spy.canMoveTo(it) }.maxByOrNull { it.population.population })
|
||||
return spy.action == SpyAction.StealingTech
|
||||
val cityToMoveTo = getCivsToStealFromSorted.first().cities.filter { spy.canMoveTo(it) }.maxByOrNull { it.population.population }
|
||||
spy.moveTo(cityToMoveTo)
|
||||
return cityToMoveTo != null
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the spy to a random city-state
|
||||
*/
|
||||
private fun automateSpyRigElection(spy: Spy): Boolean {
|
||||
val potentialCities = cityStatesToRig.flatMap { it.cities }.filter { !it.isBeingRazed && spy.canMoveTo(it) }
|
||||
spy.moveTo(potentialCities.randomOrNull())
|
||||
return spy.action == SpyAction.RiggingElections
|
||||
val cityToMoveTo = cityStatesToRig.flatMap { it.cities }.filter { !it.isBeingRazed && spy.canMoveTo(it) && (it.civ.getDiplomacyManager(civInfo).getInfluence() < 150 || it.civ.getAllyCiv() != civInfo.civName) }
|
||||
.maxByOrNull { it.civ.getDiplomacyManager(civInfo).getInfluence() }
|
||||
spy.moveTo(cityToMoveTo)
|
||||
return cityToMoveTo != null
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,7 +235,7 @@ class Spy() : IsPartOfGameInfoSerialization {
|
||||
|
||||
fun canMoveTo(city: City): Boolean {
|
||||
if (getLocation() == city) return true
|
||||
if (!city.getCenterTile().isVisible(civInfo)) return false
|
||||
if (!city.getCenterTile().isExplored(civInfo)) return false
|
||||
return espionageManager.getSpyAssignedToCity(city) == null
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,12 @@ class EspionageOverviewScreen(val civInfo: Civilization, val worldScreen: WorldS
|
||||
private fun updateSpyList() {
|
||||
spySelectionTable.clear()
|
||||
spySelectionTable.add("Spy".toLabel())
|
||||
spySelectionTable.add("Rank".toLabel())
|
||||
spySelectionTable.add("Location".toLabel())
|
||||
spySelectionTable.add("Action".toLabel()).row()
|
||||
for (spy in civInfo.espionageManager.spyList) {
|
||||
spySelectionTable.add(spy.name.toLabel())
|
||||
spySelectionTable.add(spy.rank.toLabel())
|
||||
spySelectionTable.add(spy.getLocationName().toLabel())
|
||||
val actionString =
|
||||
when (spy.action) {
|
||||
@ -99,7 +101,7 @@ class EspionageOverviewScreen(val civInfo: Civilization, val worldScreen: WorldS
|
||||
|| (city.civ != civInfo && !city.espionage.hasSpyOf(civInfo))
|
||||
}
|
||||
}
|
||||
if (!worldScreen.canChangeState) {
|
||||
if (!worldScreen.canChangeState || !spy.isAlive()) {
|
||||
// Spectators aren't allowed to move the spies of the Civs they are viewing
|
||||
moveSpyButton.disable()
|
||||
}
|
||||
|
Reference in New Issue
Block a user