mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-20 12:48:56 +07:00
Difficulty is now game-wide, in preparation for multiplayer
Apparently choosing difficulty...didn't actually do anything until now, which is an embarrasing oversight and explains why people thought the game was too hard even on easy mode...
This commit is contained in:
@ -21,7 +21,7 @@ class GameStarter{
|
|||||||
|
|
||||||
|
|
||||||
val playerCiv = CivilizationInfo(newGameParameters.nation)
|
val playerCiv = CivilizationInfo(newGameParameters.nation)
|
||||||
playerCiv.difficulty=newGameParameters.difficulty
|
gameInfo.difficulty=newGameParameters.difficulty
|
||||||
playerCiv.playerType=PlayerType.Human
|
playerCiv.playerType=PlayerType.Human
|
||||||
gameInfo.civilizations.add(playerCiv) // first one is player civ
|
gameInfo.civilizations.add(playerCiv) // first one is player civ
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ class GameStarter{
|
|||||||
for (nationName in GameBasics.Nations.keys.filterNot { it=="Barbarians" || it==newGameParameters.nation }.shuffled()
|
for (nationName in GameBasics.Nations.keys.filterNot { it=="Barbarians" || it==newGameParameters.nation }.shuffled()
|
||||||
.take(newGameParameters.numberOfEnemies)) {
|
.take(newGameParameters.numberOfEnemies)) {
|
||||||
val civ = CivilizationInfo(nationName)
|
val civ = CivilizationInfo(nationName)
|
||||||
civ.tech.techsResearched.addAll(playerCiv.getDifficulty().aiFreeTechs)
|
civ.tech.techsResearched.addAll(gameInfo.getDifficulty().aiFreeTechs)
|
||||||
gameInfo.civilizations.add(civ)
|
gameInfo.civilizations.add(civ)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ class GameInfo {
|
|||||||
@Deprecated("As of 2.6.9")
|
@Deprecated("As of 2.6.9")
|
||||||
var tutorial = mutableListOf<String>()
|
var tutorial = mutableListOf<String>()
|
||||||
var civilizations = mutableListOf<CivilizationInfo>()
|
var civilizations = mutableListOf<CivilizationInfo>()
|
||||||
|
var difficulty="Chieftain" // difficulty is game-wide, think what would happen if 2 human players could play on diffferent difficulties?
|
||||||
var tileMap: TileMap = TileMap()
|
var tileMap: TileMap = TileMap()
|
||||||
var turns = 0
|
var turns = 0
|
||||||
|
|
||||||
@ -24,11 +25,13 @@ class GameInfo {
|
|||||||
toReturn.tileMap = tileMap.clone()
|
toReturn.tileMap = tileMap.clone()
|
||||||
toReturn.civilizations.addAll(civilizations.map { it.clone() })
|
toReturn.civilizations.addAll(civilizations.map { it.clone() })
|
||||||
toReturn.turns = turns
|
toReturn.turns = turns
|
||||||
|
toReturn.difficulty=difficulty
|
||||||
return toReturn
|
return toReturn
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPlayerCivilization(): CivilizationInfo = civilizations[0]
|
fun getPlayerCivilization(): CivilizationInfo = civilizations[0]
|
||||||
fun getBarbarianCivilization(): CivilizationInfo = civilizations[1]
|
fun getBarbarianCivilization(): CivilizationInfo = civilizations[1]
|
||||||
|
fun getDifficulty() = GameBasics.Difficulties[difficulty]!!
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
fun nextTurn() {
|
fun nextTurn() {
|
||||||
@ -98,6 +101,8 @@ class GameInfo {
|
|||||||
// PlayerType was only added in 2.11.1, so we need to adjust for older saved games
|
// PlayerType was only added in 2.11.1, so we need to adjust for older saved games
|
||||||
if(civilizations.all { it.playerType==PlayerType.AI })
|
if(civilizations.all { it.playerType==PlayerType.AI })
|
||||||
getPlayerCivilization().playerType=PlayerType.Human
|
getPlayerCivilization().playerType=PlayerType.Human
|
||||||
|
if(getPlayerCivilization().difficulty!="Chieftain")
|
||||||
|
difficulty= getPlayerCivilization().difficulty
|
||||||
|
|
||||||
for (civInfo in civilizations) civInfo.setTransients()
|
for (civInfo in civilizations) civInfo.setTransients()
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ class CityInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
civInfo.cities = civInfo.cities.toMutableList().apply { add(this@CityInfo) }
|
civInfo.cities = civInfo.cities.toMutableList().apply { add(this@CityInfo) }
|
||||||
if(civInfo == civInfo.gameInfo.getPlayerCivilization())
|
|
||||||
civInfo.addNotification("[$name] has been founded!", cityLocation, Color.PURPLE)
|
civInfo.addNotification("[$name] has been founded!", cityLocation, Color.PURPLE)
|
||||||
|
|
||||||
if (civInfo.policies.isAdopted("Legalism") && civInfo.cities.size <= 4) cityConstructions.addCultureBuilding()
|
if (civInfo.policies.isAdopted("Legalism") && civInfo.cities.size <= 4) cityConstructions.addCultureBuilding()
|
||||||
if (civInfo.cities.size == 1) {
|
if (civInfo.cities.size == 1) {
|
||||||
cityConstructions.addBuilding("Palace")
|
cityConstructions.addBuilding("Palace")
|
||||||
|
@ -9,6 +9,7 @@ import com.unciv.logic.map.MapUnit
|
|||||||
import com.unciv.logic.map.RoadStatus
|
import com.unciv.logic.map.RoadStatus
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.Counter
|
import com.unciv.models.Counter
|
||||||
|
import com.unciv.models.gamebasics.Difficulty
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.models.gamebasics.tech.TechEra
|
import com.unciv.models.gamebasics.tech.TechEra
|
||||||
import com.unciv.models.gamebasics.tile.ResourceType
|
import com.unciv.models.gamebasics.tile.ResourceType
|
||||||
@ -41,7 +42,7 @@ class CivilizationInfo {
|
|||||||
|
|
||||||
var gold = 0
|
var gold = 0
|
||||||
var happiness = 15
|
var happiness = 15
|
||||||
var difficulty = "Chieftain"
|
@Deprecated("As of 2.11.1") var difficulty = "Chieftain"
|
||||||
var playerType = PlayerType.AI
|
var playerType = PlayerType.AI
|
||||||
var civName = ""
|
var civName = ""
|
||||||
var tech = TechManager()
|
var tech = TechManager()
|
||||||
@ -69,7 +70,7 @@ class CivilizationInfo {
|
|||||||
val toReturn = CivilizationInfo()
|
val toReturn = CivilizationInfo()
|
||||||
toReturn.gold = gold
|
toReturn.gold = gold
|
||||||
toReturn.happiness=happiness
|
toReturn.happiness=happiness
|
||||||
toReturn.difficulty=difficulty
|
toReturn.playerType=playerType
|
||||||
toReturn.civName=civName
|
toReturn.civName=civName
|
||||||
toReturn.tech = tech.clone()
|
toReturn.tech = tech.clone()
|
||||||
toReturn.policies = policies.clone()
|
toReturn.policies = policies.clone()
|
||||||
@ -84,7 +85,11 @@ class CivilizationInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//region pure functions
|
//region pure functions
|
||||||
fun getDifficulty() = GameBasics.Difficulties[difficulty]!!
|
fun getDifficulty():Difficulty {
|
||||||
|
if(playerType==PlayerType.AI) return GameBasics.Difficulties["Chieftain"]!!
|
||||||
|
else return gameInfo.getDifficulty()
|
||||||
|
}
|
||||||
|
|
||||||
fun getNation() = GameBasics.Nations[civName]!!
|
fun getNation() = GameBasics.Nations[civName]!!
|
||||||
fun getCapital()=cities.first { it.isCapital() }
|
fun getCapital()=cities.first { it.isCapital() }
|
||||||
fun isPlayerCivilization() = gameInfo.getPlayerCivilization()==this
|
fun isPlayerCivilization() = gameInfo.getPlayerCivilization()==this
|
||||||
|
@ -157,6 +157,11 @@ class NewGameScreen: PickerScreen(){
|
|||||||
|
|
||||||
newGameOptionsTable.add("{Difficulty}:".tr())
|
newGameOptionsTable.add("{Difficulty}:".tr())
|
||||||
val difficultySelectBox = TranslatedSelectBox(GameBasics.Difficulties.keys, newGameParameters.difficulty, skin)
|
val difficultySelectBox = TranslatedSelectBox(GameBasics.Difficulties.keys, newGameParameters.difficulty, skin)
|
||||||
|
difficultySelectBox.addListener(object : ChangeListener() {
|
||||||
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
|
newGameParameters.difficulty = difficultySelectBox.selected.value
|
||||||
|
}
|
||||||
|
})
|
||||||
newGameOptionsTable.add(difficultySelectBox).pad(10f).row()
|
newGameOptionsTable.add(difficultySelectBox).pad(10f).row()
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@ class LoadScreen : PickerScreen() {
|
|||||||
textToSet+="\n{Saved at}: ".tr()+ SimpleDateFormat("dd-MM-yy HH.mm").format(savedAt)
|
textToSet+="\n{Saved at}: ".tr()+ SimpleDateFormat("dd-MM-yy HH.mm").format(savedAt)
|
||||||
try{
|
try{
|
||||||
val game = GameSaver().loadGame(it)
|
val game = GameSaver().loadGame(it)
|
||||||
textToSet+="\n"+game.getPlayerCivilization()+", {Turn} ".tr()+game.turns
|
textToSet+="\n"+game.getPlayerCivilization().civName.tr()+
|
||||||
|
", "+game.difficulty.tr()+", {Turn} ".tr()+game.turns
|
||||||
}catch (ex:Exception){
|
}catch (ex:Exception){
|
||||||
textToSet+="\n{Could not load game}!".tr()
|
textToSet+="\n{Could not load game}!".tr()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user