mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-01 15:49:46 +07:00
Can now choose construction to work on even when worker has no movement points, since it won't advance unless he does
This commit is contained in:
@ -81,12 +81,12 @@ object UnitActions {
|
||||
else "Do you really want to disband this unit?".tr()
|
||||
YesNoPopup(disbandText, { unit.disband(); worldScreen.shouldUpdate = true }).open()
|
||||
}
|
||||
}.takeIf {unit.currentMovement > 0} )
|
||||
}.takeIf { unit.currentMovement > 0 })
|
||||
}
|
||||
|
||||
private fun addCreateWaterImprovements(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||
val waterImprovementAction = getWaterImprovementAction(unit)
|
||||
if(waterImprovementAction!=null) actionList += waterImprovementAction
|
||||
if (waterImprovementAction != null) actionList += waterImprovementAction
|
||||
}
|
||||
|
||||
fun getWaterImprovementAction(unit: MapUnit): UnitAction? {
|
||||
@ -104,7 +104,7 @@ object UnitActions {
|
||||
action = {
|
||||
tile.improvement = improvement
|
||||
unit.destroy()
|
||||
}.takeIf {unit.currentMovement > 0})
|
||||
}.takeIf { unit.currentMovement > 0 })
|
||||
}
|
||||
return null
|
||||
}
|
||||
@ -115,7 +115,7 @@ object UnitActions {
|
||||
&& tile.roadStatus == RoadStatus.None
|
||||
&& tile.improvementInProgress != "Road"
|
||||
&& tile.isLand
|
||||
&& (improvement.techRequired==null || unit.civInfo.tech.isResearched(improvement.techRequired!!)))
|
||||
&& (improvement.techRequired == null || unit.civInfo.tech.isResearched(improvement.techRequired!!)))
|
||||
actionList += UnitAction(
|
||||
type = UnitActionType.ConstructRoad,
|
||||
action = {
|
||||
@ -129,7 +129,7 @@ object UnitActions {
|
||||
if (getFoundCityAction != null) actionList += getFoundCityAction
|
||||
}
|
||||
|
||||
fun getFoundCityAction(unit:MapUnit, tile: TileInfo): UnitAction? {
|
||||
fun getFoundCityAction(unit: MapUnit, tile: TileInfo): UnitAction? {
|
||||
if (!unit.hasUnique("Founds a new city") || tile.isWater) return null
|
||||
return UnitAction(
|
||||
type = UnitActionType.FoundCity,
|
||||
@ -168,7 +168,7 @@ object UnitActions {
|
||||
private fun addPillageAction(unit: MapUnit, actionList: ArrayList<UnitAction>, worldScreen: WorldScreen) {
|
||||
val pillageAction = getPillageAction(unit)
|
||||
if (pillageAction == null) return
|
||||
if(pillageAction.action==null)
|
||||
if (pillageAction.action == null)
|
||||
actionList += UnitAction(UnitActionType.Pillage, action = null)
|
||||
else actionList += UnitAction(type = UnitActionType.Pillage) {
|
||||
if (!worldScreen.hasOpenPopups()) {
|
||||
@ -192,11 +192,11 @@ object UnitActions {
|
||||
tile.turnsToImprovement = 2
|
||||
}
|
||||
tile.improvement = null
|
||||
if (tile.resource!=null) tile.getOwner()?.updateDetailedCivResources() // this might take away a resource
|
||||
if (tile.resource != null) tile.getOwner()?.updateDetailedCivResources() // this might take away a resource
|
||||
|
||||
val freePillage = unit.hasUnique("No movement cost to pillage") ||
|
||||
(unit.type.isMelee() && unit.civInfo.hasUnique("Melee units pay no movement cost to pillage"))
|
||||
if(!freePillage) unit.useMovementPoints(1f)
|
||||
if (!freePillage) unit.useMovementPoints(1f)
|
||||
|
||||
unit.healBy(25)
|
||||
|
||||
@ -210,7 +210,7 @@ object UnitActions {
|
||||
type = UnitActionType.Explore,
|
||||
action = {
|
||||
unit.action = Constants.unitActionExplore
|
||||
if(unit.currentMovement>0) UnitAutomation.automatedExplore(unit)
|
||||
if (unit.currentMovement > 0) UnitAutomation.automatedExplore(unit)
|
||||
})
|
||||
} else {
|
||||
actionList += UnitAction(
|
||||
@ -222,7 +222,7 @@ object UnitActions {
|
||||
|
||||
private fun addUnitUpgradeAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||
val upgradeAction = getUpgradeAction(unit)
|
||||
if(upgradeAction!=null) actionList += upgradeAction
|
||||
if (upgradeAction != null) actionList += upgradeAction
|
||||
}
|
||||
|
||||
fun getUpgradeAction(unit: MapUnit): UnitAction? {
|
||||
@ -275,11 +275,11 @@ object UnitActions {
|
||||
}.takeIf { unit.currentMovement > 0 })
|
||||
}
|
||||
|
||||
if(unit.isEmbarked()) return
|
||||
if (unit.isEmbarked()) return
|
||||
|
||||
val canConstruct =unit.currentMovement > 0
|
||||
&& !tile.isCityCenter()
|
||||
&& unit.civInfo.gameInfo.ruleSet.tileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }
|
||||
val canConstruct = !tile.isCityCenter()
|
||||
&& unit.civInfo.gameInfo.ruleSet.tileImprovements.values
|
||||
.any { tile.canBuildImprovement(it, unit.civInfo) }
|
||||
actionList += UnitAction(
|
||||
type = UnitActionType.ConstructImprovement,
|
||||
isCurrentAction = unit.currentTile.hasImprovementInProgress(),
|
||||
@ -358,7 +358,7 @@ object UnitActions {
|
||||
val finalActions = ArrayList<UnitAction>()
|
||||
for (unique in unit.getMatchingUniques("Can construct []")) {
|
||||
val improvementName = unique.params[0]
|
||||
finalActions += UnitAction(
|
||||
finalActions += UnitAction(
|
||||
type = UnitActionType.Create,
|
||||
title = "Create [$improvementName]",
|
||||
uncivSound = UncivSound.Chimes,
|
||||
@ -379,12 +379,14 @@ object UnitActions {
|
||||
}
|
||||
addGoldPerGreatPersonUsage(unit.civInfo)
|
||||
unit.destroy()
|
||||
}.takeIf { unit.currentMovement > 0f && !tile.isWater &&
|
||||
!tile.isCityCenter() && !tile.isImpassible() &&
|
||||
tile.improvement != improvementName &&
|
||||
// citadel can be built only next to or within own borders
|
||||
(improvementName != Constants.citadel ||
|
||||
tile.neighbors.any { it.getOwner() == unit.civInfo })})
|
||||
}.takeIf {
|
||||
unit.currentMovement > 0f && !tile.isWater &&
|
||||
!tile.isCityCenter() && !tile.isImpassible() &&
|
||||
tile.improvement != improvementName &&
|
||||
// citadel can be built only next to or within own borders
|
||||
(improvementName != Constants.citadel ||
|
||||
tile.neighbors.any { it.getOwner() == unit.civInfo })
|
||||
})
|
||||
}
|
||||
return finalActions
|
||||
}
|
||||
@ -403,7 +405,7 @@ object UnitActions {
|
||||
val otherCiv = tile.getOwner()
|
||||
if (otherCiv != null) {
|
||||
// decrease relations for -10 pt/tile
|
||||
if(!otherCiv.knows(unit.civInfo)) otherCiv.meetCivilization(unit.civInfo)
|
||||
if (!otherCiv.knows(unit.civInfo)) otherCiv.meetCivilization(unit.civInfo)
|
||||
otherCiv.getDiplomacyManager(unit.civInfo).addModifier(DiplomaticModifiers.StealingTerritory, -10f)
|
||||
notifications.add(otherCiv)
|
||||
}
|
||||
@ -482,4 +484,4 @@ object UnitActions {
|
||||
// Can't pillage friendly tiles, just like you can't attack them - it's an 'act of war' thing
|
||||
return tileOwner == null || tileOwner == unit.civInfo || unit.civInfo.isAtWarWith(tileOwner)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user