From c221d50e0118687d1da97bd3a7cd9187f855a41e Mon Sep 17 00:00:00 2001 From: Duan Tao Date: Thu, 9 May 2019 20:05:44 +0800 Subject: [PATCH] Add 2 more type of city-states. --- android/assets/jsons/Nations.json | 59 ++++++++++++++++++- core/src/com/unciv/logic/city/CityStats.kt | 20 +++++++ .../logic/civilization/CivilizationInfo.kt | 17 +++++- .../src/com/unciv/ui/trade/DiplomacyScreen.kt | 11 +++- 4 files changed, 101 insertions(+), 6 deletions(-) diff --git a/android/assets/jsons/Nations.json b/android/assets/jsons/Nations.json index 75cd98dcf3..87b937b804 100644 --- a/android/assets/jsons/Nations.json +++ b/android/assets/jsons/Nations.json @@ -813,7 +813,64 @@ mainColor:[255, 250, 240], secondaryColor:[238, 44, 44], cities:["Florence"] - } + }, + { + name:"Rio de Janeiro", + adjective:["Rio de Janeiro"], + cityStateType:"Maritime", + startBias:["Coast"], + + //TO DO : better dialogs + declaringWar:"Declare war.", + attacked:"Let's fight.", + defeated:"GoodBye.", + introduction:"Hi.", + + neutralHello:"Greetings.", + neutralLetsHearIt:["I'm listening.","What do you want?"], + neutralNo:["No!","Certainly not.","Unacceptable!"], + neutralYes:["Completed!","Yes!","Agreed!"], + + hateHello:"What do YOU want?!", + hateLetsHearIt:["I'm certainly listening.","I'm listening!"], + hateNo:["No!","Certainly not!","Unacceptable!"], + hateYes:["Yes!"], + + afterPeace:"Peace then.", + tradeRequest:"Trade?", + + mainColor:[32, 178, 170], + secondaryColor:[255, 255, 224], + cities:["Rio de Janeiro"] + }, + { + name:"Antwerp", + adjective:["Antwerp"], + cityStateType:"Mercantile", + + //TO DO : better dialogs + declaringWar:"Declare war.", + attacked:"Let's fight.", + defeated:"GoodBye.", + introduction:"Hi.", + + neutralHello:"Greetings.", + neutralLetsHearIt:["I'm listening.","What do you want?"], + neutralNo:["No!","Certainly not.","Unacceptable!"], + neutralYes:["Completed!","Yes!","Agreed!"], + + hateHello:"What do YOU want?!", + hateLetsHearIt:["I'm certainly listening.","I'm listening!"], + hateNo:["No!","Certainly not!","Unacceptable!"], + hateYes:["Yes!"], + + afterPeace:"Peace then.", + tradeRequest:"Trade?", + + mainColor:[250, 250, 210], + secondaryColor:[250, 128, 114], + cities:["Rio de Janeiro"] + }, //Barbarian { diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 5171e93d78..e26fd77598 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -4,6 +4,7 @@ import com.unciv.UnCivGame import com.unciv.logic.map.BFS import com.unciv.logic.map.RoadStatus import com.unciv.Constants +import com.unciv.logic.civilization.CityStateType import com.unciv.models.gamebasics.Building import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.unit.BaseUnit @@ -119,6 +120,24 @@ class CityStats { return stats } + private fun getStatsFromCityStates(): Stats { + val stats = Stats() + + for (otherCivName in cityInfo.civInfo.diplomacy.keys) { + val otherCiv = cityInfo.civInfo.gameInfo.getCivilization(otherCivName) + if (otherCiv.isCityState() && otherCiv.getCityStateType() == CityStateType.Maritime + && otherCiv.diplomacy[cityInfo.civInfo.civName]!!.influence >= 60) { + if (cityInfo.isCapital()) { + stats.food = stats.food + 3 + } else { + stats.food = stats.food + 1 + } + } + } + + return stats + } + private fun getStatPercentBonusesFromNationUnique(): Stats { val stats = Stats() @@ -321,6 +340,7 @@ class CityStats { newBaseStatList["Buildings"] = cityInfo.cityConstructions.getStats() newBaseStatList["Policies"] = getStatsFromPolicies(civInfo.policies.adoptedPolicies) newBaseStatList["National ability"] = getStatsFromNationUnique() + newBaseStatList["CityStates"] = getStatsFromCityStates() baseStatList = newBaseStatList } diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 122a09e6f7..018c1e250d 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -37,7 +37,9 @@ enum class PlayerType{ } enum class CityStateType{ - Cultured + Cultured, + Maritime, + Mercantile } class TradeRequest(val requestingCiv:String, @@ -152,7 +154,7 @@ class CivilizationInfo { //City states culture bonus for (otherCivName in diplomacy.keys) { val otherCiv = gameInfo.getCivilization(otherCivName) - if (otherCiv.isCityState() && otherCiv.diplomacy[civName]!!.influence > 60) { + if (otherCiv.isCityState() && otherCiv.getCityStateType() == CityStateType.Cultured && otherCiv.diplomacy[civName]!!.influence >= 60) { val cultureBonus = Stats() cultureBonus.add(Stat.Culture, 5.0f * getEra().ordinal) if (statMap.containsKey("City States")) @@ -244,6 +246,17 @@ class CivilizationInfo { policies.getAdoptedPolicies().count { !it.endsWith("Complete") }.toFloat() } + //From city-states + for (otherCivName in diplomacy.keys) { + val otherCiv = gameInfo.getCivilization(otherCivName) + if (otherCiv.isCityState() && otherCiv.getCityStateType() == CityStateType.Mercantile && otherCiv.diplomacy[civName]!!.influence >= 60) { + if (statMap.containsKey("City-states")) + statMap["City-states"] = statMap["City-states"]!! + 3f + else + statMap["City-states"] = 3f + } + } + return statMap } diff --git a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt index 64d84f05dd..e5d53737a3 100644 --- a/core/src/com/unciv/ui/trade/DiplomacyScreen.kt +++ b/core/src/com/unciv/ui/trade/DiplomacyScreen.kt @@ -95,9 +95,14 @@ class DiplomacyScreen:CameraStageBaseScreen() { diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel()) diplomacyTable.add(("Type : " + otherCiv.getCityStateType().toString()).toLabel()).row() diplomacyTable.add(("Influence : " + otherCiv.getDiplomacyManager(currentPlayerCiv).influence.toInt().toString()).toLabel()).row() - if (otherCiv.getDiplomacyManager(currentPlayerCiv).influence > 60) { - if (otherCiv.getCityStateType() == CityStateType.Cultured) { - diplomacyTable.add(("Providing " + (5.0f * currentPlayerCiv.getEra().ordinal).toString() + " culture each turn").toLabel()) + if (otherCiv.getDiplomacyManager(currentPlayerCiv).influence >= 60) { + when(otherCiv.getCityStateType()) { + CityStateType.Cultured -> diplomacyTable.add( + ("Providing " + (5.0f * currentPlayerCiv.getEra().ordinal).toString() + " culture each turn").toLabel()) + CityStateType.Maritime -> diplomacyTable.add( + ("Providing 3 food in capital and 1 food in other cities.").toLabel()) + CityStateType.Mercantile -> diplomacyTable.add( + ("Providing 3 happiness.").toLabel()) } } } else {