Add global alerts for certain constructions (#4039)

* Add global alerts for certain constructions

In the original game, certain constructions alert all players upon
their completion. This commit introduces a new unique for this behavior
and adds this unique to the relevant constructions.

The code that implements the new unique is placed in
Building.postBuildEvent, so it can only be activated by buildings. If
other kinds of constructions require a global alert as well, the code
could be moved to CityConstructions.constructionComplete.

* Removed redundant line in template.properties

* Moved global alert logic to CityConstructions

Moved the implementation of "Triggers a global alert upon completion"
from Building.postBuildEvent to CityConstructions.constructionComplete,
close to the similar Wonder notification logic.
This commit is contained in:
Arthur van der Staaij 2021-06-03 06:31:39 +02:00 committed by GitHub
parent 9c406b72bc
commit a765caa97c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 8 deletions

View File

@ -937,7 +937,7 @@
{
"name": "Manhattan Project",
"isNationalWonder": true,
"uniques": ["Enables nuclear weapon"],
"uniques": ["Enables nuclear weapon", "Triggers a global alert upon completion"],
"requiredTech": "Nuclear Fission"
},
{
@ -1014,13 +1014,13 @@
"name": "SS Booster",
"requiredResource": "Aluminum",
"requiredTech": "Robotics",
"uniques": ["Spaceship part", "Cannot be purchased"]
"uniques": ["Spaceship part", "Triggers a global alert upon completion", "Cannot be purchased"]
},
{
"name": "Apollo Program",
"cost": 1500,
"isNationalWonder": true,
"uniques": ["Enables construction of Spaceship parts"],
"uniques": ["Enables construction of Spaceship parts", "Triggers a global alert upon completion"],
"requiredTech": "Rocketry"
},
@ -1044,18 +1044,18 @@
"name": "SS Cockpit",
"requiredResource": "Aluminum",
"requiredTech": "Satellites",
"uniques": ["Spaceship part", "Cannot be purchased"]
"uniques": ["Spaceship part", "Triggers a global alert upon completion", "Cannot be purchased"]
},
{
"name": "SS Engine",
"requiredResource": "Aluminum",
"requiredTech": "Particle Physics",
"uniques": ["Spaceship part", "Cannot be purchased"]
"uniques": ["Spaceship part", "Triggers a global alert upon completion", "Cannot be purchased"]
},
{
"name": "SS Stasis Chamber",
"requiredResource": "Aluminum",
"requiredTech": "Nanotechnology",
"uniques": ["Spaceship part", "Cannot be purchased"]
"uniques": ["Spaceship part", "Triggers a global alert upon completion", "Cannot be purchased"]
}
]

View File

@ -395,6 +395,8 @@ Cannot provide unit upkeep for [unitName] - unit has been disbanded! =
[cityName] is starving! =
[construction] has been built in [cityName] =
[wonder] has been built in a faraway land =
[civName] has completed [construction]! =
An unknown civilization has completed [construction]! =
Work has started on [construction] =
[cityName] cannot continue work on [construction] =
[cityName] has expanded its borders! =

View File

@ -347,7 +347,16 @@ class CityConstructions {
cityInfo.civInfo.addNotification("[${construction.name}] has been built in [" + cityInfo.name + "]",
cityInfo.location, NotificationIcon.Construction, icon)
}
if (construction is Building && "Triggers a global alert upon completion" in construction.uniques) {
for (otherCiv in cityInfo.civInfo.gameInfo.civilizations) {
// No need to notify ourself, since we already got the building notification anyway
if (otherCiv == cityInfo.civInfo) continue
val completingCivDescription =
if (otherCiv.knows(cityInfo.civInfo)) "[${cityInfo.civInfo.civName}]" else "An unknown civilization"
otherCiv.addNotification("$completingCivDescription has completed [${construction.name}]!",
NotificationIcon.Construction, buildingIcon)
}
}
}
fun addBuilding(buildingName: String) {

View File

@ -413,8 +413,8 @@ class Building : NamedStats(), IConstruction {
civInfo.victoryManager.currentsSpaceshipParts.add(name, 1)
return true
}
cityConstructions.addBuilding(name)
cityConstructions.addBuilding(name)
val improvement = getImprovement(civInfo.gameInfo.ruleSet)
if (improvement != null) {