Improvements that provide resources now specified in the improvement picker screen

Tutorials for resources now specify that a specific improvement is needed
This commit is contained in:
Yair Morgenstern 2019-10-12 22:27:45 +03:00
parent 7d14c0924b
commit b661308a9d
6 changed files with 79 additions and 65 deletions

View File

@ -226,13 +226,12 @@
],
[
"There are three ways to win in Unciv. They are:",
"Cultural Victory: Complete 4 Social Policy Trees",
"Domination Victory: Survive as the last civilization",
"Science Victory: Be the first to construct a spaceship to Alpha Centauri"
" - Cultural Victory: Complete 4 Social Policy Trees",
" - Domination Victory: Survive as the last civilization",
" - Science Victory: Be the first to construct a spaceship to Alpha Centauri"
],
[
"So to sum it up, these are the basics of Unciv ",
"Found a prosperous first city, expand slowly to manage happiness,",
"So to sum it up, these are the basics of Unciv Found a prosperous first city, expand slowly to manage happiness,",
" and set yourself up for the victory condition you wish to pursue.",
"Obviously, there is much more to it than that, but it is important not to jump into the deep end before you know how to swim.",
]
@ -249,6 +248,7 @@
Luxury_Resource: [
[
"Luxury resources within your domain and with their specific improvement are connected to your trade network.",
"Each unique Luxury resource you have adds 5 happiness to your civilization,",
" but extra resources of the same type don't add anything, ",
" so use them for trading with other civilizations!"
@ -257,6 +257,7 @@
Strategic_Resource: [
[
"Strategic resources within your domain and with their specific improvement are connected to your trade network.",
"Strategic resources allow you to train units and construct buildings that",
" require those specific resources, for example the Horseman requires Horses."
"Each unit 'consumes' a copy of that resource, but if the unit is killed you can ",

View File

@ -17,6 +17,7 @@ class Constants{
const val ancientRuins = "Ancient ruins"
const val peaceTreaty = "Peace Treaty"
const val openBorders = "Open Borders"
const val random = "Random"
val greatImprovements = listOf("Academy", "Landmark", "Manufactory", "Customs house")

View File

@ -10,7 +10,6 @@ import com.unciv.logic.trade.Trade
import com.unciv.logic.trade.TradeType
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tile.ResourceSupplyList
import com.unciv.models.gamebasics.tr
enum class RelationshipLevel{
Unforgivable,
@ -195,7 +194,7 @@ class DiplomacyManager() {
// for performance reasons we don't want to call this every time we want to see if a unit can move through a tile
fun updateHasOpenBorders(){
val newHasOpenBorders = trades.flatMap { it.theirOffers }
.any { it.name == "Open Borders" && it.duration > 0 }
.any { it.name == Constants.openBorders && it.duration > 0 }
val bordersWereClosed = hasOpenBorders && !newHasOpenBorders
hasOpenBorders=newHasOpenBorders
@ -209,6 +208,42 @@ class DiplomacyManager() {
}
fun nextTurn(){
nextTurnTrades()
removeUntenebleTrades()
updateHasOpenBorders()
nextTurnDiplomaticModifiers()
nextTurnFlags()
nextTurnCityStateInfluence()
}
private fun nextTurnCityStateInfluence() {
val hasCityStateInfluenceBonus =
civInfo.nation.unique == "City-State Influence degrades at half and recovers at twice the normal rate"
if (influence > 1) {
if (hasCityStateInfluenceBonus) influence -= 0.5f
else influence -= 1
} else if (influence < 1) {
if (hasCityStateInfluenceBonus) influence += 2
else influence += 1
} else influence = 0f
}
private fun nextTurnFlags() {
for (flag in flagsCountdown.keys.toList()) {
flagsCountdown[flag] = flagsCountdown[flag]!! - 1
if (flagsCountdown[flag] == 0) {
if (flag == DiplomacyFlags.ProvideMilitaryUnit.name && civInfo.cities.isEmpty() || otherCiv().cities.isEmpty())
continue
flagsCountdown.remove(flag)
if (flag == DiplomacyFlags.AgreedToNotSettleNearUs.name)
addModifier(DiplomaticModifiers.FulfilledPromiseToNotSettleCitiesNearUs, 10f)
else if (flag == DiplomacyFlags.ProvideMilitaryUnit.name)
civInfo.giftMilitaryUnitTo(otherCiv())
}
}
}
private fun nextTurnTrades() {
for (trade in trades.toList()) {
for (offer in trade.ourOffers.union(trade.theirOffers).filter { it.duration > 0 }) {
offer.duration--
@ -224,14 +259,13 @@ class DiplomacyManager() {
trades.remove(trade)
}
}
removeUntenebleTrades()
updateHasOpenBorders()
}
private fun nextTurnDiplomaticModifiers() {
if (diplomaticStatus == DiplomaticStatus.Peace) {
if (getModifier(DiplomaticModifiers.YearsOfPeace) < 30)
addModifier(DiplomaticModifiers.YearsOfPeace, 0.5f)
}
else revertToZero(DiplomaticModifiers.YearsOfPeace,0.5f) // war makes you forget the good ol' days
} else revertToZero(DiplomaticModifiers.YearsOfPeace, 0.5f) // war makes you forget the good ol' days
var openBorders = 0
if (hasOpenBorders) openBorders += 1
@ -254,36 +288,10 @@ class DiplomacyManager() {
if (otherCiv().isCityState() && otherCiv().getCityStateType() == CityStateType.Militaristic) {
if (relationshipLevel() < RelationshipLevel.Friend) {
if (hasFlag(DiplomacyFlags.ProvideMilitaryUnit)) removeFlag(DiplomacyFlags.ProvideMilitaryUnit)
}
else {
} else {
if (!hasFlag(DiplomacyFlags.ProvideMilitaryUnit)) setFlag(DiplomacyFlags.ProvideMilitaryUnit, 20)
}
}
for(flag in flagsCountdown.keys.toList()) {
flagsCountdown[flag] = flagsCountdown[flag]!! - 1
if(flagsCountdown[flag]==0) {
if(flag==DiplomacyFlags.ProvideMilitaryUnit.name && civInfo.cities.isEmpty() || otherCiv().cities.isEmpty())
continue
flagsCountdown.remove(flag)
if(flag==DiplomacyFlags.AgreedToNotSettleNearUs.name)
addModifier(DiplomaticModifiers.FulfilledPromiseToNotSettleCitiesNearUs,10f)
else if(flag==DiplomacyFlags.ProvideMilitaryUnit.name)
civInfo.giftMilitaryUnitTo(otherCiv())
}
}
// City-state influence
val hasCityStateInfluenceBonus =
civInfo.nation.unique=="City-State Influence degrades at half and recovers at twice the normal rate"
if (influence > 1) {
if(hasCityStateInfluenceBonus) influence -= 0.5f
else influence -= 1
} else if (influence < 1) {
if(hasCityStateInfluenceBonus) influence += 2
else influence += 1
} else influence = 0f
}
/** Everything that happens to both sides equally when war is delcared by one side on the other */
@ -401,6 +409,9 @@ class DiplomacyManager() {
setFlag(DiplomacyFlags.Denunceation,30)
otherCivDiplomacy().setFlag(DiplomacyFlags.Denunceation,30)
otherCiv().addNotification("[${civInfo.civName}] has denounced us!", Color.RED)
// We, A, are denouncing B. What do other major civs (C,D, etc) think of this?
for(thirdCiv in civInfo.getKnownCivs().filter { it.isMajorCiv() }){
if(thirdCiv==otherCiv() || !thirdCiv.knows(otherCivName)) continue
val thirdCivRelationshipWithOtherCiv = thirdCiv.getDiplomacyManager(otherCiv()).relationshipLevel()
@ -411,7 +422,6 @@ class DiplomacyManager() {
RelationshipLevel.Ally -> addModifier(DiplomaticModifiers.DenouncedOurAllies,-15f)
}
}
otherCiv().addNotification("[${civInfo.civName}] has denounced us!", Color.RED)
}
fun agreeNotToSettleNear(){

View File

@ -145,7 +145,7 @@ class TradeEvaluation{
return sumOfStats.toInt() * 100
}
TradeType.Agreement -> {
if(offer.name=="Open Borders") return 100
if(offer.name==Constants.openBorders) return 100
throw Exception("Invalid agreement type!")
}
}
@ -211,7 +211,7 @@ class TradeEvaluation{
return sumOfStats.toInt() * 100
}
TradeType.Agreement -> {
if(offer.name == "Open Borders"){
if(offer.name == Constants.openBorders){
when(civInfo.getDiplomacyManager(tradePartner).relationshipLevel()){
RelationshipLevel.Unforgivable -> return 10000
RelationshipLevel.Enemy -> return 2000

View File

@ -25,7 +25,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
&& otherCivilization.tech.getTechUniques().contains("Enables Open Borders agreements")) {
val relationshipLevel = otherCivilization.getDiplomacyManager(civInfo).relationshipLevel()
offers.add(TradeOffer("Open Borders", TradeType.Agreement, 30))
offers.add(TradeOffer(Constants.openBorders, TradeType.Agreement, 30))
}
for(entry in civInfo.getCivResources()

View File

@ -3,7 +3,6 @@ package com.unciv.ui.pickerscreens
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Button
import com.badlogic.gdx.scenes.scene2d.ui.Label
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
import com.unciv.logic.map.TileInfo
@ -51,8 +50,11 @@ class ImprovementPickerScreen(tileInfo: TileInfo, onAccept: ()->Unit) : PickerSc
group.add(image).size(30f).pad(10f)
group.add(Label(improvement.name.tr() + " - " + improvement.getTurnsToBuild(currentPlayerCiv) + " {turns}".tr(),skin)
.setFontColor(Color.WHITE)).pad(10f)
var labelText = improvement.name.tr() + " - " + improvement.getTurnsToBuild(currentPlayerCiv) + " {turns}"
if(tileInfo.hasViewableResource(currentPlayerCiv) && tileInfo.getTileResource().improvement == improvement.name)
labelText += "\n"+"Provides [${tileInfo.resource}]".tr()
group.add(labelText.toLabel().setFontColor(Color.WHITE)).pad(10f)
group.touchable = Touchable.enabled
group.onClick {