Resolved #435 - profit from disbanding units
This commit is contained in:
parent
665af17ae5
commit
f80077a412
4 changed files with 18 additions and 3 deletions
|
@ -293,6 +293,8 @@
|
|||
Portuguese:"Voçê realmente quer desfazer essa unidade?"
|
||||
German:"Wollen Sie diese Einheit wirklich auflösen?"
|
||||
}
|
||||
"Disband this unit for [goldAmount] gold?":{}
|
||||
|
||||
"Yes":{
|
||||
Italian:"Sì"
|
||||
Russian:"Да"
|
||||
|
|
|
@ -392,6 +392,12 @@ class MapUnit {
|
|||
civInfo.updateViewableTiles()
|
||||
}
|
||||
|
||||
fun disband(){
|
||||
destroy()
|
||||
if(currentTile.isCityCenter() && currentTile.getOwner()==civInfo)
|
||||
civInfo.gold += baseUnit.getDisbandGold()
|
||||
}
|
||||
|
||||
private fun getAncientRuinBonus() {
|
||||
currentTile.improvement=null
|
||||
val actions: ArrayList<() -> Unit> = ArrayList()
|
||||
|
|
|
@ -87,12 +87,16 @@ class BaseUnit : INamed, IConstruction, ICivilopedia {
|
|||
|
||||
override fun getProductionCost(adoptedPolicies: HashSet<String>): Int = cost
|
||||
|
||||
fun getBaseGoldCost() = Math.pow((30 * cost).toDouble(), 0.75) * (1 + hurryCostModifier / 100)
|
||||
|
||||
override fun getGoldCost(adoptedPolicies: HashSet<String>): Int {
|
||||
var cost = Math.pow((30 * cost).toDouble(), 0.75) * (1 + hurryCostModifier / 100)
|
||||
var cost = getBaseGoldCost()
|
||||
if(adoptedPolicies.contains("Militarism")) cost *= 0.66f
|
||||
return (cost / 10).toInt() * 10 // rounded down o nearest ten
|
||||
}
|
||||
|
||||
fun getDisbandGold() = getBaseGoldCost().toInt()/20
|
||||
|
||||
fun isBuildable(civInfo:CivilizationInfo): Boolean {
|
||||
if (unbuildable) return false
|
||||
if (requiredTech!=null && !civInfo.tech.isResearched(requiredTech!!)) return false
|
||||
|
|
|
@ -200,8 +200,11 @@ class UnitActions {
|
|||
|
||||
actionList += UnitAction("Disband unit",unit.currentMovement >0
|
||||
) {
|
||||
YesNoPopupTable("Do you really want to disband this unit?".tr(),
|
||||
{unit.destroy(); worldScreen.shouldUpdate=true} )
|
||||
val disbandText = if(unit.currentTile.getOwner()==unit.civInfo)
|
||||
"Disband this unit for [${unit.baseUnit.getDisbandGold()}] gold?".tr()
|
||||
else "Do you really want to disband this unit?".tr()
|
||||
YesNoPopupTable(disbandText,
|
||||
{unit.disband(); worldScreen.shouldUpdate=true} )
|
||||
}
|
||||
|
||||
return actionList
|
||||
|
|
Loading…
Reference in a new issue