"Introduction to X" and "Declare war on X" trade items are now only X, adding the extra text on UI display - this makes them translatable

This commit is contained in:
Yair Morgenstern 2019-10-04 16:49:31 +03:00
parent aafe23a2f5
commit 2a00ab2775
5 changed files with 29 additions and 20 deletions

View file

@ -222,6 +222,15 @@ class GameInfo {
// As of 2.16.1, changed Colloseum to Colosseum
changeBuildingName(cityConstructions, "Colloseum", "Colosseum")
}
// This doesn't HAVE to go here, but why not.
// As of version 3.1.3, trade offers of "Declare war on X" and "Introduction to X" were changed to X,
// with the extra text being added only on UI display (solved a couple of problems).
for(trade in civInfo.tradeRequests.map { it.trade })
for(offer in trade.theirOffers.union(trade.ourOffers)){
offer.name = offer.name.removePrefix("Declare war on ")
offer.name = offer.name.removePrefix("Introduction to ")
}
}
for (civInfo in civilizations) civInfo.setNationTransient()

View file

@ -122,8 +122,7 @@ class TradeEvaluation{
* civInfo.gameInfo.gameParameters.gameSpeed.getModifier()).toInt()*20
TradeType.Introduction -> return 250
TradeType.WarDeclaration -> {
val nameOfCivToDeclareWarOn = offer.name.removePrefix("Declare war on ")
val civToDeclareWarOn = civInfo.gameInfo.getCivilization(nameOfCivToDeclareWarOn)
val civToDeclareWarOn = civInfo.gameInfo.getCivilization(offer.name)
val threatToThem = Automation().threatAssessment(civInfo,civToDeclareWarOn)
if(civInfo.isAtWarWith(civToDeclareWarOn)){
@ -193,8 +192,7 @@ class TradeEvaluation{
TradeType.Technology -> return sqrt(GameBasics.Technologies[offer.name]!!.cost.toDouble()).toInt()*20
TradeType.Introduction -> return 250
TradeType.WarDeclaration -> {
val nameOfCivToDeclareWarOn = offer.name.removePrefix("Declare war on ")
val civToDeclareWarOn = civInfo.gameInfo.getCivilization(nameOfCivToDeclareWarOn)
val civToDeclareWarOn = civInfo.gameInfo.getCivilization(offer.name)
val threatToUs = Automation().threatAssessment(civInfo, civToDeclareWarOn)
when (threatToUs) {

View file

@ -55,7 +55,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
.filter { !otherCivilization.diplomacy.containsKey(it.civName) && !it.isDefeated() }
for (thirdCiv in civsWeKnowAndTheyDont) {
offers.add(TradeOffer("Introduction to " + thirdCiv.civName, TradeType.Introduction, 0))
offers.add(TradeOffer(thirdCiv.civName, TradeType.Introduction, 0))
}
if (!civInfo.isCityState() && !otherCivilization.isCityState()) {
@ -64,7 +64,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
val civsWeArentAtWarWith = civsWeBothKnow
.filter { civInfo.getDiplomacyManager(it).diplomaticStatus == DiplomaticStatus.Peace }
for (thirdCiv in civsWeArentAtWarWith) {
offers.add(TradeOffer("Declare war on " + thirdCiv.civName, TradeType.WarDeclaration, 0))
offers.add(TradeOffer(thirdCiv.civName, TradeType.WarDeclaration, 0))
}
}
@ -91,21 +91,21 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
if (offer.type == TradeType.Technology) {
to.tech.addTechnology(offer.name)
}
if(offer.type== TradeType.City){
val city = from.cities.first { it.name==offer.name }
if (offer.type == TradeType.City) {
val city = from.cities.first { it.name == offer.name }
city.moveToCiv(to)
city.getCenterTile().getUnits().forEach { it.movement.teleportToClosestMoveableTile() }
to.updateViewableTiles()
from.updateViewableTiles()
}
if(offer.type== TradeType.Treaty){
if(offer.name==Constants.peaceTreaty) to.getDiplomacyManager(from).makePeace()
if (offer.type == TradeType.Treaty) {
if (offer.name == Constants.peaceTreaty) to.getDiplomacyManager(from).makePeace()
}
if(offer.type==TradeType.Introduction)
to.meetCivilization(to.gameInfo.getCivilization(offer.name.removePrefix("Introduction to " )))
if (offer.type == TradeType.Introduction)
to.meetCivilization(to.gameInfo.getCivilization(offer.name))
if(offer.type==TradeType.WarDeclaration){
val nameOfCivToDeclareWarOn = offer.name.removePrefix("Declare war on ")
if (offer.type == TradeType.WarDeclaration) {
val nameOfCivToDeclareWarOn = offer.name
from.getDiplomacyManager(nameOfCivToDeclareWarOn).declareWar()
}
}
@ -113,8 +113,8 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
to.updateDetailedCivResources()
}
transferTrade(ourCivilization,otherCivilization,currentTrade)
transferTrade(otherCivilization,ourCivilization,currentTrade.reverse())
transferTrade(ourCivilization, otherCivilization, currentTrade)
transferTrade(otherCivilization, ourCivilization, currentTrade.reverse())
}
}

View file

@ -15,8 +15,12 @@ data class TradeOffer(var name:String, var type: TradeType,
fun getOfferText(): String {
var offerText = name.tr()
if (type !in tradesToNotHaveNumbers) offerText += " (" + amount + ")"
var offerText = when(type){
TradeType.WarDeclaration -> "Declare war on [$name]"
TradeType.Introduction -> "Introduction to [$name]"
else -> name
}.tr()
if (type !in tradesToNotHaveNumbers) offerText += " ($amount)"
if (duration > 0) offerText += "\n" + duration + " {turns}".tr()
return offerText
}

View file

@ -39,8 +39,6 @@ class Building : NamedStats(), IConstruction{
var replaces:String?=null
var uniqueTo:String?=null
var quote:String=""
// Uniques
private var providesFreeBuilding: String? = null
var uniques = ArrayList<String>()