Recycling center (#5738)

* Add support to UniqueType.MaxNumberBuilding (including rejectionReasons)
Add Recycling Center entry to JSON
Need Graphical Icon

* Fix typo
Add TODO

* adding Recycling Center icon

* Credit update for icon
Rephrase Rejection text
Updated .atlas and .png
Add code to block showing Recycling Center

* Fix using placeholderText
Set shouldShow to True so iot still appears while under construction but not completed

* Rejection Text now working
Remove debug prints

* Remove odd extra lines

* extra lines

* Remove excessive if statement in shouldBeDisplayed
Reword text. Unique can apply to Buildings and Units
Refactor Signature since not just Buildings

* Adding code to remove building in transferred city

Co-authored-by: temurakami <spellman23@gmail.com>
This commit is contained in:
itanasi
2021-12-03 00:15:51 -08:00
committed by GitHub
parent 8060b69378
commit 7f07bcb9e5
10 changed files with 136 additions and 92 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -599,415 +599,422 @@ BuildingIcons/Pyramid
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Research Lab
BuildingIcons/Recycling Center
rotate: false
xy: 1192, 1142
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/SS Booster
BuildingIcons/Research Lab
rotate: false
xy: 1516, 1466
xy: 1300, 1250
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/SS Cockpit
BuildingIcons/SS Booster
rotate: false
xy: 1624, 1574
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/SS Engine
BuildingIcons/SS Cockpit
rotate: false
xy: 1732, 1683
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/SS Stasis Chamber
BuildingIcons/SS Engine
rotate: false
xy: 1840, 1790
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/SS Stasis Chamber
rotate: false
xy: 220, 62
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Satrap's Court
rotate: false
xy: 328, 170
xy: 436, 278
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Seaport
rotate: false
xy: 652, 494
xy: 760, 602
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Shrine
rotate: false
xy: 976, 818
xy: 1084, 932
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Sistine Chapel
rotate: false
xy: 1192, 1034
xy: 1300, 1142
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Solar Plant
rotate: false
xy: 1516, 1358
xy: 1624, 1466
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Spaceship Factory
rotate: false
xy: 1624, 1466
xy: 1732, 1575
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stable
rotate: false
xy: 1840, 1682
xy: 328, 62
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stadium
rotate: false
xy: 328, 62
xy: 436, 170
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Statue of Liberty
rotate: false
xy: 436, 170
xy: 544, 278
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Statue of Zeus
rotate: false
xy: 544, 278
xy: 652, 386
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stele
rotate: false
xy: 760, 494
xy: 868, 602
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stock Exchange
rotate: false
xy: 868, 602
xy: 976, 710
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stone Works
rotate: false
xy: 976, 710
xy: 1084, 824
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Stonehenge
rotate: false
xy: 1084, 824
xy: 1192, 926
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Sydney Opera House
rotate: false
xy: 1408, 1142
xy: 1516, 1250
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Taj Mahal
rotate: false
xy: 1516, 1250
xy: 1624, 1358
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Temple
rotate: false
xy: 1732, 1467
xy: 1840, 1574
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Temple of Artemis
rotate: false
xy: 1840, 1574
xy: 436, 62
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Terracotta Army
rotate: false
xy: 544, 170
xy: 652, 278
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/The Great Library
rotate: false
xy: 652, 278
xy: 760, 386
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/The Great Lighthouse
rotate: false
xy: 760, 386
xy: 868, 494
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/The Louvre
rotate: false
xy: 868, 494
xy: 976, 602
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/The Oracle
rotate: false
xy: 976, 602
xy: 1084, 716
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/The Pyramids
rotate: false
xy: 1084, 716
xy: 1192, 818
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Theatre
rotate: false
xy: 1192, 818
xy: 1300, 926
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/United Nations
rotate: false
xy: 1732, 1359
xy: 1840, 1466
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/University
rotate: false
xy: 1840, 1466
xy: 544, 62
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Utopia Project
rotate: false
xy: 544, 62
xy: 652, 170
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Walls
rotate: false
xy: 652, 170
xy: 760, 278
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Walls of Babylon
rotate: false
xy: 760, 278
xy: 868, 386
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Wat
rotate: false
xy: 1192, 710
xy: 1300, 818
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Water Mill
rotate: false
xy: 1300, 818
xy: 1408, 926
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Windmill
rotate: false
xy: 1408, 926
xy: 1516, 1034
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
BuildingIcons/Workshop
rotate: false
xy: 1732, 1251
xy: 1840, 1358
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
MayaCalendar/0
rotate: false
xy: 1840, 1300
xy: 62, 4
size: 25, 50
orig: 25, 50
offset: 0, 0
index: -1
MayaCalendar/1
rotate: false
xy: 916, 328
xy: 1024, 436
size: 13, 50
orig: 13, 50
offset: 0, 0
index: -1
MayaCalendar/10
rotate: false
xy: 818, 220
xy: 926, 328
size: 21, 50
orig: 21, 50
offset: 0, 0
index: -1
MayaCalendar/11
rotate: false
xy: 1300, 760
xy: 1408, 868
size: 35, 50
orig: 35, 50
offset: 0, 0
index: -1
MayaCalendar/12
rotate: false
xy: 1408, 868
xy: 1516, 976
size: 35, 50
orig: 35, 50
offset: 0, 0
index: -1
MayaCalendar/13
rotate: false
xy: 1516, 975
xy: 1624, 1083
size: 35, 50
orig: 35, 50
offset: 0, 0
index: -1
MayaCalendar/14
rotate: false
xy: 1624, 1084
xy: 1732, 1193
size: 35, 50
orig: 35, 50
offset: 0, 0
index: -1
MayaCalendar/15
rotate: false
xy: 1732, 1193
xy: 1840, 1300
size: 30, 50
orig: 30, 50
offset: 0, 0
index: -1
MayaCalendar/16
rotate: false
xy: 868, 328
xy: 976, 436
size: 40, 50
orig: 40, 50
offset: 0, 0
index: -1
MayaCalendar/17
rotate: false
xy: 976, 436
xy: 1084, 550
size: 40, 50
orig: 40, 50
offset: 0, 0
index: -1
MayaCalendar/18
rotate: false
xy: 1084, 550
xy: 1192, 652
size: 40, 50
orig: 40, 50
offset: 0, 0
index: -1
MayaCalendar/19
rotate: false
xy: 1192, 652
xy: 1300, 760
size: 40, 50
orig: 40, 50
offset: 0, 0
index: -1
MayaCalendar/2
rotate: false
xy: 1024, 436
xy: 1132, 550
size: 13, 50
orig: 13, 50
offset: 0, 0
index: -1
MayaCalendar/3
rotate: false
xy: 1132, 550
xy: 1240, 652
size: 13, 50
orig: 13, 50
offset: 0, 0
index: -1
MayaCalendar/4
rotate: false
xy: 1240, 652
xy: 1348, 760
size: 13, 50
orig: 13, 50
offset: 0, 0
index: -1
MayaCalendar/5
rotate: false
xy: 1343, 760
xy: 1451, 868
size: 10, 50
orig: 10, 50
offset: 0, 0
index: -1
MayaCalendar/6
rotate: false
xy: 62, 4
xy: 1948, 1890
size: 25, 50
orig: 25, 50
offset: 0, 0
index: -1
MayaCalendar/7
rotate: false
xy: 1948, 1890
xy: 2006, 1948
size: 25, 50
orig: 25, 50
offset: 0, 0
index: -1
MayaCalendar/8
rotate: false
xy: 2006, 1948
xy: 760, 162
size: 25, 50
orig: 25, 50
offset: 0, 0
index: -1
MayaCalendar/9
rotate: false
xy: 710, 112
xy: 818, 220
size: 25, 50
orig: 25, 50
offset: 0, 0
@ -1028,14 +1035,14 @@ MayaCalendar/Katun
index: -1
MayaCalendar/Maya
rotate: false
xy: 652, 112
xy: 760, 220
size: 50, 50
orig: 50, 50
offset: 0, 0
index: -1
MayaCalendar/Tun
rotate: false
xy: 760, 220
xy: 868, 328
size: 50, 50
orig: 50, 50
offset: 0, 0
@ -1714,182 +1721,182 @@ UnitIcons/Quinquereme
index: -1
UnitIcons/Rifleman
rotate: false
xy: 1300, 1250
xy: 1408, 1358
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Rocket Artillery
rotate: false
xy: 1408, 1358
xy: 1516, 1466
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Samurai
rotate: false
xy: 220, 62
xy: 328, 170
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Scout
rotate: false
xy: 436, 278
xy: 544, 386
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Sea Beggar
rotate: false
xy: 544, 386
xy: 652, 494
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Settler
rotate: false
xy: 760, 602
xy: 868, 710
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Ship of the Line
rotate: false
xy: 868, 710
xy: 976, 818
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Sipahi
rotate: false
xy: 1084, 932
xy: 1192, 1034
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Skirmisher
rotate: false
xy: 1300, 1142
xy: 1408, 1250
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Slinger
rotate: false
xy: 1408, 1250
xy: 1516, 1358
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Spearman
rotate: false
xy: 1732, 1575
xy: 1840, 1682
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Stealth Bomber
rotate: false
xy: 652, 386
xy: 760, 494
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Submarine
rotate: false
xy: 1192, 926
xy: 1300, 1034
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Swordsman
rotate: false
xy: 1300, 1034
xy: 1408, 1142
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Tank
rotate: false
xy: 1624, 1358
xy: 1732, 1467
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Tercio
rotate: false
xy: 436, 62
xy: 544, 170
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Trebuchet
rotate: false
xy: 1300, 926
xy: 1408, 1034
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Triplane
rotate: false
xy: 1408, 1034
xy: 1516, 1142
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Trireme
rotate: false
xy: 1516, 1141
xy: 1624, 1249
size: 100, 101
orig: 100, 101
offset: 0, 0
index: -1
UnitIcons/Turtle Ship
rotate: false
xy: 1624, 1250
xy: 1732, 1359
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/War Chariot
rotate: false
xy: 868, 386
xy: 976, 494
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/War Elephant
rotate: false
xy: 976, 494
xy: 1084, 608
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Warrior
rotate: false
xy: 1084, 608
xy: 1192, 710
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Work Boats
rotate: false
xy: 1516, 1033
xy: 1624, 1141
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Worker
rotate: false
xy: 1624, 1142
xy: 1732, 1251
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
UnitIcons/Zero
rotate: false
xy: 1840, 1358
xy: 652, 62
size: 100, 100
orig: 100, 100
offset: 0, 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 714 KiB

After

Width:  |  Height:  |  Size: 717 KiB

View File

@ -1049,6 +1049,12 @@
"requiredTech": "Ecology",
"uniques": ["Must be next to [Desert]", "Cannot be built with [Nuclear Plant]"]
},
{
"name": "Recycling Center",
"maintenance": 3,
"requiredTech": "Ecology",
"uniques": ["Provides [2] [Aluminum]","Limited to [5] per Civilization"]
},
{
"name": "Sydney Opera House",
"isWonder": true,

View File

@ -332,7 +332,7 @@ class CityInfo {
cityResources.add(resource, -amount, "Buildings")
}
}
for (unique in getLocalMatchingUniques(UniqueType.ProvidesResources)) { // E.G "Provides [1] [Iron]"
if (!unique.conditionalsApply(civInfo, this)) continue
val resource = getRuleset().tileResources[unique.params[1]]

View File

@ -10,6 +10,7 @@ import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
import com.unciv.logic.trade.TradeLogic
import com.unciv.logic.trade.TradeOffer
import com.unciv.logic.trade.TradeType
import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.ui.utils.withoutItem
import java.util.*
import kotlin.math.max
@ -259,7 +260,20 @@ class CityInfoConquestFunctions(val city: CityInfo){
// Remove their free buildings from this city and remove free buildings provided by the city from their cities
removeBuildingsOnMoveToCiv(oldCiv)
// Add our free buildings to this city and add free buildings provided by the city to other cities
civInfo.civConstructions.tryAddFreeBuildings()
civInfo.civConstructions.tryAddFreeBuildings()
// Check if we exceed MaxNumberBuildable for any buildings
for (building in cityConstructions.getBuiltBuildings()) {
for (unique in building.getMatchingUniques(UniqueType.MaxNumberBuildable)) {
if (civInfo.cities.count {
it.cityConstructions.containsBuildingOrEquivalent(building.name) ||
it.cityConstructions.isBeingConstructedOrEnqueued(building.name)
}
>= unique.params[0].toInt()) {
// For now, just destroy in new city. Even if constructing in own cities
city.cityConstructions.removeBuilding(building.name)
}
}
}
// Place palace for newCiv if this is the only city they have
if (newCivInfo.cities.count() == 1) {

View File

@ -120,7 +120,8 @@ class RejectionReasons: HashSet<RejectionReason>() {
RejectionReason.RequiresBuildingInSomeCity,
RejectionReason.PopulationRequirement,
RejectionReason.ConsumesResources,
RejectionReason.CanOnlyBePurchased
RejectionReason.CanOnlyBePurchased,
RejectionReason.MaxNumberBuildable
)
}
}
@ -142,6 +143,7 @@ enum class RejectionReason(val shouldShow: Boolean, var errorMessage: String) {
MustOwnTile(false, "Must own a specific tile close by"),
WaterUnitsInCoastalCities(false, "May only built water units in coastal cities"),
CanOnlyBeBuiltInSpecificCities(false, "Can only be built in specific cities"),
MaxNumberBuildable(true, "Maximum number being built"),
UniqueToOtherNation(false, "Unique to another nation"),
ReplacedByOurUnique(false, "Our unique replaces this"),

View File

@ -454,6 +454,11 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
override fun shouldBeDisplayed(cityConstructions: CityConstructions): Boolean {
if (cityConstructions.isBeingConstructedOrEnqueued(name))
return false
for (unique in getMatchingUniques(UniqueType.MaxNumberBuildable)){
if (cityConstructions.cityInfo.civInfo.cities.count{it.cityConstructions.containsBuildingOrEquivalent(name)}>=unique.params[0].toInt())
return false
}
val rejectionReasons = getRejectionReasons(cityConstructions)
return rejectionReasons.none { !it.shouldShow }
|| (
@ -539,6 +544,15 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
UniqueType.HiddenWithoutReligion.text ->
if (!civInfo.gameInfo.isReligionEnabled())
rejectionReasons.add(RejectionReason.DisabledBySetting)
UniqueType.MaxNumberBuildable.placeholderText ->
if (civInfo.cities.count {
it.cityConstructions.containsBuildingOrEquivalent(name) ||
it.cityConstructions.isBeingConstructedOrEnqueued(name)
}
>= unique.params[0].toInt()) {
rejectionReasons.add(RejectionReason.MaxNumberBuildable)
}
}
}

View File

@ -202,7 +202,7 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget, val flags:
CannotBePurchased("Cannot be purchased", UniqueTarget.Building, UniqueTarget.Unit),
CanBePurchasedWithStat("Can be purchased with [stat] [cityFilter]", UniqueTarget.Building, UniqueTarget.Unit),
CanBePurchasedForAmountStat("Can be purchased for [amount] [stat] [cityFilter]", UniqueTarget.Building, UniqueTarget.Unit),
MaxNumberBuildable("Limited to [amount] per Civilization", UniqueTarget.Building, UniqueTarget.Unit),
///////////////////////////////////////// BUILDING UNIQUES /////////////////////////////////////////

View File

@ -325,6 +325,7 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
* [Chemistry](https://thenounproject.com/term/chemistry/175847/) By Creative Stall for Medical Lab
* [Pentagon](https://thenounproject.com/search/?q=the%20pentagon&i=1788323) By Maxim Kulikov
* [Solar panel](https://thenounproject.com/term/solar-panel/1131/) By Modik for Solar Plant
* [Recycle](https://thenounproject.com/search/?q=recycling&i=4397434) By Umer Younas, PK for Recycling Center
* [Opera House Sydney](https://thenounproject.com/term/opera-house-sydney/1626283/) By Pham Duy Phuong Hung for Sydney Opera House
* [Water dam](https://thenounproject.com/term/water-dam/1002726/) By Symbolon for Hydro Plant
* [Manhattan Project](https://thenounproject.com/search/?q=Nuclear%20Bomb&i=2041074) By corpus delicti, GR