Resolved #435 - profit from disbanding units

This commit is contained in:
Yair Morgenstern 2019-01-26 22:39:48 +02:00
parent 665af17ae5
commit f80077a412
4 changed files with 18 additions and 3 deletions

View file

@ -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:"Да"

View file

@ -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()

View file

@ -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

View file

@ -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