From 1b2fa7317e12666689fff96be75b5cc6c6565149 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 21 May 2018 23:00:09 +0300 Subject: [PATCH] Added unit obsolesence --- android/assets/jsons/Tutorials.json | 21 ++++++++++++ android/assets/jsons/Units.json | 9 ++++++ android/build.gradle | 4 +-- .../unciv/logic/civilization/TechManager.kt | 28 ++++++++++------ core/src/com/unciv/models/gamebasics/Unit.kt | 32 +++++++++++-------- .../com/unciv/ui/worldscreen/WorldScreen.kt | 3 ++ 6 files changed, 72 insertions(+), 25 deletions(-) diff --git a/android/assets/jsons/Tutorials.json b/android/assets/jsons/Tutorials.json index 949eaa6c94..f1ef3cd3f0 100644 --- a/android/assets/jsons/Tutorials.json +++ b/android/assets/jsons/Tutorials.json @@ -147,4 +147,25 @@ ] ] + ContactMe: [ + [ + "Hi there! If you've played this far, you've probably", + " seen that the game is currently incomplete.", + "UnCiv is meant to be open-source and free, forever.", + " That means no ads or any other nonsense.", + ], + [ + "What motivates me to keep working on it, ", + " besides the fact I think it's amazingly cool that I can," + " is the support from the players - you guys are the best!" + ], + [ + "Every rating and review that I get puts a smile on my face =)", + " So contact me! Send me an email, review, Github issue" + " or mail pigeon, and let's figure out how to make the game ", + " even more awesome!" + "(Contact info is in the Play Store)" + ] + ], + } diff --git a/android/assets/jsons/Units.json b/android/assets/jsons/Units.json index b04076d61a..62da8f6d79 100644 --- a/android/assets/jsons/Units.json +++ b/android/assets/jsons/Units.json @@ -1,5 +1,7 @@ [ +// Info according to Civilization Wiki and https://www.civfanatics.com/civ5/info/units/ + /* Ancient Era */ { name:"Worker", @@ -32,6 +34,7 @@ strength:8, cost: 40, hurryCostModifier:20, + obsoleteTech:"Metal Casting", upgradesTo:"Swordsman" }, { @@ -42,6 +45,8 @@ rangedStrength:7, cost: 40, hurryCostModifier:20 + obsoleteTech:"Machinery", + upgradesTo:"Crossbowman" }, { name:"Chariot Archer", @@ -62,6 +67,8 @@ strength:11, cost: 56, requiredTech:"Bronze Working", + obsoleteTech:"Civil Service", + upgradesTo: "Pikeman", uniques:["Bonus vs Mounted 50%"], hurryCostModifier:20 }, @@ -76,6 +83,8 @@ rangedStrength:8, cost: 75, requiredTech:"Mathematics", + obsoleteTech:"Physics", + upgradesTo: "Trebuchet", uniques:["Bonus vs City 200%","No defensive terrain bonus","Must set up to ranged attack"], hurryCostModifier:20 }, diff --git a/android/build.gradle b/android/build.gradle index edefdbf9b3..8915b869d5 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,8 +21,8 @@ android { applicationId "com.unciv.game" minSdkVersion 14 targetSdkVersion 26 - versionCode 60 - versionName "2.2.1" + versionCode 61 + versionName "2.2.2" } buildTypes { release { diff --git a/core/src/com/unciv/logic/civilization/TechManager.kt b/core/src/com/unciv/logic/civilization/TechManager.kt index f565b018a5..30c2c0aff9 100644 --- a/core/src/com/unciv/logic/civilization/TechManager.kt +++ b/core/src/com/unciv/logic/civilization/TechManager.kt @@ -3,6 +3,7 @@ package com.unciv.logic.civilization import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.Technology +import com.unciv.models.gamebasics.Unit import java.util.* class TechManager { @@ -49,6 +50,7 @@ class TechManager { techsInProgress[currentTechnology] = researchOfTech(currentTechnology) + scienceForNewTurn if (techsInProgress[currentTechnology]!! < getCurrentTechnology().cost) return + // We finished it! techsInProgress.remove(currentTechnology) techsToResearch.remove(currentTechnology) @@ -57,18 +59,26 @@ class TechManager { val revealedResource = GameBasics.TileResources.values.firstOrNull { currentTechnology == it.revealedBy } - if (revealedResource == null) return - for (tileInfo in civInfo.gameInfo.tileMap.values - .filter { it.resource == revealedResource.name && civInfo == it.getOwner() }) { + if (revealedResource != null) { + for (tileInfo in civInfo.gameInfo.tileMap.values + .filter { it.resource == revealedResource.name && civInfo == it.getOwner() }) { - val closestCityTile = tileInfo.getTilesInDistance(4) - .firstOrNull { it.isCityCenter() } - if (closestCityTile != null) { - civInfo.addNotification( - revealedResource.name + " revealed near " + closestCityTile.getCity()!!.name, tileInfo.position) - break + val closestCityTile = tileInfo.getTilesInDistance(4) + .firstOrNull { it.isCityCenter() } + if (closestCityTile != null) { + civInfo.addNotification( + revealedResource.name + " revealed near " + closestCityTile.getCity()!!.name, tileInfo.position) + break + } } } + + val obsoleteUnits = GameBasics.Units.values.filter { it.obsoleteTech==currentTechnology } + for(city in civInfo.cities) + if(city.cityConstructions.getCurrentConstruction() in obsoleteUnits){ + val currentConstructionUnit = city.cityConstructions.getCurrentConstruction() as Unit + city.cityConstructions.currentConstruction = currentConstructionUnit.upgradesTo!! + } } } diff --git a/core/src/com/unciv/models/gamebasics/Unit.kt b/core/src/com/unciv/models/gamebasics/Unit.kt index c206db6797..25e2b06728 100644 --- a/core/src/com/unciv/models/gamebasics/Unit.kt +++ b/core/src/com/unciv/models/gamebasics/Unit.kt @@ -7,6 +7,23 @@ import com.unciv.logic.map.UnitType import com.unciv.models.stats.INamed class Unit : INamed, IConstruction, ICivilopedia { + + override lateinit var name: String + var baseDescription: String? = null + var cost: Int = 0 + var hurryCostModifier: Int = 0 + var movement: Int = 0 + var strength:Int = 0 + var rangedStrength:Int = 0 + lateinit var unitType: UnitType + internal var unbuildable: Boolean = false // for special units like great people + var requiredTech:String? = null + var requiredResource:String? = null + var uniques:HashSet?=null + var obsoleteTech:String?=null + var upgradesTo:String? = null + + override val description: String get(){ return getDescription(false) @@ -44,20 +61,6 @@ class Unit : INamed, IConstruction, ICivilopedia { return sb.toString() } - override lateinit var name: String - var baseDescription: String? = null - var cost: Int = 0 - var hurryCostModifier: Int = 0 - var movement: Int = 0 - var strength:Int = 0 - var rangedStrength:Int = 0 - lateinit var unitType: UnitType - internal var unbuildable: Boolean = false // for special units like great people - var requiredTech:String? = null - var requiredResource:String? = null - var uniques:HashSet?=null - var upgradesTo:String? = null - fun getMapUnit(): MapUnit { val unit = MapUnit() unit.name = name @@ -76,6 +79,7 @@ class Unit : INamed, IConstruction, ICivilopedia { val civInfo = construction.cityInfo.civInfo if (unbuildable) return false if (requiredTech!=null && !civInfo.tech.isResearched(requiredTech!!)) return false + if (obsoleteTech!=null && civInfo.tech.isResearched(obsoleteTech!!)) return false if (requiredResource!=null && !civInfo.getCivResources().keys.any { it.name == requiredResource }) return false return true } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index daa193909f..cb2027bbb0 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -112,6 +112,9 @@ class WorldScreen : CameraStageBaseScreen() { GameSaver.saveGame(game.gameInfo, "Autosave") update() displayTutorials("NextTurn") + + if(gameInfo.turns>=100) + displayTutorials("ContactMe") } return nextTurnButton