mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04: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:
parent
98685ad7c0
commit
d0a59889c4
@ -81,12 +81,12 @@ object UnitActions {
|
|||||||
else "Do you really want to disband this unit?".tr()
|
else "Do you really want to disband this unit?".tr()
|
||||||
YesNoPopup(disbandText, { unit.disband(); worldScreen.shouldUpdate = true }).open()
|
YesNoPopup(disbandText, { unit.disband(); worldScreen.shouldUpdate = true }).open()
|
||||||
}
|
}
|
||||||
}.takeIf {unit.currentMovement > 0} )
|
}.takeIf { unit.currentMovement > 0 })
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addCreateWaterImprovements(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
private fun addCreateWaterImprovements(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||||
val waterImprovementAction = getWaterImprovementAction(unit)
|
val waterImprovementAction = getWaterImprovementAction(unit)
|
||||||
if(waterImprovementAction!=null) actionList += waterImprovementAction
|
if (waterImprovementAction != null) actionList += waterImprovementAction
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getWaterImprovementAction(unit: MapUnit): UnitAction? {
|
fun getWaterImprovementAction(unit: MapUnit): UnitAction? {
|
||||||
@ -104,7 +104,7 @@ object UnitActions {
|
|||||||
action = {
|
action = {
|
||||||
tile.improvement = improvement
|
tile.improvement = improvement
|
||||||
unit.destroy()
|
unit.destroy()
|
||||||
}.takeIf {unit.currentMovement > 0})
|
}.takeIf { unit.currentMovement > 0 })
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ object UnitActions {
|
|||||||
&& tile.roadStatus == RoadStatus.None
|
&& tile.roadStatus == RoadStatus.None
|
||||||
&& tile.improvementInProgress != "Road"
|
&& tile.improvementInProgress != "Road"
|
||||||
&& tile.isLand
|
&& tile.isLand
|
||||||
&& (improvement.techRequired==null || unit.civInfo.tech.isResearched(improvement.techRequired!!)))
|
&& (improvement.techRequired == null || unit.civInfo.tech.isResearched(improvement.techRequired!!)))
|
||||||
actionList += UnitAction(
|
actionList += UnitAction(
|
||||||
type = UnitActionType.ConstructRoad,
|
type = UnitActionType.ConstructRoad,
|
||||||
action = {
|
action = {
|
||||||
@ -129,7 +129,7 @@ object UnitActions {
|
|||||||
if (getFoundCityAction != null) actionList += getFoundCityAction
|
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
|
if (!unit.hasUnique("Founds a new city") || tile.isWater) return null
|
||||||
return UnitAction(
|
return UnitAction(
|
||||||
type = UnitActionType.FoundCity,
|
type = UnitActionType.FoundCity,
|
||||||
@ -168,7 +168,7 @@ object UnitActions {
|
|||||||
private fun addPillageAction(unit: MapUnit, actionList: ArrayList<UnitAction>, worldScreen: WorldScreen) {
|
private fun addPillageAction(unit: MapUnit, actionList: ArrayList<UnitAction>, worldScreen: WorldScreen) {
|
||||||
val pillageAction = getPillageAction(unit)
|
val pillageAction = getPillageAction(unit)
|
||||||
if (pillageAction == null) return
|
if (pillageAction == null) return
|
||||||
if(pillageAction.action==null)
|
if (pillageAction.action == null)
|
||||||
actionList += UnitAction(UnitActionType.Pillage, action = null)
|
actionList += UnitAction(UnitActionType.Pillage, action = null)
|
||||||
else actionList += UnitAction(type = UnitActionType.Pillage) {
|
else actionList += UnitAction(type = UnitActionType.Pillage) {
|
||||||
if (!worldScreen.hasOpenPopups()) {
|
if (!worldScreen.hasOpenPopups()) {
|
||||||
@ -192,11 +192,11 @@ object UnitActions {
|
|||||||
tile.turnsToImprovement = 2
|
tile.turnsToImprovement = 2
|
||||||
}
|
}
|
||||||
tile.improvement = null
|
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") ||
|
val freePillage = unit.hasUnique("No movement cost to pillage") ||
|
||||||
(unit.type.isMelee() && unit.civInfo.hasUnique("Melee units pay 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)
|
unit.healBy(25)
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ object UnitActions {
|
|||||||
type = UnitActionType.Explore,
|
type = UnitActionType.Explore,
|
||||||
action = {
|
action = {
|
||||||
unit.action = Constants.unitActionExplore
|
unit.action = Constants.unitActionExplore
|
||||||
if(unit.currentMovement>0) UnitAutomation.automatedExplore(unit)
|
if (unit.currentMovement > 0) UnitAutomation.automatedExplore(unit)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
actionList += UnitAction(
|
actionList += UnitAction(
|
||||||
@ -222,7 +222,7 @@ object UnitActions {
|
|||||||
|
|
||||||
private fun addUnitUpgradeAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
private fun addUnitUpgradeAction(unit: MapUnit, actionList: ArrayList<UnitAction>) {
|
||||||
val upgradeAction = getUpgradeAction(unit)
|
val upgradeAction = getUpgradeAction(unit)
|
||||||
if(upgradeAction!=null) actionList += upgradeAction
|
if (upgradeAction != null) actionList += upgradeAction
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUpgradeAction(unit: MapUnit): UnitAction? {
|
fun getUpgradeAction(unit: MapUnit): UnitAction? {
|
||||||
@ -275,11 +275,11 @@ object UnitActions {
|
|||||||
}.takeIf { unit.currentMovement > 0 })
|
}.takeIf { unit.currentMovement > 0 })
|
||||||
}
|
}
|
||||||
|
|
||||||
if(unit.isEmbarked()) return
|
if (unit.isEmbarked()) return
|
||||||
|
|
||||||
val canConstruct =unit.currentMovement > 0
|
val canConstruct = !tile.isCityCenter()
|
||||||
&& !tile.isCityCenter()
|
&& unit.civInfo.gameInfo.ruleSet.tileImprovements.values
|
||||||
&& unit.civInfo.gameInfo.ruleSet.tileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) }
|
.any { tile.canBuildImprovement(it, unit.civInfo) }
|
||||||
actionList += UnitAction(
|
actionList += UnitAction(
|
||||||
type = UnitActionType.ConstructImprovement,
|
type = UnitActionType.ConstructImprovement,
|
||||||
isCurrentAction = unit.currentTile.hasImprovementInProgress(),
|
isCurrentAction = unit.currentTile.hasImprovementInProgress(),
|
||||||
@ -358,7 +358,7 @@ object UnitActions {
|
|||||||
val finalActions = ArrayList<UnitAction>()
|
val finalActions = ArrayList<UnitAction>()
|
||||||
for (unique in unit.getMatchingUniques("Can construct []")) {
|
for (unique in unit.getMatchingUniques("Can construct []")) {
|
||||||
val improvementName = unique.params[0]
|
val improvementName = unique.params[0]
|
||||||
finalActions += UnitAction(
|
finalActions += UnitAction(
|
||||||
type = UnitActionType.Create,
|
type = UnitActionType.Create,
|
||||||
title = "Create [$improvementName]",
|
title = "Create [$improvementName]",
|
||||||
uncivSound = UncivSound.Chimes,
|
uncivSound = UncivSound.Chimes,
|
||||||
@ -379,12 +379,14 @@ object UnitActions {
|
|||||||
}
|
}
|
||||||
addGoldPerGreatPersonUsage(unit.civInfo)
|
addGoldPerGreatPersonUsage(unit.civInfo)
|
||||||
unit.destroy()
|
unit.destroy()
|
||||||
}.takeIf { unit.currentMovement > 0f && !tile.isWater &&
|
}.takeIf {
|
||||||
!tile.isCityCenter() && !tile.isImpassible() &&
|
unit.currentMovement > 0f && !tile.isWater &&
|
||||||
tile.improvement != improvementName &&
|
!tile.isCityCenter() && !tile.isImpassible() &&
|
||||||
// citadel can be built only next to or within own borders
|
tile.improvement != improvementName &&
|
||||||
(improvementName != Constants.citadel ||
|
// citadel can be built only next to or within own borders
|
||||||
tile.neighbors.any { it.getOwner() == unit.civInfo })})
|
(improvementName != Constants.citadel ||
|
||||||
|
tile.neighbors.any { it.getOwner() == unit.civInfo })
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return finalActions
|
return finalActions
|
||||||
}
|
}
|
||||||
@ -403,7 +405,7 @@ object UnitActions {
|
|||||||
val otherCiv = tile.getOwner()
|
val otherCiv = tile.getOwner()
|
||||||
if (otherCiv != null) {
|
if (otherCiv != null) {
|
||||||
// decrease relations for -10 pt/tile
|
// 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)
|
otherCiv.getDiplomacyManager(unit.civInfo).addModifier(DiplomaticModifiers.StealingTerritory, -10f)
|
||||||
notifications.add(otherCiv)
|
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
|
// 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)
|
return tileOwner == null || tileOwner == unit.civInfo || unit.civInfo.isAtWarWith(tileOwner)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user