mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 19:43:13 -04:00
Change save promotion from unitType to just baseUnit (#12960)
* Settler settle best tile when not escort and dangerous Tiles instead of running away Settler unit will now settle on best tile in dangerous Tiles without escort instead of running away. * Update WorkerAutomation.kt * Update SpecificUnitAutomation.kt * Update WorkerAutomation.kt * Update SpecificUnitAutomation.kt * Now city states get mad when you steal their Lands * new version * change to getDiplomacyManagerOrMeet * added text to template.properties and changed AlertPopup.kt * Update template.properties * with period at the end :b * add flag now * Made Option to declare war when a city state is bullied unavailable * added option to change the Maximum Autosave turns stored * remove print * change letter * should fix issue with building test * update with changes * Added UniqueType.FoundPuppetCity with "Founds a new puppet city" in "uniques" of an unit in Units.json. Making it so you can now settle a puppet city. * Added save promotion * Updated for PR * Updated with requested changes * Removed unnecessary check * updated PR * Update PromotionPickerScreen.kt to save promotion cells too * change name and added ! * updated name of variable * updated version from unitType to BaseUnit * updated variable name * Added unitType to reduce the xp cost of promotions for all units in a civ This was a unique type that the Zulu have in civ 5 * updated name * remove UniqueTarget.FollowerBelief * Experience from to XP * fix ? * XP * change it back to Experience because it didn't want to build on git :( * back to XP then * update auto promotion and fix negative XP on unit * Fix build issues and remove the XPForPromotionModifier from xpForNextPromotion and xpForNextNPromotions * remove XPForPromotionModifier * re added Statuses and remove duplicate comment * remove some white space and 1 used import "com.unciv.ui.components.extensions.toPercent" * remove unique from uniques.md
This commit is contained in:
parent
733df5f282
commit
3e6cb2c80e
@ -114,7 +114,7 @@ Cannot be purchased =
|
|||||||
Can only be purchased =
|
Can only be purchased =
|
||||||
See also =
|
See also =
|
||||||
Use default promotions =
|
Use default promotions =
|
||||||
Default promotions for [unitType] =
|
Default promotions for [unitName] =
|
||||||
Statuses =
|
Statuses =
|
||||||
|
|
||||||
Requires at least one of the following: =
|
Requires at least one of the following: =
|
||||||
|
@ -93,9 +93,9 @@ class City : IsPartOfGameInfoSerialization, INamed {
|
|||||||
var isPuppet = false
|
var isPuppet = false
|
||||||
var shouldReassignPopulation = false // flag so that on startTurn() we reassign population
|
var shouldReassignPopulation = false // flag so that on startTurn() we reassign population
|
||||||
|
|
||||||
var unitTypeShouldUseSavedPromotion = HashMap<String, Boolean>()
|
var unitShouldUseSavedPromotion = HashMap<String, Boolean>()
|
||||||
|
|
||||||
var cityUnitTypePromotions = HashMap<String, UnitPromotions>()
|
var unitToPromotions = HashMap<String, UnitPromotions>()
|
||||||
|
|
||||||
@delegate:Transient
|
@delegate:Transient
|
||||||
val neighboringCities: List<City> by lazy {
|
val neighboringCities: List<City> by lazy {
|
||||||
@ -158,8 +158,8 @@ class City : IsPartOfGameInfoSerialization, INamed {
|
|||||||
toReturn.avoidGrowth = avoidGrowth
|
toReturn.avoidGrowth = avoidGrowth
|
||||||
toReturn.manualSpecialists = manualSpecialists
|
toReturn.manualSpecialists = manualSpecialists
|
||||||
toReturn.connectedToCapitalStatus = connectedToCapitalStatus
|
toReturn.connectedToCapitalStatus = connectedToCapitalStatus
|
||||||
toReturn.unitTypeShouldUseSavedPromotion = unitTypeShouldUseSavedPromotion
|
toReturn.unitShouldUseSavedPromotion = unitShouldUseSavedPromotion
|
||||||
toReturn.cityUnitTypePromotions = cityUnitTypePromotions
|
toReturn.unitToPromotions = unitToPromotions
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,12 +469,16 @@ class CityConstructions : IsPartOfGameInfoSerialization {
|
|||||||
// Check if the player want to rebuild the unit the saved promotion
|
// Check if the player want to rebuild the unit the saved promotion
|
||||||
// and null check.
|
// and null check.
|
||||||
// and finally check if the current unit has enough XP.
|
// and finally check if the current unit has enough XP.
|
||||||
val savedPromotion = city.cityUnitTypePromotions[unit.baseUnit.unitType]
|
val savedPromotion = city.unitToPromotions[unit.baseUnit.name]
|
||||||
if (city.unitTypeShouldUseSavedPromotion[unit.baseUnit.unitType] == true &&
|
if (city.unitShouldUseSavedPromotion[unit.baseUnit.name] == true &&
|
||||||
savedPromotion != null && unit.promotions.XP >= savedPromotion.XP) {
|
savedPromotion != null && unit.promotions.XP >= savedPromotion.XP) {
|
||||||
|
// sorting it to avoid getting Accuracy III before Accuracy I
|
||||||
for (promotions in savedPromotion.promotions) {
|
for (promotions in savedPromotion.promotions.sorted()) {
|
||||||
unit.promotions.addPromotion(promotions)
|
if (unit.promotions.XP >= savedPromotion.XP) {
|
||||||
|
unit.promotions.addPromotion(promotions)
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,13 +101,12 @@ class ConstructionInfoTable(val cityScreen: CityScreen) : Table() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (construction is BaseUnit) {
|
if (construction is BaseUnit) {
|
||||||
val unitType = construction.unitType
|
val baseUnit = construction.name
|
||||||
|
val buildUnitWithPromotions = city.unitShouldUseSavedPromotion[baseUnit]
|
||||||
val buildUnitWithPromotions = city.unitTypeShouldUseSavedPromotion[unitType]
|
|
||||||
|
|
||||||
if (buildUnitWithPromotions != null) {
|
if (buildUnitWithPromotions != null) {
|
||||||
row()
|
row()
|
||||||
add("Use default promotions".toCheckBox(buildUnitWithPromotions) {city.unitTypeShouldUseSavedPromotion[unitType] = it}).colspan(2).center()
|
add("Use default promotions".toCheckBox(buildUnitWithPromotions) {city.unitShouldUseSavedPromotion[baseUnit] = it}).colspan(2).center()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,20 +199,21 @@ class PromotionPickerScreen private constructor(
|
|||||||
|
|
||||||
// adds the checkBoxs to choice to save unit promotion.
|
// adds the checkBoxs to choice to save unit promotion.
|
||||||
private fun saveUnitTypePromotionForCity() {
|
private fun saveUnitTypePromotionForCity() {
|
||||||
val checkBoxSaveUnitPromotion = "Default promotions for [${unit.baseUnit.unitType}]".toCheckBox(saveUnitTypePromotion) {saveUnitTypePromotion = it}
|
// if you are not in a city tile then don't show up
|
||||||
|
if (unit.currentTile.getCity() == null) return
|
||||||
|
val checkBoxSaveUnitPromotion = "Default promotions for [${unit.baseUnit.name}]".toCheckBox(saveUnitTypePromotion) {saveUnitTypePromotion = it}
|
||||||
promotionsTable.add(checkBoxSaveUnitPromotion)
|
promotionsTable.add(checkBoxSaveUnitPromotion)
|
||||||
}
|
}
|
||||||
|
|
||||||
// going to reuse this bit of code 2 time so turn it into a funtion
|
// going to reuse this bit of code 2 time so turn it into a funtion
|
||||||
private fun checkSaveUnitTypePrormotion() {
|
private fun checkSaveUnitTypePrormotion() {
|
||||||
if (!saveUnitTypePromotion) {
|
if (!saveUnitTypePromotion) return
|
||||||
val unitCurrentCity = unit.currentTile.getCity()
|
|
||||||
|
|
||||||
if (unitCurrentCity != null) {
|
val unitCurrentCity = unit.currentTile.getCity()
|
||||||
// If you are clicked the save unitType promotion, you want the next unitType to have the same promotion.
|
if (unitCurrentCity != null) {
|
||||||
unitCurrentCity.unitTypeShouldUseSavedPromotion.put(unit.baseUnit.unitType,true)
|
// If you are clicked the save baseUnit promotion, you want the next baseUnit to have the same promotion.
|
||||||
unitCurrentCity.cityUnitTypePromotions.put(unit.baseUnit.unitType,unit.promotions)
|
unitCurrentCity.unitShouldUseSavedPromotion[unit.baseUnit.name] = true
|
||||||
}
|
unitCurrentCity.unitToPromotions[unit.baseUnit.name] = unit.promotions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user