From e292c210c809971440261a04230e05067557e23f Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 8 Oct 2020 17:35:25 +0300 Subject: [PATCH] Added "Must be next to []" unique for tile improvements --- .../assets/jsons/Civ V - Vanilla/TileImprovements.json | 8 ++++++-- core/src/com/unciv/logic/map/TileInfo.kt | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/TileImprovements.json b/android/assets/jsons/Civ V - Vanilla/TileImprovements.json index 000cf1b59c..74da212510 100644 --- a/android/assets/jsons/Civ V - Vanilla/TileImprovements.json +++ b/android/assets/jsons/Civ V - Vanilla/TileImprovements.json @@ -6,7 +6,9 @@ "food": 1, "turnsToBuild": 7, "techRequired": "Agriculture", - "uniques": ["Can also be built on tiles adjacent to fresh water", "[+1 Food] on [fresh water] tiles once [Civil Service] is discovered", "[+1 Food] on [non-fresh water] tiles once [Fertilizer] is discovered"], + "uniques": ["Can also be built on tiles adjacent to fresh water", + "[+1 Food] on [fresh water] tiles once [Civil Service] is discovered", + "[+1 Food] on [non-fresh water] tiles once [Fertilizer] is discovered"], }, { "name": "Lumber mill", @@ -184,7 +186,9 @@ "terrainsCanBeBuiltOn": ["Hill"], "food": 1, "turnsToBuild": 7, - "uniques": ["[+1 Food] for each adjacent [Mountain]", "Cannot be built on bonus resource", "[+1 Food] on [fresh water] tiles once [Civil Service] is discovered", "[+1 Food] on [non-fresh water] tiles once [Fertilizer] is discovered"], + "uniques": ["[+1 Food] for each adjacent [Mountain]", "Cannot be built on bonus resource", + "[+1 Food] on [fresh water] tiles once [Civil Service] is discovered", + "[+1 Food] on [non-fresh water] tiles once [Fertilizer] is discovered"], "techRequired": "Construction" }, diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 1b52193781..71b60a0267 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -307,6 +307,11 @@ open class TileInfo { "Cannot be built on bonus resource" in improvement.uniques && resource != null && getTileResource().resourceType == ResourceType.Bonus -> false improvement.terrainsCanBeBuiltOn.contains(topTerrain.name) -> true + improvement.uniqueObjects.filter { it.placeholderText == "Must be next to []" }.any { + val filter = it.params[0] + if (filter == "River") return@any !isAdjacentToRiver() + else return@any !neighbors.any { it.matchesUniqueFilter(filter) } + } -> false improvement.name == "Road" && roadStatus == RoadStatus.None -> true improvement.name == "Railroad" && this.roadStatus != RoadStatus.Railroad -> true improvement.name == "Remove Road" && this.roadStatus == RoadStatus.Road -> true