mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-10 19:09:06 +07:00
Added unit obsolesence
This commit is contained in:
parent
1de4c2c9f2
commit
1b2fa7317e
@ -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)"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
[
|
[
|
||||||
|
|
||||||
|
// Info according to Civilization Wiki and https://www.civfanatics.com/civ5/info/units/
|
||||||
|
|
||||||
/* Ancient Era */
|
/* Ancient Era */
|
||||||
{
|
{
|
||||||
name:"Worker",
|
name:"Worker",
|
||||||
@ -32,6 +34,7 @@
|
|||||||
strength:8,
|
strength:8,
|
||||||
cost: 40,
|
cost: 40,
|
||||||
hurryCostModifier:20,
|
hurryCostModifier:20,
|
||||||
|
obsoleteTech:"Metal Casting",
|
||||||
upgradesTo:"Swordsman"
|
upgradesTo:"Swordsman"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -42,6 +45,8 @@
|
|||||||
rangedStrength:7,
|
rangedStrength:7,
|
||||||
cost: 40,
|
cost: 40,
|
||||||
hurryCostModifier:20
|
hurryCostModifier:20
|
||||||
|
obsoleteTech:"Machinery",
|
||||||
|
upgradesTo:"Crossbowman"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Chariot Archer",
|
name:"Chariot Archer",
|
||||||
@ -62,6 +67,8 @@
|
|||||||
strength:11,
|
strength:11,
|
||||||
cost: 56,
|
cost: 56,
|
||||||
requiredTech:"Bronze Working",
|
requiredTech:"Bronze Working",
|
||||||
|
obsoleteTech:"Civil Service",
|
||||||
|
upgradesTo: "Pikeman",
|
||||||
uniques:["Bonus vs Mounted 50%"],
|
uniques:["Bonus vs Mounted 50%"],
|
||||||
hurryCostModifier:20
|
hurryCostModifier:20
|
||||||
},
|
},
|
||||||
@ -76,6 +83,8 @@
|
|||||||
rangedStrength:8,
|
rangedStrength:8,
|
||||||
cost: 75,
|
cost: 75,
|
||||||
requiredTech:"Mathematics",
|
requiredTech:"Mathematics",
|
||||||
|
obsoleteTech:"Physics",
|
||||||
|
upgradesTo: "Trebuchet",
|
||||||
uniques:["Bonus vs City 200%","No defensive terrain bonus","Must set up to ranged attack"],
|
uniques:["Bonus vs City 200%","No defensive terrain bonus","Must set up to ranged attack"],
|
||||||
hurryCostModifier:20
|
hurryCostModifier:20
|
||||||
},
|
},
|
||||||
|
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.game"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 60
|
versionCode 61
|
||||||
versionName "2.2.1"
|
versionName "2.2.2"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -3,6 +3,7 @@ package com.unciv.logic.civilization
|
|||||||
|
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.models.gamebasics.Technology
|
import com.unciv.models.gamebasics.Technology
|
||||||
|
import com.unciv.models.gamebasics.Unit
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class TechManager {
|
class TechManager {
|
||||||
@ -49,6 +50,7 @@ class TechManager {
|
|||||||
techsInProgress[currentTechnology] = researchOfTech(currentTechnology) + scienceForNewTurn
|
techsInProgress[currentTechnology] = researchOfTech(currentTechnology) + scienceForNewTurn
|
||||||
if (techsInProgress[currentTechnology]!! < getCurrentTechnology().cost)
|
if (techsInProgress[currentTechnology]!! < getCurrentTechnology().cost)
|
||||||
return
|
return
|
||||||
|
|
||||||
// We finished it!
|
// We finished it!
|
||||||
techsInProgress.remove(currentTechnology)
|
techsInProgress.remove(currentTechnology)
|
||||||
techsToResearch.remove(currentTechnology)
|
techsToResearch.remove(currentTechnology)
|
||||||
@ -57,18 +59,26 @@ class TechManager {
|
|||||||
|
|
||||||
val revealedResource = GameBasics.TileResources.values.firstOrNull { currentTechnology == it.revealedBy }
|
val revealedResource = GameBasics.TileResources.values.firstOrNull { currentTechnology == it.revealedBy }
|
||||||
|
|
||||||
if (revealedResource == null) return
|
if (revealedResource != null) {
|
||||||
for (tileInfo in civInfo.gameInfo.tileMap.values
|
for (tileInfo in civInfo.gameInfo.tileMap.values
|
||||||
.filter { it.resource == revealedResource.name && civInfo == it.getOwner() }) {
|
.filter { it.resource == revealedResource.name && civInfo == it.getOwner() }) {
|
||||||
|
|
||||||
val closestCityTile = tileInfo.getTilesInDistance(4)
|
val closestCityTile = tileInfo.getTilesInDistance(4)
|
||||||
.firstOrNull { it.isCityCenter() }
|
.firstOrNull { it.isCityCenter() }
|
||||||
if (closestCityTile != null) {
|
if (closestCityTile != null) {
|
||||||
civInfo.addNotification(
|
civInfo.addNotification(
|
||||||
revealedResource.name + " revealed near " + closestCityTile.getCity()!!.name, tileInfo.position)
|
revealedResource.name + " revealed near " + closestCityTile.getCity()!!.name, tileInfo.position)
|
||||||
break
|
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!!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,23 @@ import com.unciv.logic.map.UnitType
|
|||||||
import com.unciv.models.stats.INamed
|
import com.unciv.models.stats.INamed
|
||||||
|
|
||||||
class Unit : INamed, IConstruction, ICivilopedia {
|
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<String>?=null
|
||||||
|
var obsoleteTech:String?=null
|
||||||
|
var upgradesTo:String? = null
|
||||||
|
|
||||||
|
|
||||||
override val description: String
|
override val description: String
|
||||||
get(){
|
get(){
|
||||||
return getDescription(false)
|
return getDescription(false)
|
||||||
@ -44,20 +61,6 @@ class Unit : INamed, IConstruction, ICivilopedia {
|
|||||||
return sb.toString()
|
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<String>?=null
|
|
||||||
var upgradesTo:String? = null
|
|
||||||
|
|
||||||
fun getMapUnit(): MapUnit {
|
fun getMapUnit(): MapUnit {
|
||||||
val unit = MapUnit()
|
val unit = MapUnit()
|
||||||
unit.name = name
|
unit.name = name
|
||||||
@ -76,6 +79,7 @@ class Unit : INamed, IConstruction, ICivilopedia {
|
|||||||
val civInfo = construction.cityInfo.civInfo
|
val civInfo = construction.cityInfo.civInfo
|
||||||
if (unbuildable) return false
|
if (unbuildable) return false
|
||||||
if (requiredTech!=null && !civInfo.tech.isResearched(requiredTech!!)) 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
|
if (requiredResource!=null && !civInfo.getCivResources().keys.any { it.name == requiredResource }) return false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,9 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
GameSaver.saveGame(game.gameInfo, "Autosave")
|
GameSaver.saveGame(game.gameInfo, "Autosave")
|
||||||
update()
|
update()
|
||||||
displayTutorials("NextTurn")
|
displayTutorials("NextTurn")
|
||||||
|
|
||||||
|
if(gameInfo.turns>=100)
|
||||||
|
displayTutorials("ContactMe")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nextTurnButton
|
return nextTurnButton
|
||||||
|
Loading…
Reference in New Issue
Block a user