From 48af218795f92eaff81d542d688f24e9a1c84163 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 13 May 2019 22:23:30 +0300 Subject: [PATCH] Strategic resources cost more in trade from a civ who's at war and can use them for units --- .../jsons/Translations/Units,Promotions.json | 2 +- android/build.gradle | 4 +-- .../com/unciv/logic/trade/TradeEvaluation.kt | 25 ++++++++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/android/assets/jsons/Translations/Units,Promotions.json b/android/assets/jsons/Translations/Units,Promotions.json index 4c6849a21e..fe56cd126f 100644 --- a/android/assets/jsons/Translations/Units,Promotions.json +++ b/android/assets/jsons/Translations/Units,Promotions.json @@ -698,7 +698,7 @@ } "Bonus vs Mounted 33%":{ - Italian:"+33% Bonus contro unità a cavallo + Italian:"+33% Bonus contro unità a cavallo" Simplified_Chinese:"对战骑乘单位时+33%战斗力" } diff --git a/android/build.gradle b/android/build.gradle index e74db30ef1..a15adb60a5 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.app" minSdkVersion 14 targetSdkVersion 28 - versionCode 240 - versionName "2.16.4" + versionCode 241 + versionName "2.16.5" } // Had to add this crap for Travis to build, it wanted to sign the app diff --git a/core/src/com/unciv/logic/trade/TradeEvaluation.kt b/core/src/com/unciv/logic/trade/TradeEvaluation.kt index 8d7f9e4602..411d22d8be 100644 --- a/core/src/com/unciv/logic/trade/TradeEvaluation.kt +++ b/core/src/com/unciv/logic/trade/TradeEvaluation.kt @@ -133,7 +133,30 @@ class TradeEvaluation{ return 250 // fair price else return 500 // you want to take away our last lux of this type?! } - TradeType.Strategic_Resource -> return 50*offer.amount + TradeType.Strategic_Resource -> { + if(!civInfo.isAtWar()) return 50*offer.amount + + val canUseForUnits = GameBasics.Units.values + .any { it.requiredResource==offer.name && it.isBuildable(civInfo) } + if(!canUseForUnits) return 50*offer.amount + + val amountLeft = civInfo.getCivResourcesByName()[offer.name]!! + + // Each strategic resource starts costing 100 more when we ass the 5 resources baseline + // That is to say, if I have 4 and you take one away, that's 200 + // take away the third, that's 300, 2nd 400, 1st 500 + + // So if he had 5 left, and we want to buy 2, then we want to buy his 5th and 4th last resources, + // So we'll calculate how much he'll sell his 4th for (200) and his 5th for (100) + var totalCost = 0 + + // I know it's confusing, you're welcome to change to a more understandable way of counting if you can think of one... + for(numberOfResource in (amountLeft-offer.amount+1)..amountLeft){ + if(numberOfResource>5) totalCost+=100 + else totalCost += (6-numberOfResource) * 100 + } + return totalCost + } TradeType.Technology -> return sqrt(GameBasics.Technologies[offer.name]!!.cost.toDouble()).toInt()*20 TradeType.Introduction -> return 250 TradeType.WarDeclaration -> {