mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 22:00:24 +07:00
Rewritten the MapUnit.rankTileForHealing() (#1811)
This commit is contained in:
@ -221,6 +221,14 @@ class DiplomacyManager() {
|
|||||||
/** Returns the [civilizations][CivilizationInfo] that know about both sides ([civInfo] and [otherCiv]) */
|
/** Returns the [civilizations][CivilizationInfo] that know about both sides ([civInfo] and [otherCiv]) */
|
||||||
fun getCommonKnownCivs(): Set<CivilizationInfo> = civInfo.getKnownCivs().intersect(otherCiv().getKnownCivs())
|
fun getCommonKnownCivs(): Set<CivilizationInfo> = civInfo.getKnownCivs().intersect(otherCiv().getKnownCivs())
|
||||||
|
|
||||||
|
/** Returns true when the [civInfo]'s territory is considered allied for [otherCiv].
|
||||||
|
*
|
||||||
|
* This includes friendly and allied city-states and the open border treaties.
|
||||||
|
*/
|
||||||
|
fun isConsideredAllyTerritory(): Boolean {
|
||||||
|
return (hasOpenBorders)
|
||||||
|
|| (civInfo.isCityState() && relationshipLevel() >= RelationshipLevel.Friend)
|
||||||
|
}
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region state-changing functions
|
//region state-changing functions
|
||||||
|
@ -386,19 +386,31 @@ class MapUnit {
|
|||||||
if(health>100) health=100
|
if(health>100) health=100
|
||||||
}
|
}
|
||||||
|
|
||||||
fun rankTileForHealing(tileInfo:TileInfo): Int {
|
/** Returns the health points [MapUnit] will receive if healing on [tileInfo] */
|
||||||
return when{
|
fun rankTileForHealing(tileInfo: TileInfo): Int {
|
||||||
tileInfo.isWater && type.isLandUnit() -> 0 // Can't heal in water!
|
val tileOwner = tileInfo.getOwner()
|
||||||
tileInfo.getOwner() == null -> 10 // no man's land (neutral)
|
val isAlliedTerritory = if (tileOwner != null)
|
||||||
tileInfo.isCityCenter() -> 20
|
tileOwner == civInfo || tileOwner.getDiplomacyManager(civInfo).isConsideredAllyTerritory()
|
||||||
!civInfo.isAtWarWith(tileInfo.getOwner()!!) -> 15 // home or allied territory
|
else
|
||||||
else -> { // enemy territory
|
false
|
||||||
if(hasUnique("This unit and all others in adjacent tiles heal 5 additional HP. This unit heals 5 additional HP outside of friendly territory.")) 10
|
|
||||||
else 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
var healing = when {
|
||||||
|
tileInfo.isCityCenter() -> 20
|
||||||
|
tileInfo.isWater && isAlliedTerritory && type.isWaterUnit() -> 15 // Water unit on friendly water
|
||||||
|
tileInfo.isWater -> 0 // All other water cases
|
||||||
|
tileOwner == null -> 10 // Neutral territory
|
||||||
|
isAlliedTerritory -> 15 // Allied territory
|
||||||
|
else -> 5 // Enemy territory
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasUnique("This unit and all others in adjacent tiles heal 5 additional HP. This unit heals 5 additional HP outside of friendly territory.")
|
||||||
|
&& !isAlliedTerritory
|
||||||
|
// Additional healing from medic is only applied when the unit is able to heal
|
||||||
|
&& healing > 0)
|
||||||
|
healing += 5
|
||||||
|
|
||||||
|
return healing
|
||||||
|
}
|
||||||
|
|
||||||
fun endTurn() {
|
fun endTurn() {
|
||||||
doPostTurnAction()
|
doPostTurnAction()
|
||||||
|
Reference in New Issue
Block a user