mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-10 02:47:24 +07:00
Minor improvements from GPC
This commit is contained in:
parent
6bbab8a394
commit
8a6b4de84f
@ -212,33 +212,33 @@ class WorkerAutomation(
|
||||
}
|
||||
while (true) {
|
||||
for (cityTile in cityTilesToSeek) {
|
||||
if (bfs.hasReachedTile(cityTile)) { // we have a winner!
|
||||
val pathToCity = bfs.getPathTo(cityTile)
|
||||
val roadableTiles = pathToCity.filter { it.roadStatus < bestRoadAvailable }
|
||||
val tileToConstructRoadOn: TileInfo
|
||||
if (currentTile in roadableTiles) tileToConstructRoadOn =
|
||||
currentTile
|
||||
else {
|
||||
val reachableTile = roadableTiles
|
||||
.sortedBy { it.aerialDistanceTo(unit.getTile()) }
|
||||
.firstOrNull {
|
||||
unit.movement.canMoveTo(it) && unit.movement.canReach(
|
||||
it
|
||||
)
|
||||
}
|
||||
?: continue
|
||||
tileToConstructRoadOn = reachableTile
|
||||
unit.movement.headTowards(tileToConstructRoadOn)
|
||||
}
|
||||
if (unit.currentMovement > 0 && currentTile == tileToConstructRoadOn
|
||||
&& currentTile.improvementInProgress != bestRoadAvailable.name) {
|
||||
val improvement = bestRoadAvailable.improvement(ruleSet)!!
|
||||
tileToConstructRoadOn.startWorkingOnImprovement(improvement, civInfo)
|
||||
}
|
||||
if (WorkerAutomationConst.consoleOutput)
|
||||
println("WorkerAutomation: ${unit.label()} -> connect city ${bfs.startingPoint.getCity()?.name} to ${cityTile.getCity()!!.name} on $tileToConstructRoadOn")
|
||||
return true
|
||||
if (!bfs.hasReachedTile(cityTile)) continue
|
||||
// we have a winner!
|
||||
val pathToCity = bfs.getPathTo(cityTile)
|
||||
val roadableTiles = pathToCity.filter { it.roadStatus < bestRoadAvailable }
|
||||
val tileToConstructRoadOn: TileInfo
|
||||
if (currentTile in roadableTiles) tileToConstructRoadOn =
|
||||
currentTile
|
||||
else {
|
||||
val reachableTile = roadableTiles
|
||||
.sortedBy { it.aerialDistanceTo(unit.getTile()) }
|
||||
.firstOrNull {
|
||||
unit.movement.canMoveTo(it) && unit.movement.canReach(
|
||||
it
|
||||
)
|
||||
}
|
||||
?: continue
|
||||
tileToConstructRoadOn = reachableTile
|
||||
unit.movement.headTowards(tileToConstructRoadOn)
|
||||
}
|
||||
if (unit.currentMovement > 0 && currentTile == tileToConstructRoadOn
|
||||
&& currentTile.improvementInProgress != bestRoadAvailable.name) {
|
||||
val improvement = bestRoadAvailable.improvement(ruleSet)!!
|
||||
tileToConstructRoadOn.startWorkingOnImprovement(improvement, civInfo)
|
||||
}
|
||||
if (WorkerAutomationConst.consoleOutput)
|
||||
println("WorkerAutomation: ${unit.label()} -> connect city ${bfs.startingPoint.getCity()?.name} to ${cityTile.getCity()!!.name} on $tileToConstructRoadOn")
|
||||
return true
|
||||
}
|
||||
if (bfs.hasEnded()) break
|
||||
bfs.nextStep()
|
||||
|
@ -349,7 +349,7 @@ class CityStateFunctions(val civInfo: CivilizationInfo) {
|
||||
if (!requireWholeList && modifiers.values.sum() < -100)
|
||||
return modifiers
|
||||
|
||||
val bullyRange = max(5, civInfo.gameInfo.tileMap.tileMatrix.size / 10) // Longer range for larger maps
|
||||
val bullyRange = (civInfo.gameInfo.tileMap.tileMatrix.size / 10).coerceIn(5, 10) // Longer range for larger maps
|
||||
val inRangeTiles = civInfo.getCapital().getCenterTile().getTilesInDistanceRange(1..bullyRange)
|
||||
val forceNearCity = inRangeTiles
|
||||
.sumOf { if (it.militaryUnit?.civInfo == demandingCiv)
|
||||
|
@ -168,11 +168,11 @@ class DiplomacyManager() {
|
||||
return otherCiv().getDiplomacyManager(civInfo).relationshipLevel()
|
||||
|
||||
if (civInfo.isCityState()) return when {
|
||||
influence >= 60 && civInfo.getAllyCiv() == otherCivName -> RelationshipLevel.Ally
|
||||
influence >= 30 -> RelationshipLevel.Friend
|
||||
influence <= -30 || civInfo.isAtWarWith(otherCiv()) -> RelationshipLevel.Unforgivable
|
||||
influence < 30 && civInfo.getTributeWillingness(otherCiv()) > 0 -> RelationshipLevel.Afraid
|
||||
influence < 0 -> RelationshipLevel.Enemy
|
||||
influence >= 60 && civInfo.getAllyCiv() == otherCivName -> RelationshipLevel.Ally
|
||||
influence >= 30 -> RelationshipLevel.Friend
|
||||
else -> RelationshipLevel.Neutral
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user