Skip to content

Commit

Permalink
Resolved #11082 - Added "Will not be replaced by automated units" unique
Browse files Browse the repository at this point in the history
  • Loading branch information
yairm210 committed Jun 17, 2024
1 parent bbea083 commit 79be14e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
16 changes: 11 additions & 5 deletions android/assets/jsons/Civ V - Gods & Kings/TileImprovements.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,30 @@
"name": "Academy",
"terrainsCanBeBuiltOn": ["Land"],
"science": 8,
"uniques": ["Great Improvement", "[+2 Science] <after discovering [Scientific Theory]>", "[+2 Science] <after discovering [Atomic Theory]>", "Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
"uniques": ["Great Improvement", "[+2 Science] <after discovering [Scientific Theory]>",
"[+2 Science] <after discovering [Atomic Theory]>", "Removes removable features when built",
"Will not be replaced by automated units", "Pillaging this improvement yields approximately [+20 Gold]"]
},
{
"name": "Landmark",
"terrainsCanBeBuiltOn": ["Land"],
"culture": 6,
"uniques": ["Great Improvement", "Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
"uniques": ["Great Improvement", "Removes removable features when built",
"Will not be replaced by automated units", "Pillaging this improvement yields approximately [+20 Gold]"]
},
{
"name": "Manufactory",
"terrainsCanBeBuiltOn": ["Land"],
"production": 4,
"uniques": ["Great Improvement", "[+1 Production] <after discovering [Chemistry]>", "Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
"uniques": ["Great Improvement", "[+1 Production] <after discovering [Chemistry]>", "Will not be replaced by automated units",
"Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
},
{
"name": "Customs house",
"terrainsCanBeBuiltOn": ["Land"],
"gold": 4,
"uniques": ["Great Improvement", "[+1 Gold] <after discovering [Economics]>", "Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
"uniques": ["Great Improvement", "[+1 Gold] <after discovering [Economics]>", "Removes removable features when built",
"Will not be replaced by automated units", "Pillaging this improvement yields approximately [+20 Gold]"]
},
{
"name": "Holy site",
Expand All @@ -230,6 +235,7 @@
"Can be built just outside your borders",
"Constructing it will take over the tiles around it and assign them to your closest city",
"Removes removable features when built",
"Will not be replaced by automated units"
]
},

Expand Down Expand Up @@ -278,7 +284,7 @@
{
"name": "City ruins",
"terrainsCanBeBuiltOn": ["Land"],
"uniques": ["Unpillagable", "Unbuildable", "Will be replaced by automated workers"],
"uniques": ["Unpillagable", "Unbuildable", "Will be replaced by automated units"],
"civilopediaText": [{"text":"A bleak reminder of the destruction wreaked by War"}]
},
{
Expand Down
18 changes: 12 additions & 6 deletions android/assets/jsons/Civ V - Vanilla/TileImprovements.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,31 +193,36 @@
"name": "Academy",
"terrainsCanBeBuiltOn": ["Land"],
"science": 8,
"uniques": ["Great Improvement", "[+2 Science] <after discovering [Scientific Theory]>", "Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
"uniques": ["Great Improvement", "[+2 Science] <after discovering [Scientific Theory]>", "Will not be replaced by automated units",
"Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
},
{
"name": "Landmark",
"terrainsCanBeBuiltOn": ["Land"],
"culture": 6,
"uniques": ["Great Improvement", "Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
"uniques": ["Great Improvement", "Removes removable features when built",
"Will not be replaced by automated units", "Pillaging this improvement yields approximately [+20 Gold]"]
},
{
"name": "Manufactory",
"terrainsCanBeBuiltOn": ["Land"],
"production": 4,
"uniques": ["Great Improvement", "[+1 Production] <after discovering [Chemistry]>", "Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
"uniques": ["Great Improvement", "[+1 Production] <after discovering [Chemistry]>", "Removes removable features when built",
"Will not be replaced by automated units", "Pillaging this improvement yields approximately [+20 Gold]"]
},
{
"name": "Customs house",
"terrainsCanBeBuiltOn": ["Land"],
"gold": 4,
"uniques": ["Great Improvement", "[+1 Gold] <after discovering [Economics]>", "Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
"uniques": ["Great Improvement", "[+1 Gold] <after discovering [Economics]>", "Removes removable features when built",
"Will not be replaced by automated units", "Pillaging this improvement yields approximately [+20 Gold]"]
},
{
"name": "Holy site",
"terrainsCanBeBuiltOn": ["Land"],
"faith": 6,
"uniques": ["Great Improvement", "Removes removable features when built", "Pillaging this improvement yields approximately [+20 Gold]"]
"uniques": ["Great Improvement", "Removes removable features when built",
"Will not be replaced by automated units", "Pillaging this improvement yields approximately [+20 Gold]"]
},
{
"name": "Citadel",
Expand All @@ -229,6 +234,7 @@
"Can be built just outside your borders",
"Constructing it will take over the tiles around it and assign them to your closest city",
"Removes removable features when built",
"Will not be replaced by automated units"
]
},

Expand Down Expand Up @@ -267,7 +273,7 @@
{
"name": "City ruins",
"terrainsCanBeBuiltOn": ["Land"],
"uniques": ["Unpillagable", "Unbuildable", "Will be replaced by automated workers"],
"uniques": ["Unpillagable", "Unbuildable", "Will be replaced by automated units"],
"civilopediaText": [{"text":"A bleak reminder of the destruction wreaked by War"}]
},
{
Expand Down
4 changes: 3 additions & 1 deletion core/src/com/unciv/logic/automation/Automation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ object Automation {
fun getTileForConstructionImprovement(city: City, improvement: TileImprovement): Tile? {
val localUniqueCache = LocalUniqueCache()
return city.getTiles().filter {
it.improvementFunctions.canBuildImprovement(improvement, city.civ)
it.getTileImprovement()?.hasUnique(UniqueType.AutomatedUnitsWillNotReplace,
StateForConditionals(city.civ, city, tile = it)) == false
&& it.improvementFunctions.canBuildImprovement(improvement, city.civ)
}.maxByOrNull {
rankTileForCityWork(it, city, localUniqueCache)
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/unciv/models/ruleset/unique/UniqueType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ enum class UniqueType(
PillageYieldRandom("Pillaging this improvement yields approximately [stats]", UniqueTarget.Improvement),
PillageYieldFixed("Pillaging this improvement yields [stats]", UniqueTarget.Improvement),
Irremovable("Irremovable", UniqueTarget.Improvement),
AutomatedWorkersWillReplace("Will be replaced by automated workers", UniqueTarget.Improvement),
AutomatedUnitsWillNotReplace("Will not be replaced by automated units", UniqueTarget.Improvement),
//endregion

/////////////////////////////////// region 07 PERSONALITY UNIQUES ////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions docs/Modders/uniques.md
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
??? example "Will be replaced by automated workers"
Applicable to: Improvement

??? example "Will not be replaced by automated workers"
Applicable to: Improvement

## Resource uniques
??? example "Deposits in [tileFilter] tiles always provide [amount] resources"
Example: "Deposits in [Farm] tiles always provide [3] resources"
Expand Down
19 changes: 0 additions & 19 deletions tests/src/com/unciv/testing/BasicTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.unciv.models.metadata.BaseRuleset
import com.unciv.models.metadata.GameSettings
import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.RulesetCache
import com.unciv.models.ruleset.RulesetStatsObject
import com.unciv.models.ruleset.unique.Unique
import com.unciv.models.ruleset.unique.UniqueParameterType
import com.unciv.models.ruleset.unique.UniqueType
Expand Down Expand Up @@ -176,24 +175,6 @@ class BasicTests {
Assert.assertTrue("This test succeeds only if all uniques of promotions are presented in UniqueType.values()", allOK)
}

@Test
fun allTerrainRelatedUniquesHaveTheirUniqueTypes() {
val objects : MutableCollection<RulesetStatsObject> = mutableListOf()
objects.addAll(ruleset.tileImprovements.values)
objects.addAll(ruleset.tileResources.values)
objects.addAll(ruleset.terrains.values)
var allOK = true
for (obj in objects) {
for (unique in obj.uniques) {
if (!UniqueType.values().any { it.placeholderText == unique.getPlaceholderText() }) {
debug("%s: %s", obj.name, unique)
allOK = false
}
}
}
Assert.assertTrue("This test succeeds only if all uniques are presented in UniqueType.values()", allOK)
}

@Test
fun allPolicyRelatedUniquesHaveTheirUniqueTypes() {
val policies = ruleset.policies.values
Expand Down

0 comments on commit 79be14e

Please sign in to comment.