From 25fc1b3c71c10f092fe41f91d282fc03706e4b43 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 24 May 2019 13:59:00 +0300 Subject: [PATCH] Last fixes for Indian nation! Checks for specific buildings now work for all civ-unique buildings as well --- android/assets/jsons/Buildings.json | 4 +- android/assets/jsons/Nations.json | 69 ++++++++++--------- android/assets/jsons/Units.json | 3 - .../com/unciv/logic/city/CityConstructions.kt | 1 - core/src/com/unciv/logic/city/CityInfo.kt | 4 +- .../logic/civilization/CivilizationInfo.kt | 19 +++-- core/src/com/unciv/logic/map/MapUnit.kt | 11 ++- .../com/unciv/models/gamebasics/Building.kt | 26 ++++--- 8 files changed, 73 insertions(+), 64 deletions(-) diff --git a/android/assets/jsons/Buildings.json b/android/assets/jsons/Buildings.json index be1578f908..4de62a4681 100644 --- a/android/assets/jsons/Buildings.json +++ b/android/assets/jsons/Buildings.json @@ -395,19 +395,17 @@ requiredBuilding:"Walls", requiredTech:"Chivalry" }, - /* { name:"Mughal Fort", replaces:"Castle", uniqueTo:"India", cityStrength:7, cityHealth:25, - culture:2; + culture:2, hurryCostModifier:25, requiredBuilding:"Walls", requiredTech:"Chivalry" }, - */ { name:"Angkor Wat", culture:1, diff --git a/android/assets/jsons/Nations.json b/android/assets/jsons/Nations.json index 0a54dde3df..b01a5678e6 100644 --- a/android/assets/jsons/Nations.json +++ b/android/assets/jsons/Nations.json @@ -377,6 +377,40 @@ unique: "Units fight as though they were at full strength even when damaged", cities:["Kyoto","Osaka","Tokyo","Satsuma","Kagoshima","Nara","Nagoya","Izumo","Nagasaki","Yokohama","Shimonoseki","Matsuyama","Sapporo","Hakodate","Ise","Toyama","Fukushima","Suo","Bizen","Echizen","Izumi","Omi","Echigo","Kozuke","Sado","Kobe","Nagano","Hiroshima","Takayama","Akita","Fukuoka","Aomori","Kamakura","Kochi","Naha","Sendai","Gifu","Yamaguchi","Ota","Tottori"] }, + { + name:"India", + leaderName:"Gandhi", + adjective:["Indian"], + startBias:["Grassland"], + + startIntroPart1: "Greetings, President Mahatma Gandhi, great souled leader of India! You are the ruler of one of the oldest countries in the world with history stretching back almost 10'000 years. A spiritual country, India is the birthplace of three of the world's great religions - Hinduism, Buddhism and Jainism. This is a passionate land of music and color, a land of great wealth and grinding poverty. For centuries, India was divided into kingdoms who fought constantly with each other and against outside invaders. That was, horever, after empires such as Maratha, Maurya and Gupta. In the 12th century AD, India was conquered by Muslim Turks fled from the Mongols. In the early 17th century, the English arrived, and thought a combination of shrewd diplomacy and technological supeiority, they conquered your fragmented nation. England remained in power for some two centuries until driven out by a rising wave of Indian nationalism, a peaceful rebellion unlike any before seen in history, one led by you!" + startIntroPart2: "Gandhi, your people look to you to lead them to even greater heights of glory! Can you help your people realize their great potential, to once again become the world's center of arts, culture and religion? Can you build a civilization that will stand the test of time?" + + declaringWar:"I have just received a report that large numbers of my troops have crossed your borders." + attacked:"My attempts to avoid violence have failed. An eye for an eye only makes the world blind." + defeated:"You can chain me, you can torture me, you can even destroy this body, but you will never imprison my mind. " + introduction:"Hello, I am Mohandas Gandhi. My people call me Bapu, but please, call me friend." + + neutralHello:"I wish you peace." + neutralLetsHearIt:["Go ahead.","Yes?","I'm listening."] + neutralNo:["Absolutely not.","No.","This is unacceptable"] + neutralYes:["Okay.","We agree.","Fine."] + + hateHello:"What do you want?" + hateLetsHearIt:["Continue.","And?","Go on."] + hateNo:["This is not acceptable.","You are probably not serious.","This is impossible."] + hateYes:["Oh. Very good.","I think that I should accept.","Very well..."] + + afterPeace:"I am happy that it is once again peaceful at our place, even if we had to pay a price for it." + tradeRequest:"My friend, are you interested in this arrangement?" + + mainColor:[16,126,5], + secondaryColor:[255,153,51], + unique:"Unhappiness from number of Cities doubled, Unhappiness from number of Citizens halved.", + cities:["Delhi","Mumbai","Vijayanagara","Pataliputra","Varanasi","Agra","Calcutta","Lahore","Bangalore","Hyderabad","Madurai","Ahmedabad", + "Kolhapur","Prayaga","Ayodhya","Indraprastha","Mathura","Ujjain","Gulbarga","Jaunpur","Rajagriha","Sravasti","Tiruchirapalli","Thanjavur", + "Bodhgaya","Kushinagar","Amaravati","Gaur","Gwalior","Jaipur","Karachi"] + }, /* { name:"Germany", @@ -415,40 +449,7 @@ "Osnabruck","Ludwingshafen","Leverkusen","Oldenburg","Neuss","Mulheim","Darmstadt","Herne","Wurzburg", "Recklinghausen","Gצttingen","Wolfsburg","Koblenz","Hildesheim","Erlangen"] }, - { - name:"India", - leaderName:"Gandhi", - adjective:["Indian"], - startBias:["Grassland"], - - startIntroPart1: "Greetings, President Mahatma Gandhi, great souled leader of India! You are the ruler of one of the oldest countries in the world with history stretching back almost 10'000 years. A spiritual country, India is the birthplace of three of the world's great religions - Hinduism, Buddhism and Jainism. This is a passionate land of music and color, a land of great wealth and grinding poverty. For centuries, India was divided into kingdoms who fought constantly with each other and against outside invaders. That was, horever, after empires such as Maratha, Maurya and Gupta. In the 12th century AD, India was conquered by Muslim Turks fled from the Mongols. In the early 17th century, the English arrived, and thought a combination of shrewd diplomacy and technological supeiority, they conquered your fragmented nation. England remained in power for some two centuries until driven out by a rising wave of Indian nationalism, a peaceful rebellion unlike any before seen in history, one led by you!" - startIntroPart2: "Gandhi, your people look to you to lead them to even greater heights of glory! Can you help your people realize their great potential, to once again become the world's center of arts, culture and religion? Can you build a civilization that will stand the test of time?" - - declaringWar:"I have just received a report that large numbers of my troops have crossed your borders." - attacked:"My attempts to avoid violence have failed. An eye for an eye only makes the world blind." - defeated:"You can chain me, you can torture me, you can even destroy this body, but you will never imprison my mind. " - introduction:"Hello, I am Mohandas Gandhi. My people call me Bapu, but please, call me friend." - - neutralHello:"I wish you peace." - neutralLetsHearIt:["Go ahead.","Yes?","I'm listening."] - neutralNo:["Absolutely not.","No.","This is unacceptable"] - neutralYes:["Okay.","We agree.","Fine."] - - hateHello:"What do you want?" - hateLetsHearIt:["Continue.","And?","Go on."] - hateNo:["This is not acceptable.","You are probably not serious.","This is impossible."] - hateYes:["Oh. Very good.","I think that I should accept.","Very well..."] - - afterPeace:"I am happy that it is once again peaceful at our place, even if we had to pay a price for it." - tradeRequest:"My friend, are you interested in this arrangement?" - - mainColor:[0,255,0], - secondaryColor:[255,153,51], - unique:"Unhappiness from number of Cities doubled, Unhappiness from number of Citizens halved.", - cities:["Delhi","Mumbai","Vijayanagara","Pataliputra","Varanasi","Agra","Calcutta","Lahore","Bangalore","Hyderabad","Madurai","Ahmedabad", - "Kolhapur","Prayaga","Ayodhya","Indraprastha","Mathura","Ujjain","Gulbarga","Jaunpur","Rajagriha","Sravasti","Tiruchirapalli","Thanjavur", - "Bodhgaya","Kushinagar","Amaravati","Gaur","Gwalior","Jaipur","Karachi"] - }, + { name:"Aztecs", leaderName:"Montezuma I", diff --git a/android/assets/jsons/Units.json b/android/assets/jsons/Units.json index 58ff8fcd7c..02f7cff886 100644 --- a/android/assets/jsons/Units.json +++ b/android/assets/jsons/Units.json @@ -202,7 +202,6 @@ hurryCostModifier:20, attackSound:"arrow" }, - /* { name:"War Elephant", unitType:"Ranged", @@ -218,9 +217,7 @@ uniques:["No defensive terrain bonus"], hurryCostModifier:20, attackSound:"horse" - //This is the Indian unique unit. It replaces Chariot Archer, moves slower, has no rough terrain penalty and needs no horses. }, - */ { name:"Spearman", unitType:"Melee", diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index d68fe7f22b..b9c12e4625 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -222,7 +222,6 @@ class CityConstructions { .map { cityInfo.civInfo.getEquivalentBuilding(it) } val buildableCultureBuildings = basicCultureBuildings - .map { GameBasics.Buildings[it]!! } .filter { it.isBuildable(this)} if (buildableCultureBuildings.isEmpty()) return diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 73cd341e6c..a08a0e402e 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -263,9 +263,9 @@ class CityInfo { // Transfer unique buildings for(building in cityConstructions.getBuiltBuildings()) { val civEquivalentBuilding = newCivInfo.getEquivalentBuilding(building.name) - if(building.name != civEquivalentBuilding) { + if(building != civEquivalentBuilding) { cityConstructions.removeBuilding(building.name) - cityConstructions.addBuilding(civEquivalentBuilding) + cityConstructions.addBuilding(civEquivalentBuilding.name) } } diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 94bf1ad63d..f66788187f 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -15,13 +15,10 @@ import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.TileInfo import com.unciv.logic.trade.Trade import com.unciv.models.Counter -import com.unciv.models.gamebasics.Difficulty -import com.unciv.models.gamebasics.GameBasics -import com.unciv.models.gamebasics.Nation +import com.unciv.models.gamebasics.* import com.unciv.models.gamebasics.tech.TechEra import com.unciv.models.gamebasics.tile.ResourceType import com.unciv.models.gamebasics.tile.TileResource -import com.unciv.models.gamebasics.tr import com.unciv.models.stats.Stat import com.unciv.models.stats.Stats import java.util.* @@ -320,13 +317,13 @@ class CivilizationInfo { return null } - fun getEquivalentBuilding(buildingName:String): String { - val building = GameBasics.Buildings[buildingName]!! - val baseBuildingName = if(building.replaces==null) buildingName else building.replaces!! - for(blding in GameBasics.Buildings.values) - if(blding.replaces==buildingName && blding.uniqueTo==civName) - return blding.name - return baseBuildingName + fun getEquivalentBuilding(buildingName:String): Building { + val baseBuilding = GameBasics.Buildings[buildingName]!!.getBaseBuilding() + + for(building in GameBasics.Buildings.values) + if(building.replaces==baseBuilding.name && building.uniqueTo==civName) + return building + return baseBuilding } fun updateViewableTiles() { diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 08ab28767a..59826b7276 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -40,7 +40,16 @@ class MapUnit { var action: String? // work, automation, fortifying, I dunno what. // getter and setter for compatibility: make sure string-based actions still work - get() = (mapUnitAction as? StringAction)?.action ?: mapUnitAction?.let { "" } // null if no action is assigned. + get() { + val mapUnitActionVal=mapUnitAction + if(mapUnitActionVal is StringAction) + return mapUnitActionVal.action + // any other unit action does count as a unit action, thus is not null. The actual logic is not based on an action string, but realized by extending MapUnitAction + if(mapUnitActionVal!=null) + return "" + + return null // unit has no action + } set(value) { mapUnitAction = value?.let{ StringAction(this, value) } } // wrap traditional string-encoded actions into StringAction diff --git a/core/src/com/unciv/models/gamebasics/Building.kt b/core/src/com/unciv/models/gamebasics/Building.kt index 1a295e05d6..826d2b09a5 100644 --- a/core/src/com/unciv/models/gamebasics/Building.kt +++ b/core/src/com/unciv/models/gamebasics/Building.kt @@ -1,12 +1,13 @@ package com.unciv.models.gamebasics +import com.unciv.Constants import com.unciv.logic.city.CityConstructions import com.unciv.logic.city.IConstruction import com.unciv.logic.civilization.CivilizationInfo -import com.unciv.Constants import com.unciv.models.gamebasics.tech.Technology import com.unciv.models.stats.NamedStats -import com.unciv.models.stats.* +import com.unciv.models.stats.Stat +import com.unciv.models.stats.Stats class Building : NamedStats(), IConstruction{ @@ -124,22 +125,24 @@ class Building : NamedStats(), IConstruction{ val stats = this.clone() if(civInfo != null) { val adoptedPolicies = civInfo.policies.adoptedPolicies - if (adoptedPolicies.contains("Organized Religion") && cultureBuildings.contains(name)) + val baseBuildingName = getBaseBuilding().name + + if (adoptedPolicies.contains("Organized Religion") && cultureBuildings.contains(baseBuildingName )) stats.happiness += 1 - if (adoptedPolicies.contains("Free Religion") && cultureBuildings.contains(name)) + if (adoptedPolicies.contains("Free Religion") && cultureBuildings.contains(baseBuildingName )) stats.culture += 1f - if (adoptedPolicies.contains("Entrepreneurship") && hashSetOf("Mint", "Market", "Bank", "Stock Market").contains(name)) + if (adoptedPolicies.contains("Entrepreneurship") && hashSetOf("Mint", "Market", "Bank", "Stock Market").contains(baseBuildingName )) stats.science += 1f - if (adoptedPolicies.contains("Humanism") && hashSetOf("University", "Observatory", "Public School").contains(name)) + if (adoptedPolicies.contains("Humanism") && hashSetOf("University", "Observatory", "Public School").contains(baseBuildingName )) stats.happiness += 1f - if (adoptedPolicies.contains("Theocracy") && name == "Temple") + if (adoptedPolicies.contains("Theocracy") && baseBuildingName == "Temple") percentStatBonus = Stats().apply { gold = 10f } - if (adoptedPolicies.contains("Free Thought") && name == "University") + if (adoptedPolicies.contains("Free Thought") && baseBuildingName == "University") percentStatBonus!!.science = 50f if (adoptedPolicies.contains("Rationalism Complete") && !isWonder && stats.science > 0) @@ -151,7 +154,7 @@ class Building : NamedStats(), IConstruction{ if (adoptedPolicies.contains("Autocracy Complete") && cityStrength > 0) stats.happiness += 1 - if (hashSetOf("Castle", "Mughal Fort").contains(name) + if (baseBuildingName == "Castle" && civInfo.getBuildingUniques().contains("+1 happiness, +2 culture and +3 gold from every Castle")){ stats.happiness+=1 stats.culture+=2 @@ -326,4 +329,9 @@ class Building : NamedStats(), IConstruction{ if (specialistSlots!=null && specialistSlots!!.get(stat)>0) return true return false } + + fun getBaseBuilding(): Building { + if(replaces==null) return this + else return GameBasics.Buildings[replaces!!]!! + } }