Added unit maintainance costs to civ
This commit is contained in:
parent
e5e0c5daa5
commit
8b176f062b
4 changed files with 23 additions and 8 deletions
|
@ -5,9 +5,9 @@ import com.unciv.logic.battle.Battle
|
|||
import com.unciv.logic.battle.MapUnitCombatant
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.Notification
|
||||
import com.unciv.logic.civilization.getRandom
|
||||
import com.unciv.logic.map.TileMap
|
||||
import com.unciv.logic.map.UnitType
|
||||
import com.unciv.ui.utils.getRandom
|
||||
|
||||
class GameInfo {
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@ import com.unciv.models.gamebasics.ResourceType
|
|||
import com.unciv.models.gamebasics.TileResource
|
||||
import com.unciv.models.linq.Counter
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.ui.utils.getRandom
|
||||
import kotlin.math.max
|
||||
import kotlin.math.pow
|
||||
|
||||
|
||||
class CivilizationInfo {
|
||||
|
@ -46,7 +49,10 @@ class CivilizationInfo {
|
|||
statsForTurn.happiness = getHappinessForNextTurn().toFloat()
|
||||
|
||||
val transportationUpkeep = getTransportationUpkeep()
|
||||
statsForTurn.gold -= transportationUpkeep.toFloat()
|
||||
statsForTurn.gold -= transportationUpkeep
|
||||
|
||||
val unitUpkeep = getUnitUpkeep()
|
||||
statsForTurn.gold -= unitUpkeep
|
||||
|
||||
if (policies.isAdopted("Mandate Of Heaven"))
|
||||
statsForTurn.culture += statsForTurn.happiness / 2
|
||||
|
@ -55,6 +61,16 @@ class CivilizationInfo {
|
|||
return statsForTurn
|
||||
}
|
||||
|
||||
private fun getUnitUpkeep(): Int {
|
||||
val baseUnitCost = 0.5f
|
||||
val freeUnits = 3
|
||||
val totalPaidUnits = max(0,getCivUnits().count()-freeUnits)
|
||||
val gameProgress = gameInfo.turns/400f // as game progresses maintainance cost rises
|
||||
val cost = baseUnitCost*totalPaidUnits*(1+gameProgress)
|
||||
val finalCost = cost.pow(1+gameProgress/3) // Why 3? No reason.
|
||||
return finalCost.toInt()
|
||||
}
|
||||
|
||||
private fun getTransportationUpkeep(): Int {
|
||||
var transportationUpkeep = 0
|
||||
for (it in gameInfo.tileMap.values.filterNot { it.isCityCenter }) {
|
||||
|
@ -159,6 +175,4 @@ class CivilizationInfo {
|
|||
return viewablePositions
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun <E> List<E>.getRandom(): E = if (size == 0) throw Exception() else get((Math.random() * size).toInt())
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package com.unciv.logic.map
|
||||
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.unciv.logic.civilization.getRandom
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ResourceType
|
||||
import com.unciv.models.gamebasics.TerrainType
|
||||
import com.unciv.models.gamebasics.TileResource
|
||||
import com.unciv.ui.utils.HexMath
|
||||
import com.unciv.ui.utils.getRandom
|
||||
|
||||
class SeedRandomMapGenerator : RandomMapGenerator() {
|
||||
|
||||
|
@ -73,7 +73,7 @@ class SeedRandomMapGenerator : RandomMapGenerator() {
|
|||
|
||||
val mapToReturn = HashMap<String,TileInfo>()
|
||||
for (entry in map){
|
||||
mapToReturn.put(entry.key.toString(),entry.value!!)
|
||||
mapToReturn[entry.key.toString()] = entry.value!!
|
||||
}
|
||||
|
||||
return mapToReturn
|
||||
|
|
|
@ -104,4 +104,5 @@ fun TextButton.disable(){
|
|||
fun TextButton.enable() {
|
||||
color = Color.WHITE
|
||||
touchable = Touchable.enabled
|
||||
}
|
||||
}
|
||||
fun <E> List<E>.getRandom(): E = if (size == 0) throw Exception() else get((Math.random() * size).toInt())
|
Loading…
Reference in a new issue