mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-11 11:28:03 +07:00
Implemented Unit Supply by r3versi, not by me (#5234)
* Implemented Unit Supply Unit Supply is a soft cap to number of units. If the number of units of a civilization exceeds the total supply, a production malus (capped at 70%) is applied. * Warning icon & message for supply deficit * Implemented Unit Supply - atlas merge * Unit Supply: Malus->Penalty, lint, sumOf * Unit Supply: Fresh atlas Co-authored-by: r3versi <fluo392@gmail.com>
This commit is contained in:
parent
3d9c5bcc34
commit
340bedc7ea
BIN
android/Images/OtherIcons/ExclamationMark.png
Normal file
BIN
android/Images/OtherIcons/ExclamationMark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 1016 KiB After Width: | Height: | Size: 1017 KiB |
@ -5,6 +5,8 @@
|
|||||||
"extraHappinessPerLuxury": 1,
|
"extraHappinessPerLuxury": 1,
|
||||||
"researchCostModifier": 0.9,
|
"researchCostModifier": 0.9,
|
||||||
"unitCostModifier": 0.5,
|
"unitCostModifier": 0.5,
|
||||||
|
"unitSupplyBase": 10,
|
||||||
|
"unitSupplyPerCity": 3,
|
||||||
"buildingCostModifier": 0.5,
|
"buildingCostModifier": 0.5,
|
||||||
"policyCostModifier": 0.5,
|
"policyCostModifier": 0.5,
|
||||||
"unhappinessModifier": 0.4,
|
"unhappinessModifier": 0.4,
|
||||||
@ -16,6 +18,7 @@
|
|||||||
"aiWonderCostModifier": 1.6,
|
"aiWonderCostModifier": 1.6,
|
||||||
"aiBuildingMaintenanceModifier": 1,
|
"aiBuildingMaintenanceModifier": 1,
|
||||||
"aiUnitMaintenanceModifier": 1,
|
"aiUnitMaintenanceModifier": 1,
|
||||||
|
"aiUnitSupplyModifier": 0,
|
||||||
"aiFreeTechs": [],
|
"aiFreeTechs": [],
|
||||||
"aiMajorCivBonusStartingUnits": [],
|
"aiMajorCivBonusStartingUnits": [],
|
||||||
"aiCityStateBonusStartingUnits": [],
|
"aiCityStateBonusStartingUnits": [],
|
||||||
@ -30,6 +33,8 @@
|
|||||||
"extraHappinessPerLuxury": 1,
|
"extraHappinessPerLuxury": 1,
|
||||||
"researchCostModifier": 0.95,
|
"researchCostModifier": 0.95,
|
||||||
"unitCostModifier": 0.67,
|
"unitCostModifier": 0.67,
|
||||||
|
"unitSupplyBase": 7,
|
||||||
|
"unitSupplyPerCity": 3,
|
||||||
"buildingCostModifier": 0.67,
|
"buildingCostModifier": 0.67,
|
||||||
"policyCostModifier": 0.67,
|
"policyCostModifier": 0.67,
|
||||||
"unhappinessModifier": 0.6,
|
"unhappinessModifier": 0.6,
|
||||||
@ -41,6 +46,7 @@
|
|||||||
"aiWonderCostModifier": 1.3,
|
"aiWonderCostModifier": 1.3,
|
||||||
"aiBuildingMaintenanceModifier": 1,
|
"aiBuildingMaintenanceModifier": 1,
|
||||||
"aiUnitMaintenanceModifier": 1,
|
"aiUnitMaintenanceModifier": 1,
|
||||||
|
"aiUnitSupplyModifier": 0,
|
||||||
"aiFreeTechs": [],
|
"aiFreeTechs": [],
|
||||||
"aiMajorCivBonusStartingUnits": [],
|
"aiMajorCivBonusStartingUnits": [],
|
||||||
"aiCityStateBonusStartingUnits": [],
|
"aiCityStateBonusStartingUnits": [],
|
||||||
@ -55,6 +61,8 @@
|
|||||||
"extraHappinessPerLuxury": 0,
|
"extraHappinessPerLuxury": 0,
|
||||||
"researchCostModifier": 1,
|
"researchCostModifier": 1,
|
||||||
"unitCostModifier": 0.85,
|
"unitCostModifier": 0.85,
|
||||||
|
"unitSupplyBase": 7,
|
||||||
|
"unitSupplyPerCity": 2,
|
||||||
"buildingCostModifier": 0.85,
|
"buildingCostModifier": 0.85,
|
||||||
"policyCostModifier": 0.85,
|
"policyCostModifier": 0.85,
|
||||||
"unhappinessModifier": 0.75,
|
"unhappinessModifier": 0.75,
|
||||||
@ -66,6 +74,7 @@
|
|||||||
"aiWonderCostModifier": 1.1,
|
"aiWonderCostModifier": 1.1,
|
||||||
"aiBuildingMaintenanceModifier": 1,
|
"aiBuildingMaintenanceModifier": 1,
|
||||||
"aiUnitMaintenanceModifier": 1,
|
"aiUnitMaintenanceModifier": 1,
|
||||||
|
"aiUnitSupplyModifier": 0.1,
|
||||||
"aiFreeTechs": [],
|
"aiFreeTechs": [],
|
||||||
"aiMajorCivBonusStartingUnits": [],
|
"aiMajorCivBonusStartingUnits": [],
|
||||||
"aiCityStateBonusStartingUnits": [],
|
"aiCityStateBonusStartingUnits": [],
|
||||||
@ -80,6 +89,8 @@
|
|||||||
"extraHappinessPerLuxury": 0,
|
"extraHappinessPerLuxury": 0,
|
||||||
"researchCostModifier": 1,
|
"researchCostModifier": 1,
|
||||||
"unitCostModifier": 1,
|
"unitCostModifier": 1,
|
||||||
|
"unitSupplyBase": 5,
|
||||||
|
"unitSupplyPerCity": 2,
|
||||||
"buildingCostModifier": 1,
|
"buildingCostModifier": 1,
|
||||||
"policyCostModifier": 1,
|
"policyCostModifier": 1,
|
||||||
"unhappinessModifier": 1,
|
"unhappinessModifier": 1,
|
||||||
@ -91,6 +102,7 @@
|
|||||||
"aiWonderCostModifier": 1,
|
"aiWonderCostModifier": 1,
|
||||||
"aiBuildingMaintenanceModifier": 1,
|
"aiBuildingMaintenanceModifier": 1,
|
||||||
"aiUnitMaintenanceModifier": 0.85,
|
"aiUnitMaintenanceModifier": 0.85,
|
||||||
|
"aiUnitSupplyModifier": 0.2,
|
||||||
"aiFreeTechs": [],
|
"aiFreeTechs": [],
|
||||||
"aiMajorCivBonusStartingUnits": [],
|
"aiMajorCivBonusStartingUnits": [],
|
||||||
"aiCityStateBonusStartingUnits": [],
|
"aiCityStateBonusStartingUnits": [],
|
||||||
@ -105,6 +117,8 @@
|
|||||||
"extraHappinessPerLuxury": 0,
|
"extraHappinessPerLuxury": 0,
|
||||||
"researchCostModifier": 1,
|
"researchCostModifier": 1,
|
||||||
"unitCostModifier": 1,
|
"unitCostModifier": 1,
|
||||||
|
"unitSupplyBase": 5,
|
||||||
|
"unitSupplyPerCity": 2,
|
||||||
"buildingCostModifier": 1,
|
"buildingCostModifier": 1,
|
||||||
"policyCostModifier": 1,
|
"policyCostModifier": 1,
|
||||||
"unhappinessModifier": 1,
|
"unhappinessModifier": 1,
|
||||||
@ -116,6 +130,7 @@
|
|||||||
"aiWonderCostModifier": 1,
|
"aiWonderCostModifier": 1,
|
||||||
"aiBuildingMaintenanceModifier": 0.85,
|
"aiBuildingMaintenanceModifier": 0.85,
|
||||||
"aiUnitMaintenanceModifier": 0.8,
|
"aiUnitMaintenanceModifier": 0.8,
|
||||||
|
"aiUnitSupplyModifier": 0.3,
|
||||||
"aiFreeTechs": ["Pottery"],
|
"aiFreeTechs": ["Pottery"],
|
||||||
"aiMajorCivBonusStartingUnits": ["Era Starting Unit"],
|
"aiMajorCivBonusStartingUnits": ["Era Starting Unit"],
|
||||||
"aiCityStateBonusStartingUnits": [],
|
"aiCityStateBonusStartingUnits": [],
|
||||||
@ -130,6 +145,8 @@
|
|||||||
"extraHappinessPerLuxury": 0,
|
"extraHappinessPerLuxury": 0,
|
||||||
"researchCostModifier": 1,
|
"researchCostModifier": 1,
|
||||||
"unitCostModifier": 1,
|
"unitCostModifier": 1,
|
||||||
|
"unitSupplyBase": 5,
|
||||||
|
"unitSupplyPerCity": 2,
|
||||||
"buildingCostModifier": 1,
|
"buildingCostModifier": 1,
|
||||||
"policyCostModifier": 1,
|
"policyCostModifier": 1,
|
||||||
"unhappinessModifier": 1,
|
"unhappinessModifier": 1,
|
||||||
@ -141,6 +158,7 @@
|
|||||||
"aiWonderCostModifier": 1,
|
"aiWonderCostModifier": 1,
|
||||||
"aiBuildingMaintenanceModifier": 0.8,
|
"aiBuildingMaintenanceModifier": 0.8,
|
||||||
"aiUnitMaintenanceModifier": 0.75,
|
"aiUnitMaintenanceModifier": 0.75,
|
||||||
|
"aiUnitSupplyModifier": 0.3,
|
||||||
"aiFreeTechs": ["Pottery","Animal Husbandry"],
|
"aiFreeTechs": ["Pottery","Animal Husbandry"],
|
||||||
"aiMajorCivBonusStartingUnits": ["Era Starting Unit", "Scout"],
|
"aiMajorCivBonusStartingUnits": ["Era Starting Unit", "Scout"],
|
||||||
"aiCityStateBonusStartingUnits": [],
|
"aiCityStateBonusStartingUnits": [],
|
||||||
@ -155,6 +173,8 @@
|
|||||||
"extraHappinessPerLuxury": 0,
|
"extraHappinessPerLuxury": 0,
|
||||||
"researchCostModifier": 1,
|
"researchCostModifier": 1,
|
||||||
"unitCostModifier": 1,
|
"unitCostModifier": 1,
|
||||||
|
"unitSupplyBase": 5,
|
||||||
|
"unitSupplyPerCity": 2,
|
||||||
"buildingCostModifier": 1,
|
"buildingCostModifier": 1,
|
||||||
"policyCostModifier": 1,
|
"policyCostModifier": 1,
|
||||||
"unhappinessModifier": 1,
|
"unhappinessModifier": 1,
|
||||||
@ -166,6 +186,7 @@
|
|||||||
"aiWonderCostModifier": 1,
|
"aiWonderCostModifier": 1,
|
||||||
"aiBuildingMaintenanceModifier": 0.65,
|
"aiBuildingMaintenanceModifier": 0.65,
|
||||||
"aiUnitMaintenanceModifier": 0.65,
|
"aiUnitMaintenanceModifier": 0.65,
|
||||||
|
"aiUnitSupplyModifier": 0.4,
|
||||||
"aiFreeTechs": ["Pottery","Animal Husbandry","Mining"],
|
"aiFreeTechs": ["Pottery","Animal Husbandry","Mining"],
|
||||||
"aiMajorCivBonusStartingUnits": ["Worker", "Scout", "Era Starting Unit", "Era Starting Unit"],
|
"aiMajorCivBonusStartingUnits": ["Worker", "Scout", "Era Starting Unit", "Era Starting Unit"],
|
||||||
"aiCityStateBonusStartingUnits": [],
|
"aiCityStateBonusStartingUnits": [],
|
||||||
@ -180,6 +201,8 @@
|
|||||||
"extraHappinessPerLuxury": 0,
|
"extraHappinessPerLuxury": 0,
|
||||||
"researchCostModifier": 1,
|
"researchCostModifier": 1,
|
||||||
"unitCostModifier": 1,
|
"unitCostModifier": 1,
|
||||||
|
"unitSupplyBase": 5,
|
||||||
|
"unitSupplyPerCity": 2,
|
||||||
"buildingCostModifier": 1,
|
"buildingCostModifier": 1,
|
||||||
"policyCostModifier": 1,
|
"policyCostModifier": 1,
|
||||||
"unhappinessModifier": 1,
|
"unhappinessModifier": 1,
|
||||||
@ -191,6 +214,7 @@
|
|||||||
"aiWonderCostModifier": 1,
|
"aiWonderCostModifier": 1,
|
||||||
"aiBuildingMaintenanceModifier": 0.5,
|
"aiBuildingMaintenanceModifier": 0.5,
|
||||||
"aiUnitMaintenanceModifier": 0.5,
|
"aiUnitMaintenanceModifier": 0.5,
|
||||||
|
"aiUnitSupplyModifier": 0.5,
|
||||||
"aiFreeTechs": ["Pottery","Animal Husbandry","Mining","The Wheel"],
|
"aiFreeTechs": ["Pottery","Animal Husbandry","Mining","The Wheel"],
|
||||||
"aiMajorCivBonusStartingUnits": ["Settler", "Worker", "Scout", "Era Starting Unit", "Era Starting Unit", "Era Starting Unit"],
|
"aiMajorCivBonusStartingUnits": ["Settler", "Worker", "Scout", "Era Starting Unit", "Era Starting Unit", "Era Starting Unit"],
|
||||||
"aiCityStateBonusStartingUnits": [],
|
"aiCityStateBonusStartingUnits": [],
|
||||||
|
@ -862,6 +862,13 @@ Transportation upkeep =
|
|||||||
Unit upkeep =
|
Unit upkeep =
|
||||||
Trades =
|
Trades =
|
||||||
Units =
|
Units =
|
||||||
|
Unit Supply =
|
||||||
|
Base Supply =
|
||||||
|
Total Supply =
|
||||||
|
In Use =
|
||||||
|
Supply Deficit =
|
||||||
|
Production Penalty =
|
||||||
|
Increase your supply or reduce the amount of units to remove the production penalty =
|
||||||
Name =
|
Name =
|
||||||
Closest city =
|
Closest city =
|
||||||
Action =
|
Action =
|
||||||
|
@ -320,6 +320,14 @@ class CityStats(val cityInfo: CityInfo) {
|
|||||||
return stats
|
return stats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getStatPercentBonusesFromUnitSupply(): Stats {
|
||||||
|
val stats = Stats()
|
||||||
|
val supplyDeficit = cityInfo.civInfo.stats().getUnitSupplyDeficit()
|
||||||
|
if (supplyDeficit > 0)
|
||||||
|
stats.production = cityInfo.civInfo.stats().getUnitSupplyProductionPenalty()
|
||||||
|
return stats
|
||||||
|
}
|
||||||
|
|
||||||
private fun constructionMatchesFilter(construction: IConstruction, filter: String): Boolean {
|
private fun constructionMatchesFilter(construction: IConstruction, filter: String): Boolean {
|
||||||
if (construction is Building) return construction.matchesFilter(filter)
|
if (construction is Building) return construction.matchesFilter(filter)
|
||||||
if (construction is BaseUnit) return construction.matchesFilter(filter)
|
if (construction is BaseUnit) return construction.matchesFilter(filter)
|
||||||
@ -465,6 +473,7 @@ class CityStats(val cityInfo: CityInfo) {
|
|||||||
newStatPercentBonusList["National ability"] = getStatPercentBonusesFromNationUnique(currentConstruction)
|
newStatPercentBonusList["National ability"] = getStatPercentBonusesFromNationUnique(currentConstruction)
|
||||||
newStatPercentBonusList["Puppet City"] = getStatPercentBonusesFromPuppetCity()
|
newStatPercentBonusList["Puppet City"] = getStatPercentBonusesFromPuppetCity()
|
||||||
newStatPercentBonusList["Religion"] = getStatPercentBonusesFromUniques(currentConstruction, cityInfo.religion.getUniques())
|
newStatPercentBonusList["Religion"] = getStatPercentBonusesFromUniques(currentConstruction, cityInfo.religion.getUniques())
|
||||||
|
newStatPercentBonusList["Unit Supply"] = getStatPercentBonusesFromUnitSupply()
|
||||||
|
|
||||||
if (UncivGame.Current.superchargedForDebug) {
|
if (UncivGame.Current.superchargedForDebug) {
|
||||||
val stats = Stats()
|
val stats = Stats()
|
||||||
|
@ -87,6 +87,24 @@ class CivInfoStats(val civInfo: CivilizationInfo) {
|
|||||||
return transportationUpkeep
|
return transportationUpkeep
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getUnitSupply(): Int {
|
||||||
|
/* TotalSupply = BaseSupply + NumCities*modifier + Population*modifier
|
||||||
|
* In civ5, it seems population modifier is always 0.5, so i hardcoded it down below */
|
||||||
|
var supply = getBaseUnitSupply() + getUnitSupplyFromCities() + getUnitSupplyFromPop()
|
||||||
|
|
||||||
|
if (civInfo.isMajorCiv() && civInfo.playerType == PlayerType.AI)
|
||||||
|
supply = (supply*(1f + civInfo.getDifficulty().aiUnitSupplyModifier)).toInt()
|
||||||
|
return supply
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBaseUnitSupply(): Int = civInfo.getDifficulty().unitSupplyBase
|
||||||
|
fun getUnitSupplyFromCities(): Int = civInfo.cities.size * civInfo.getDifficulty().unitSupplyPerCity
|
||||||
|
fun getUnitSupplyFromPop(): Int = civInfo.cities.sumOf { it.population.population } / 2
|
||||||
|
fun getUnitSupplyDeficit(): Int = max(0,civInfo.getCivUnitsSize() - getUnitSupply())
|
||||||
|
|
||||||
|
/** Per each supply missing, a player gets -10% production. Capped at -70%. */
|
||||||
|
fun getUnitSupplyProductionPenalty(): Float = -min(getUnitSupplyDeficit() * 10f, 70f)
|
||||||
|
|
||||||
fun getStatMapForNextTurn(): StatMap {
|
fun getStatMapForNextTurn(): StatMap {
|
||||||
val statMap = StatMap()
|
val statMap = StatMap()
|
||||||
for (city in civInfo.cities) {
|
for (city in civInfo.cities) {
|
||||||
|
@ -329,6 +329,7 @@ class CivilizationInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//region Units
|
//region Units
|
||||||
|
fun getCivUnitsSize(): Int = units.size
|
||||||
fun getCivUnits(): Sequence<MapUnit> = units.asSequence()
|
fun getCivUnits(): Sequence<MapUnit> = units.asSequence()
|
||||||
fun getCivGreatPeople(): Sequence<MapUnit> = getCivUnits().filter { mapUnit -> mapUnit.isGreatPerson() }
|
fun getCivGreatPeople(): Sequence<MapUnit> = getCivUnits().filter { mapUnit -> mapUnit.isGreatPerson() }
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ class Difficulty: INamed, ICivilopediaText {
|
|||||||
var extraHappinessPerLuxury: Float = 0f
|
var extraHappinessPerLuxury: Float = 0f
|
||||||
var researchCostModifier:Float = 1f
|
var researchCostModifier:Float = 1f
|
||||||
var unitCostModifier:Float = 1f
|
var unitCostModifier:Float = 1f
|
||||||
|
var unitSupplyBase: Int = 0
|
||||||
|
var unitSupplyPerCity: Int = 0
|
||||||
var buildingCostModifier:Float = 1f
|
var buildingCostModifier:Float = 1f
|
||||||
var policyCostModifier:Float = 1f
|
var policyCostModifier:Float = 1f
|
||||||
var unhappinessModifier:Float = 1f
|
var unhappinessModifier:Float = 1f
|
||||||
@ -23,6 +25,7 @@ class Difficulty: INamed, ICivilopediaText {
|
|||||||
var aiWonderCostModifier:Float = 1f
|
var aiWonderCostModifier:Float = 1f
|
||||||
var aiBuildingMaintenanceModifier:Float = 1f
|
var aiBuildingMaintenanceModifier:Float = 1f
|
||||||
var aiUnitMaintenanceModifier = 1f
|
var aiUnitMaintenanceModifier = 1f
|
||||||
|
var aiUnitSupplyModifier: Float = 0f
|
||||||
var aiFreeTechs = ArrayList<String>()
|
var aiFreeTechs = ArrayList<String>()
|
||||||
var aiMajorCivBonusStartingUnits = ArrayList<String>()
|
var aiMajorCivBonusStartingUnits = ArrayList<String>()
|
||||||
var aiCityStateBonusStartingUnits = ArrayList<String>()
|
var aiCityStateBonusStartingUnits = ArrayList<String>()
|
||||||
|
@ -2,6 +2,7 @@ package com.unciv.ui.overviewscreen
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
@ -14,14 +15,56 @@ import kotlin.math.abs
|
|||||||
* Supplies the Unit sub-table for the Empire Overview
|
* Supplies the Unit sub-table for the Empire Overview
|
||||||
*/
|
*/
|
||||||
class UnitOverviewTable(
|
class UnitOverviewTable(
|
||||||
viewingPlayer: CivilizationInfo,
|
private val viewingPlayer: CivilizationInfo,
|
||||||
overviewScreen: EmpireOverviewScreen
|
private val overviewScreen: EmpireOverviewScreen
|
||||||
) : Table(CameraStageBaseScreen.skin) {
|
) : Table(CameraStageBaseScreen.skin) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val game = overviewScreen.game
|
add(getUnitSupplyTable()).top().padRight(25f)
|
||||||
|
add(getUnitListTable())
|
||||||
|
pack()
|
||||||
|
}
|
||||||
|
|
||||||
defaults().pad(5f)
|
private fun getUnitSupplyTable(): Table {
|
||||||
|
val unitSupplyTable = Table(CameraStageBaseScreen.skin)
|
||||||
|
unitSupplyTable.defaults().pad(5f)
|
||||||
|
unitSupplyTable.apply {
|
||||||
|
add("Unit Supply".tr()).colspan(2).center().row()
|
||||||
|
addSeparator()
|
||||||
|
add("Base Supply".tr()).left()
|
||||||
|
add(viewingPlayer.stats().getBaseUnitSupply().toLabel()).right().row()
|
||||||
|
add("Cities".tr()).left()
|
||||||
|
add(viewingPlayer.stats().getUnitSupplyFromCities().toLabel()).right().row()
|
||||||
|
add("Population".tr()).left()
|
||||||
|
add(viewingPlayer.stats().getUnitSupplyFromPop().toLabel()).right().row()
|
||||||
|
addSeparator()
|
||||||
|
add("Total Supply".tr()).left()
|
||||||
|
add(viewingPlayer.stats().getUnitSupply().toLabel()).right().row()
|
||||||
|
add("In Use".tr()).left()
|
||||||
|
add(viewingPlayer.getCivUnitsSize().toLabel()).right().row()
|
||||||
|
addSeparator()
|
||||||
|
val deficit = viewingPlayer.stats().getUnitSupplyDeficit()
|
||||||
|
add("Supply Deficit".tr()).left()
|
||||||
|
add(deficit.toLabel()).right().row()
|
||||||
|
add("Production Penalty".tr()).left()
|
||||||
|
add((viewingPlayer.stats().getUnitSupplyProductionPenalty()).toInt().toString()+"%").right().row()
|
||||||
|
if (deficit > 0) {
|
||||||
|
val penaltyLabel = "Increase your supply or reduce the amount of units to remove the production penalty"
|
||||||
|
.toLabel(Color.FIREBRICK)
|
||||||
|
penaltyLabel.wrap = true
|
||||||
|
add(penaltyLabel).colspan(2).left()
|
||||||
|
.width(overviewScreen.stage.width * 0.2f).row()
|
||||||
|
}
|
||||||
|
pack()
|
||||||
|
}
|
||||||
|
return unitSupplyTable
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getUnitListTable(): Table {
|
||||||
|
val game = overviewScreen.game
|
||||||
|
val unitListTable = Table(CameraStageBaseScreen.skin)
|
||||||
|
unitListTable.defaults().pad(5f)
|
||||||
|
unitListTable.apply {
|
||||||
add("Name".tr())
|
add("Name".tr())
|
||||||
add("Action".tr())
|
add("Action".tr())
|
||||||
add(Fonts.strength.toString())
|
add(Fonts.strength.toString())
|
||||||
@ -33,8 +76,12 @@ class UnitOverviewTable(
|
|||||||
row()
|
row()
|
||||||
addSeparator()
|
addSeparator()
|
||||||
|
|
||||||
for (unit in viewingPlayer.getCivUnits().sortedWith(compareBy({ it.displayName() }, { !it.due },
|
for (unit in viewingPlayer.getCivUnits().sortedWith(
|
||||||
{ it.currentMovement < 0.1f }, { abs(it.currentTile.position.x) + abs(it.currentTile.position.y) }))) {
|
compareBy({ it.displayName() },
|
||||||
|
{ !it.due },
|
||||||
|
{ it.currentMovement < 0.1f },
|
||||||
|
{ abs(it.currentTile.position.x) + abs(it.currentTile.position.y) })
|
||||||
|
)) {
|
||||||
val baseUnit = unit.baseUnit()
|
val baseUnit = unit.baseUnit()
|
||||||
|
|
||||||
val button = Button(skin)
|
val button = Button(skin)
|
||||||
@ -50,14 +97,24 @@ class UnitOverviewTable(
|
|||||||
if (baseUnit.strength > 0) add(baseUnit.strength.toString()) else add()
|
if (baseUnit.strength > 0) add(baseUnit.strength.toString()) else add()
|
||||||
if (baseUnit.rangedStrength > 0) add(baseUnit.rangedStrength.toString()) else add()
|
if (baseUnit.rangedStrength > 0) add(baseUnit.rangedStrength.toString()) else add()
|
||||||
add(DecimalFormat("0.#").format(unit.currentMovement) + "/" + unit.getMaxMovement())
|
add(DecimalFormat("0.#").format(unit.currentMovement) + "/" + unit.getMaxMovement())
|
||||||
val closestCity = unit.getTile().getTilesInDistance(3).firstOrNull { it.isCityCenter() }
|
val closestCity =
|
||||||
|
unit.getTile().getTilesInDistance(3).firstOrNull { it.isCityCenter() }
|
||||||
if (closestCity != null) add(closestCity.getCity()!!.name.tr()) else add()
|
if (closestCity != null) add(closestCity.getCity()!!.name.tr()) else add()
|
||||||
val promotionsTable = Table()
|
val promotionsTable = Table()
|
||||||
val promotionsForUnit = unit.civInfo.gameInfo.ruleSet.unitPromotions.values.filter { unit.promotions.promotions.contains(it.name) } // force same sorting as on picker (.sorted() would be simpler code, but...)
|
val promotionsForUnit = unit.civInfo.gameInfo.ruleSet.unitPromotions.values.filter {
|
||||||
|
unit.promotions.promotions.contains(it.name)
|
||||||
|
} // force same sorting as on picker (.sorted() would be simpler code, but...)
|
||||||
for (promotion in promotionsForUnit)
|
for (promotion in promotionsForUnit)
|
||||||
promotionsTable.add(ImageGetter.getPromotionIcon(promotion.name))
|
promotionsTable.add(ImageGetter.getPromotionIcon(promotion.name))
|
||||||
if (unit.promotions.canBePromoted()) promotionsTable.add(ImageGetter.getImage("OtherIcons/Star").apply { color = Color.GOLDENROD }).size(24f).padLeft(8f)
|
if (unit.promotions.canBePromoted()) promotionsTable.add(
|
||||||
if (unit.canUpgrade()) promotionsTable.add(ImageGetter.getUnitIcon(unit.getUnitToUpgradeTo().name, Color.GREEN)).size(28f).padLeft(8f)
|
ImageGetter.getImage("OtherIcons/Star").apply { color = Color.GOLDENROD })
|
||||||
|
.size(24f).padLeft(8f)
|
||||||
|
if (unit.canUpgrade()) promotionsTable.add(
|
||||||
|
ImageGetter.getUnitIcon(
|
||||||
|
unit.getUnitToUpgradeTo().name,
|
||||||
|
Color.GREEN
|
||||||
|
)
|
||||||
|
).size(28f).padLeft(8f)
|
||||||
promotionsTable.onClick {
|
promotionsTable.onClick {
|
||||||
if (unit.promotions.canBePromoted() || unit.promotions.promotions.isNotEmpty()) {
|
if (unit.promotions.canBePromoted() || unit.promotions.promotions.isNotEmpty()) {
|
||||||
game.setScreen(PromotionPickerScreen(unit))
|
game.setScreen(PromotionPickerScreen(unit))
|
||||||
@ -67,6 +124,7 @@ class UnitOverviewTable(
|
|||||||
if (unit.health < 100) add(unit.health.toString()) else add()
|
if (unit.health < 100) add(unit.health.toString()) else add()
|
||||||
row()
|
row()
|
||||||
}
|
}
|
||||||
pack()
|
}
|
||||||
|
return unitListTable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,15 +158,27 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
|||||||
return menuButton
|
return menuButton
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getOverviewButton(): Button {
|
private fun getOverviewButton(): Table {
|
||||||
|
val rightTable = Table(CameraStageBaseScreen.skin).apply{ defaults().pad(10f) }
|
||||||
|
|
||||||
|
val unitSupplyImage = ImageGetter.getImage("OtherIcons/ExclamationMark")
|
||||||
|
.apply { color = Color.FIREBRICK }
|
||||||
|
.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv, "Units")) }
|
||||||
|
|
||||||
val overviewButton = Button(CameraStageBaseScreen.skin)
|
val overviewButton = Button(CameraStageBaseScreen.skin)
|
||||||
overviewButton.add("Overview".toLabel()).pad(10f)
|
overviewButton.add("Overview".toLabel()).pad(10f)
|
||||||
overviewButton.addTooltip('e')
|
overviewButton.addTooltip('e')
|
||||||
overviewButton.pack()
|
|
||||||
overviewButton.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv)) }
|
overviewButton.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.selectedCiv)) }
|
||||||
overviewButton.centerY(this)
|
|
||||||
overviewButton.x = worldScreen.stage.width - overviewButton.width - 10
|
if (worldScreen.selectedCiv.stats().getUnitSupplyDeficit() > 0)
|
||||||
return overviewButton
|
rightTable.add(unitSupplyImage).size(50f)
|
||||||
|
rightTable.add(overviewButton)
|
||||||
|
|
||||||
|
rightTable.pack()
|
||||||
|
rightTable.centerY(this)
|
||||||
|
rightTable.x = worldScreen.stage.width - rightTable.width - 10
|
||||||
|
|
||||||
|
return rightTable
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getSelectedCivilizationTable(): Table {
|
private fun getSelectedCivilizationTable(): Table {
|
||||||
|
Loading…
Reference in New Issue
Block a user