Added popups after construction of wonder is complete

This commit is contained in:
Yair Morgenstern 2019-09-10 00:11:25 +03:00
parent bdb049a29a
commit 1cf049f82f
6 changed files with 26 additions and 7 deletions

View File

@ -715,7 +715,8 @@
culture:3, culture:3,
isWonder:true, isWonder:true,
uniques:["Defensive buildings in all cities are 25% more effective"], uniques:["Defensive buildings in all cities are 25% more effective"],
requiredTech:"Railroad" requiredTech:"Railroad",
quote:"'The Law is a fortress on a hill that armies cannot take or floods wash away.' - The Prophet Muhammed"
}, },
{ {
name:"Neuschwanstein", name:"Neuschwanstein",

View File

@ -3,6 +3,8 @@ package com.unciv.logic.city
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.unciv.Constants import com.unciv.Constants
import com.unciv.logic.automation.ConstructionAutomation import com.unciv.logic.automation.ConstructionAutomation
import com.unciv.logic.civilization.AlertType
import com.unciv.logic.civilization.PopupAlert
import com.unciv.models.gamebasics.Building import com.unciv.models.gamebasics.Building
import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
@ -192,6 +194,7 @@ class CityConstructions {
inProgressConstructions.remove(currentConstruction) inProgressConstructions.remove(currentConstruction)
if (construction is Building && construction.isWonder) { if (construction is Building && construction.isWonder) {
cityInfo.civInfo.popupAlerts.add(PopupAlert(AlertType.WonderBuilt, construction.name))
for (civ in cityInfo.civInfo.gameInfo.civilizations) { for (civ in cityInfo.civInfo.gameInfo.civilizations) {
if (civ.exploredTiles.contains(cityInfo.location)) if (civ.exploredTiles.contains(cityInfo.location))
civ.addNotification("[$currentConstruction] has been built in [${cityInfo.name}]", cityInfo.location, Color.BROWN) civ.addNotification("[$currentConstruction] has been built in [${cityInfo.name}]", cityInfo.location, Color.BROWN)

View File

@ -10,6 +10,7 @@ enum class AlertType{
CitiesSettledNearOtherCiv, CitiesSettledNearOtherCiv,
DemandToStopSettlingCitiesNear, DemandToStopSettlingCitiesNear,
CitySettledNearOtherCivDespiteOurPromise, CitySettledNearOtherCivDespiteOurPromise,
WonderBuilt
} }
class PopupAlert { class PopupAlert {

View File

@ -44,12 +44,14 @@ class TechManager {
var techCost = GameBasics.Technologies[techName]!!.cost.toFloat() var techCost = GameBasics.Technologies[techName]!!.cost.toFloat()
techCost *= civInfo.getDifficulty().researchCostModifier techCost *= civInfo.getDifficulty().researchCostModifier
techCost *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier() techCost *= civInfo.gameInfo.gameParameters.gameSpeed.getModifier()
techCost *= (1 + 0.02 * (civInfo.cities.size -1 )).toFloat() techCost *= 1 + (civInfo.cities.size -1 ) * 0.02f // each city increases tech cost by 2%, as per https://civilization.fandom.com/wiki/Science_(Civ5)
return techCost.toInt() return techCost.toInt()
} }
fun currentTechnology(): Technology? = currentTechnologyName()?.let { fun currentTechnology(): Technology? {
GameBasics.Technologies[it] val currentTechnologyName = currentTechnologyName()
if (currentTechnologyName == null) return null
return GameBasics.Technologies[currentTechnologyName]
} }
fun currentTechnologyName(): String? { fun currentTechnologyName(): String? {

View File

@ -38,6 +38,7 @@ class Building : NamedStats(), IConstruction{
var xpForNewUnits=0 var xpForNewUnits=0
var replaces:String?=null var replaces:String?=null
var uniqueTo:String?=null var uniqueTo:String?=null
var quote:String?=null
// Uniques // Uniques
private var providesFreeBuilding: String? = null private var providesFreeBuilding: String? = null

View File

@ -5,10 +5,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.logic.civilization.AlertType import com.unciv.logic.civilization.AlertType
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.PopupAlert import com.unciv.logic.civilization.PopupAlert
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
import com.unciv.ui.utils.addSeparator import com.unciv.ui.utils.*
import com.unciv.ui.utils.onClick
import com.unciv.ui.utils.toLabel
import com.unciv.ui.worldscreen.optionstable.PopupTable import com.unciv.ui.worldscreen.optionstable.PopupTable
class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): PopupTable(worldScreen){ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): PopupTable(worldScreen){
@ -95,6 +94,18 @@ class AlertPopup(val worldScreen: WorldScreen, val popupAlert: PopupAlert): Popu
addGoodSizedLabel("We noticed your new city near our borders, despite your promise. This will have....implications.").row() addGoodSizedLabel("We noticed your new city near our borders, despite your promise. This will have....implications.").row()
add(getCloseButton("Very well.")) add(getCloseButton("Very well."))
} }
AlertType.WonderBuilt -> {
val wonder = GameBasics.Buildings[popupAlert.value]!!
addGoodSizedLabel(wonder.name)
addSeparator()
val centerTable = Table()
val wonderText = if(wonder.quote!=null) wonder.quote!! else ""
centerTable.add(wonderText.toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
centerTable.add(ImageGetter.getConstructionImage(wonder.name).surroundWithCircle(100f)).pad(20f)
centerTable.add(wonder.getShortDescription().toLabel().apply { setWrap(true) }).width(worldScreen.stage.width/3)
add(centerTable).row()
add(getCloseButton("Close"))
}
} }
open() open()
worldScreen.alertPopupIsOpen = true worldScreen.alertPopupIsOpen = true