Final touches to City States, and they're ready to roll!

This commit is contained in:
Yair Morgenstern 2019-05-26 16:10:09 +03:00
parent e4125e52c0
commit 408dfcfc7e
9 changed files with 101 additions and 161 deletions

View File

@ -763,10 +763,9 @@
cityStateType:"Cultured",
startBias:["Coast"],
//TO DO : better dialogs
declaringWar:"Declare war.",
attacked:"Let's fight.",
afterPeace:"Peace then.",
declaringWar:"You leave us no choice. War it must be.",
attacked:"Very well, this shall not be forgotten.",
afterPeace:"May peace forever bless out lands.",
mainColor:[0, 0, 0],
secondaryColor:[185,132,66],
@ -778,10 +777,9 @@
cityStateType:"Cultured",
startBias:["Coast"],
//TO DO : better dialogs
declaringWar:"Declare war.",
attacked:"Let's fight.",
afterPeace:"Peace then.",
declaringWar:"You leave us no choice. War it must be.",
attacked:"Very well, this shall not be forgotten.",
afterPeace:"May peace forever bless out lands.",
mainColor:[0, 0, 0],
secondaryColor:[62,197,252],
@ -793,10 +791,9 @@
cityStateType:"Maritime",
startBias:["Coast"],
//TO DO : better dialogs
declaringWar:"Declare war.",
attacked:"Let's fight.",
afterPeace:"Peace then.",
declaringWar:"You leave us no choice. War it must be.",
attacked:"Very well, this shall not be forgotten.",
afterPeace:"May peace forever bless out lands.",
mainColor:[0, 0, 0],
secondaryColor:[211, 220, 103],
@ -807,10 +804,9 @@
adjective:["Antwerp"],
cityStateType:"Mercantile",
//TO DO : better dialogs
declaringWar:"Declare war.",
attacked:"Let's fight.",
afterPeace:"Peace then.",
declaringWar:"You leave us no choice. War it must be.",
attacked:"Very well, this shall not be forgotten.",
afterPeace:"May peace forever bless out lands.",
mainColor:[0, 0, 0],
secondaryColor:[194,97,255],

View File

@ -1531,79 +1531,6 @@
Portuguese:"Penalidade contra [unitType]"
}
///////// Old Great Person translations (for reference only)
"Can start an 8-turn golden age or construct a Landmark (+6 Culture)":{
Italian:"Può iniziare un'Età dell'Oro di 8 turni o costruire un Punto di riferimento (+6 Cultura)"
Russian:"Может начать золотой век на 8 ходов или построить памятник (+6 культура)"
French:"Peut commencer un âge d'or de 8 tours ou construire un monument (+6 Culture)"
Romanian:"Poate începe o nouă epocă de aur sau construi un monument (Cultura + 6)"
German:"Kann ein goldenes Zeitalter mit 8 Umdrehungen beginnen oder ein Wahrzeichen erstellen (+6 Kultur)"// German translation not sure
Dutch:"Kan een gouden periode van acht beurten starten of een oriëntatiepunt bouwen (+6 Cultuur)"// Dutch translation not sure
Spanish:"Puede comenzar una Edad de Oro de 8 turnos o construir un Edificio Emblemático (+6 cultura)"
Portuguese:"Pode iniciar uma idade dourada de 8 turnos ou construir uma maravilha (+6 Cultura)"
Simplified_Chinese:"开启8回合黄金时代或建造1座文化地标(+6文化)"
}
"Can discover a technology, or construct an Academy (+4 Science)" :{
Italian:"Può scoprire una tecnologia o costruire un'Accademia (+4 Scienza)"
Russian:"Может открыть технологию или построить Академию (+4 наука)"
French:"Peut découvrir une technologie, ou construire une Académie (+4 science)"
Romanian:"Poate să descopere o tehnologie sau să construiască o Academie (știință +4)"
German:"Kann eine Technologie entdecken, oder eine Akademie (+4 Erforschung) bauen"
Dutch:"Kan een technologie ontdekken, of een Academie (+4wetenschap) bouwen"
Spanish:"Puede descubrir una tecnología o construir una Academia (+4 ciencia)"
Portuguese:"Pode descobrir uma tecnologia ou construir uma academia (+4 Ciência)"
Simplified_Chinese:"获得一项免费科技或建造1座学院(+4科研)"
}
"Can undertake a trade mission, giving a large sum of gold, or construct a Customs House (+4 Gold)":{
Italian:"Può intraprendere una missione commerciale, dare una grande somma di oro, o costruire una Dogana (+4 Oro)"
Russian:"Может предпринять торговую миссию, дать большую сумму золота или построить Таможенную палату (+4 золота)"
French:"Peut entreprendre une mission commerciale, donner une grosse somme d'or, ou construire une maison de douane (+4 pièces d'or)"
Romanian:"Poate să întreprindă o misiune comercială, să dea o sumă mare de aur sau să construiască o casă vamală (+4 de aur)"
German:"Kann eine Handelsmission unternehmen, viel Gold geben oder ein Zollamt (+4 Gold) bauen"
Dutch:"Kan een handelsmissie ondergaan, levert veel goud op, of bouwt een Douanekantoor (+4 goud) bouwen"
Portuguese:"Pode realizar uma missão comercial, dando uma grande soma de ouro, ou construir uma Alfândega (+4 de Ouro)"
Spanish:"Puede emprender una misión de comercio que proporciona una gran suma de oro, o construir una Aduana (+4 oro)"
Simplified_Chinese:"通过开展贸易获得大笔金钱或建造1座海关(+4金)"
}
"Can speed up construction of a wonder, or construct a Manufactory (+4 Production)":{
Italian:"Può velocizzare la costruzione di una meraviglia, o costruire una Manifattura (+4 Produzione)"
Russian:"Может ускорить строительство чуда или построить Завод (+4 производства)"
French:"Peut accélérer la construction d'une merveille, ou construire une manufacture (+4 production)"
Romanian:"Poate accelera construcția unei minune sau poate construi o fabrică (+4 producție)"
German:"Kann die Bauzeit eines Wunders verkürzen oder eine Fabrik (+4 Produktion) bauen"
Dutch:"Kan de produtie van een wonder versnellen, of kan een Fabriek (+4 productie) bouwen"
Spanish:"Puede acelerar la construción de una Maravilla o construir una Fábrica (+4 producción)"
Portuguese:"Pode acelerar a construção de uma maravilha ou construir uma manufatura (+4 de Produção)"
Simplified_Chinese:"加快奇观的建造速度或建造1座工厂(+4生产)"
}
"Create [improvementName]":{ // for unit action button - also used for "create fishing boats" and "create oil well"
Italian:"Costruisci [improvementName]"
Romanian:"Crează [improvementName]"
Spanish:"Crear [improvmentName]"
Simplified_Chinese:"建造[improvementName]"
German:"[improvementName] anlegen"
French:"Créer [improvementName]"
Russian:"Создайте [improvementName]"
Portuguese:"Cria [improvementName]"
}
"Start Golden Age":{
Italian:"Avvia un'Età dell'Oro"
Romanian:"Începe epoca de aur"
Spanish:"Empezar Edad Dorada"
Simplified_Chinese:"开启8回合黄金时代"
German:"Starte Goldenes Zeitalter" //I chose to transl. as if Golden Age is a proper name
French:"Commencer un âge d'Or"
Russian:"Начать золотой век"
Portuguese:"Começar a Idade Dourada" // ç=ss or depending on situation just s
}
// for unit action button
"Discover Technology":{
@ -2169,7 +2096,7 @@
"Unhappiness from number of Cities doubled. Unhappiness from number of Citizens halved.":{
Italian:"Raddoppia l'Infelicità dal numero di Città, ma la dimezza dal numero di Cittadini."
Portugue:"Tristeza por número de cidades dobrada e tristeza por número de cidadões reduzida pela metade"
Portuguese:"Tristeza por número de cidades dobrada e tristeza por número de cidadões reduzida pela metade"
}
/*
@ -2712,6 +2639,11 @@
Simplified_Chinese:"歃血之盟"
Portuguese:"Aliado"
}
// City State bonuses
"Provides [amountOfCulture] culture at 30 Influence":{}
"Provides 3 food in capital and 1 food in other cities at 30 Influence":{}
"Provides 3 happiness at 30 Influence":{}
////// Diplomatic modifiers
@ -3171,7 +3103,8 @@
"Cost":{
Italian:"Costo"
Simplified_Chinese:"花费"
French:"Côte"
French:"Côte"
French:"Côte"
Portuguese:"Custo"
}
@ -3213,7 +3146,7 @@
"Requires a [buildingName] in all cities":{
Italian:"Richiede [buildingName] in tutte le città"
Simplified_Chinese:"需要所有城市建有[buildingName]"
French:"Nécessite un(e) [buildingName] dans toutes les villes"
French:"Nécessite un(e) [buildingName] dans toutes les villes"
Portuguese:"Requer um(a) [buildingName] em todas as cidades"
}
@ -3227,7 +3160,7 @@
"Requires [resource]":{
Italian:"Richiede [resource]"
Simplified_Chinese:"需要资源:[resource]"
French:"[resource] requis(e)"
French:"[resource] requis(e)"
Portuguese:"Requer [resource]"
}
@ -3320,14 +3253,13 @@
German: "Unwegsames Gelände"
}
" for ":{ //for example:+1 Gold for Gems,Gold,Silver
" for ":{ //for example:+1 Gold for Gems,Gold,Silver
Italian:" per "
Simplified_Chinese:",当建造在拥有下列资源的地块上时:"
French:"par "
Portuguese:"Por "
}
}
// Options menu, pointed out by Smashfanful
"Missing translations:":{
Italian:"Traduzioni mancanti:"

View File

@ -250,7 +250,7 @@ class NextTurnAutomation{
val diplomacy = civInfo.getDiplomacyManager(otherCiv)
val unitsInBorder = otherCiv.getCivUnits().count { !it.type.isCivilian() && it.getTile().getOwner() == civInfo }
if (unitsInBorder > 0 && diplomacy.influence < 30f) {
if (unitsInBorder > 0 && diplomacy.relationshipLevel() < RelationshipLevel.Friend) {
diplomacy.influence -= 10f
if (!diplomacy.hasFlag(DiplomacyFlags.BorderConflict)) {
otherCiv.popupAlerts.add(PopupAlert(AlertType.BorderConflict,civInfo.civName))

View File

@ -1,10 +1,11 @@
package com.unciv.logic.city
import com.unciv.Constants
import com.unciv.UnCivGame
import com.unciv.logic.civilization.CityStateType
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
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
@ -123,15 +124,11 @@ class CityStats {
private fun getStatsFromCityStates(): Stats {
val stats = Stats()
for (otherCivName in cityInfo.civInfo.diplomacy.keys) {
val otherCiv = cityInfo.civInfo.gameInfo.getCivilization(otherCivName)
for (otherCiv in cityInfo.civInfo.getKnownCivs()) {
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
}
&& otherCiv.getDiplomacyManager(cityInfo.civInfo).relationshipLevel() >= RelationshipLevel.Friend) {
if (cityInfo.isCapital()) stats.food += 3
else stats.food += 1
}
}

View File

@ -9,6 +9,7 @@ import com.unciv.logic.GameInfo
import com.unciv.logic.city.CityInfo
import com.unciv.logic.civilization.diplomacy.DiplomacyManager
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
import com.unciv.logic.civilization.diplomacy.RelationshipLevel
import com.unciv.logic.map.BFS
import com.unciv.logic.map.MapUnit
import com.unciv.logic.map.RoadStatus
@ -124,7 +125,8 @@ class CivilizationInfo {
return translatedNation
}
fun getDiplomacyManager(civInfo: CivilizationInfo) = diplomacy[civInfo.civName]!!
fun getDiplomacyManager(civInfo: CivilizationInfo) = getDiplomacyManager(civInfo.civName)
fun getDiplomacyManager(civName: String) = diplomacy[civName]!!
fun getKnownCivs() = diplomacy.values.map { it.otherCiv() }
fun knows(otherCivName: String) = diplomacy.containsKey(otherCivName)
@ -150,9 +152,9 @@ class CivilizationInfo {
}
//City states culture bonus
for (otherCivName in diplomacy.keys) {
val otherCiv = gameInfo.getCivilization(otherCivName)
if (otherCiv.isCityState() && otherCiv.getCityStateType() == CityStateType.Cultured && otherCiv.diplomacy[civName]!!.influence >= 60) {
for (otherCiv in getKnownCivs()) {
if (otherCiv.isCityState() && otherCiv.getCityStateType() == CityStateType.Cultured
&& otherCiv.getDiplomacyManager(civName).relationshipLevel() >= RelationshipLevel.Friend) {
val cultureBonus = Stats()
cultureBonus.add(Stat.Culture, 5.0f * getEra().ordinal)
if (statMap.containsKey("City States"))
@ -245,9 +247,9 @@ class CivilizationInfo {
}
//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) {
for (otherCiv in getKnownCivs()) {
if (otherCiv.isCityState() && otherCiv.getCityStateType() == CityStateType.Mercantile
&& otherCiv.getDiplomacyManager(this).relationshipLevel() >= RelationshipLevel.Friend) {
if (statMap.containsKey("City-states"))
statMap["City-states"] = statMap["City-states"]!! + 3f
else

View File

@ -63,7 +63,7 @@ class DiplomacyManager() {
* As for why it's String and not DiplomaticModifier see FlagsCountdown comment */
var diplomaticModifiers = HashMap<String,Float>()
/** For city-states */
/** For city-states. Influence is saved in the CITY STATE -> major civ Diplomacy, NOT in the major civ -> cty state diplomacy. */
var influence = 0f
fun clone(): DiplomacyManager {
@ -98,29 +98,39 @@ class DiplomacyManager() {
fun opinionOfOtherCiv() = diplomaticModifiers.values.sum()
fun relationshipLevel(): RelationshipLevel {
if(civInfo.isPlayerCivilization() && otherCiv().isPlayerCivilization())
return RelationshipLevel.Neutral // People make their own choices.
if(civInfo.isPlayerCivilization())
return otherCiv().getDiplomacyManager(civInfo).relationshipLevel()
if(civInfo.isCityState()){
if (influence<=-60) return RelationshipLevel.Unforgivable
if (influence<=-30) return RelationshipLevel.Enemy
if(civInfo.isAtWarWith(otherCiv()))
return RelationshipLevel.Enemy // See below, same with major civs
if(influence>=60) return RelationshipLevel.Ally
if(influence>=30) return RelationshipLevel.Friend
}
// not entirely sure what to do between AI civs, because they probably have different views of each other,
// maybe we need to average their views of each other? That makes sense to me.
val opinion = opinionOfOtherCiv()
if(opinion<-80) return RelationshipLevel.Unforgivable
if(opinion<-40) return RelationshipLevel.Enemy
if(opinion<=-80) return RelationshipLevel.Unforgivable
if(opinion<=-40) return RelationshipLevel.Enemy
// This is here because when you're at war you can either be enemy OR unforgivable,
// depending on the opinion
if(civInfo.isAtWarWith(otherCiv()))
return RelationshipLevel.Enemy
if(opinion<-15) return RelationshipLevel.Competitor
if(opinion>80) return RelationshipLevel.Ally
if(opinion>40) return RelationshipLevel.Friend
if(opinion>15) return RelationshipLevel.Favorable
if(opinion<=-15) return RelationshipLevel.Competitor
if(opinion>=80) return RelationshipLevel.Ally
if(opinion>=40) return RelationshipLevel.Friend
if(opinion>=15) return RelationshipLevel.Favorable
return RelationshipLevel.Neutral
}
@ -268,6 +278,7 @@ class DiplomacyManager() {
otherCiv.popupAlerts.add(PopupAlert(AlertType.WarDeclaration,civInfo.civName))
otherCivDiplomacy.setModifier(DiplomaticModifiers.DeclaredWarOnUs,-20f)
if(otherCiv.isCityState()) otherCivDiplomacy.influence -= 60
for(thirdCiv in civInfo.getKnownCivs()){
if(thirdCiv.isAtWarWith(otherCiv))

View File

@ -116,18 +116,6 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
transferTrade(ourCivilization,otherCivilization,currentTrade)
transferTrade(otherCivilization,ourCivilization,currentTrade.reverse())
//Buy friendship with gold.
if (currentTrade.theirOffers.isEmpty()) {
for (trade in currentTrade.ourOffers) {
if (trade.type == TradeType.Gold) {
otherCivilization.getDiplomacyManager(ourCivilization).influence += trade.amount / 10
}
if (trade.type == TradeType.Gold_Per_Turn) {
otherCivilization.getDiplomacyManager(ourCivilization).influence += trade.amount * trade.duration / 10
}
}
}
}
}

View File

@ -177,8 +177,8 @@ class NewGameScreen: PickerScreen(){
newGameOptionsTable.add(enemiesSelectBox).pad(10f).row()
// Todo - re-enable this when city states are fit for players
// addCityStatesSelectBox(newGameOptionsTable)
newGameParameters.numberOfCityStates = 0
addCityStatesSelectBox(newGameOptionsTable)
// newGameParameters.numberOfCityStates = 0
humanPlayers.addListener(object : ChangeListener() {
override fun changed(event: ChangeEvent?, actor: Actor?) {

View File

@ -88,11 +88,11 @@ class DiplomacyScreen:CameraStageBaseScreen() {
}
fun giveGoldGift(otherCiv: CivilizationInfo, giftAmount: Int) {
if(!otherCiv.isCityState()) throw Exception("You can only gain influence with city states!")
val currentPlayerCiv = UnCivGame.Current.gameInfo.getCurrentPlayerCivilization()
currentPlayerCiv.gold -= giftAmount
otherCiv.getDiplomacyManager(currentPlayerCiv).influence += giftAmount/10
rightSideTable.clear()
rightSideTable.add(getCityStateDiplomacyTable(otherCiv))
updateRightSide(otherCiv)
}
@ -103,17 +103,22 @@ class DiplomacyScreen:CameraStageBaseScreen() {
if (otherCiv.isCityState()) {
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel()).row()
diplomacyTable.add(("Type: " + otherCiv.getCityStateType().toString()).toLabel()).row()
diplomacyTable.add(("Influence: " + otherCiv.getDiplomacyManager(currentPlayerCiv).influence.toInt()+"/60").toLabel()).row()
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())
}
diplomacyTable.add(("Influence: " + otherCiv.getDiplomacyManager(currentPlayerCiv).influence.toInt()+"/30").toLabel()).row()
diplomacyTable.add(getRelationshipTable(otherCiv.getDiplomacyManager(currentPlayerCiv))).row()
val friendBonusText = when(otherCiv.getCityStateType()) {
CityStateType.Cultured -> "Provides [" + (5.0f * currentPlayerCiv.getEra().ordinal).toString() + "] culture at 30 Influence"
CityStateType.Maritime -> "Provides 3 food in capital and 1 food in other cities at 30 Influence"
CityStateType.Mercantile -> "Provides 3 happiness at 30 Influence"
}
val friendBonusLabel = friendBonusText.toLabel()
if (otherCiv.getDiplomacyManager(currentPlayerCiv).relationshipLevel() >= RelationshipLevel.Friend)
friendBonusLabel.setFontColor(Color.GREEN)
else
friendBonusLabel.setFontColor(Color.GRAY)
diplomacyTable.add(friendBonusLabel).row()
} else {
diplomacyTable.add(otherCiv.getNation().getLeaderDisplayName().toLabel())
}
@ -194,22 +199,11 @@ class DiplomacyScreen:CameraStageBaseScreen() {
}
val diplomacyModifiersTable = Table()
val otherCivDiplomacyManager = otherCiv.getDiplomacyManager(currentPlayerCiv)
val relationshipTable = Table()
relationshipTable.add("Our relationship: ".toLabel())
val relationshipLevel = otherCivDiplomacyManager.relationshipLevel()
val relationshipText = otherCivDiplomacyManager.relationshipLevel().toString().tr() + " (" + otherCivDiplomacyManager.opinionOfOtherCiv().toInt() + ")"
val relationshipColor = when {
relationshipLevel == RelationshipLevel.Neutral -> Color.WHITE
relationshipLevel == RelationshipLevel.Favorable || relationshipLevel == RelationshipLevel.Friend
|| relationshipLevel == RelationshipLevel.Ally -> Color.GREEN
else -> Color.RED
}
relationshipTable.add(relationshipText.toLabel().setFontColor(relationshipColor))
diplomacyModifiersTable.add(relationshipText.toLabel()).row()
diplomacyTable.add(getRelationshipTable(otherCivDiplomacyManager)).row()
val diplomacyModifiersTable = Table()
for (modifier in otherCivDiplomacyManager.diplomaticModifiers) {
var text = when (valueOf(modifier.key)) {
DeclaredWarOnUs -> "You declared war on us!"
@ -234,6 +228,26 @@ class DiplomacyScreen:CameraStageBaseScreen() {
return diplomacyTable
}
fun getRelationshipTable(otherCivDiplomacyManager: DiplomacyManager): Table {
val relationshipTable = Table()
val opinionOfUs = if(otherCivDiplomacyManager.civInfo.isCityState()) otherCivDiplomacyManager.influence.toInt()
else otherCivDiplomacyManager.opinionOfOtherCiv().toInt()
relationshipTable.add("Our relationship: ".toLabel())
val relationshipLevel = otherCivDiplomacyManager.relationshipLevel()
val relationshipText = relationshipLevel.name.tr() + " ($opinionOfUs)"
val relationshipColor = when {
relationshipLevel == RelationshipLevel.Neutral -> Color.WHITE
relationshipLevel == RelationshipLevel.Favorable || relationshipLevel == RelationshipLevel.Friend
|| relationshipLevel == RelationshipLevel.Ally -> Color.GREEN
else -> Color.RED
}
relationshipTable.add(relationshipText.toLabel().setFontColor(relationshipColor))
return relationshipTable
}
private fun getDeclareWarButton(diplomacyManager: DiplomacyManager, otherCiv: CivilizationInfo): TextButton {
val declareWarButton = TextButton("Declare war".tr(), skin)
declareWarButton.color = Color.RED