Trading gold now works as well!

This commit is contained in:
Yair Morgenstern 2018-07-06 16:42:32 +03:00
parent 5fc20fb547
commit 0c17e19ea2
2 changed files with 18 additions and 3 deletions

View file

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.game"
minSdkVersion 14
targetSdkVersion 26
versionCode 96
versionName "2.5.10"
versionCode 97
versionName "2.6.0"
}
buildTypes {
release {

View file

@ -89,6 +89,21 @@ class TradeScreen(val otherCivilization: CivilizationInfo) : CameraStageBaseScre
else if(offerButton.text.toString() == "Accept"){
civInfo.diplomacy[otherCivilization.civName]!!.trades.add(currentTrade)
otherCivilization.diplomacy[civInfo.civName]!!.trades.add(currentTrade.reverse())
// instant transfers
for(offer in currentTrade.theirOffers){
if(offer.type==TradeType.Gold){
civInfo.gold += offer.amount
otherCivilization.gold -= offer.amount
}
}
for(offer in currentTrade.ourOffers){
if(offer.type==TradeType.Gold){
civInfo.gold -= offer.amount
otherCivilization.gold += offer.amount
}
}
val newTradeScreen = TradeScreen(otherCivilization)
UnCivGame.Current.screen = newTradeScreen
newTradeScreen.tradeText.setText("Pleasure doing business with you!")
@ -164,7 +179,7 @@ class TradeScreen(val otherCivilization: CivilizationInfo) : CameraStageBaseScre
}
fun evaluateOffer(offer:TradeOffer, otherCivIsRecieving:Boolean): Int {
if(offer.type==TradeType.Gold) return 1
if(offer.type==TradeType.Gold) return offer.amount
if(offer.type == TradeType.Luxury_Resource){
var value = 100*offer.amount
if(!theirAvailableOffers.any { it.name==offer.name }) // We want to take away their last luxury or give them one they don't have