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:
Yair Morgenstern 2018-12-18 19:26:56 +02:00
parent b054a3ff4a
commit e3926764f2
6 changed files with 24 additions and 8 deletions

View File

@ -21,7 +21,7 @@ class GameStarter{
val playerCiv = CivilizationInfo(newGameParameters.nation)
playerCiv.difficulty=newGameParameters.difficulty
gameInfo.difficulty=newGameParameters.difficulty
playerCiv.playerType=PlayerType.Human
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()
.take(newGameParameters.numberOfEnemies)) {
val civ = CivilizationInfo(nationName)
civ.tech.techsResearched.addAll(playerCiv.getDifficulty().aiFreeTechs)
civ.tech.techsResearched.addAll(gameInfo.getDifficulty().aiFreeTechs)
gameInfo.civilizations.add(civ)
}

View File

@ -15,6 +15,7 @@ class GameInfo {
@Deprecated("As of 2.6.9")
var tutorial = mutableListOf<String>()
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 turns = 0
@ -24,11 +25,13 @@ class GameInfo {
toReturn.tileMap = tileMap.clone()
toReturn.civilizations.addAll(civilizations.map { it.clone() })
toReturn.turns = turns
toReturn.difficulty=difficulty
return toReturn
}
fun getPlayerCivilization(): CivilizationInfo = civilizations[0]
fun getBarbarianCivilization(): CivilizationInfo = civilizations[1]
fun getDifficulty() = GameBasics.Difficulties[difficulty]!!
//endregion
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
if(civilizations.all { it.playerType==PlayerType.AI })
getPlayerCivilization().playerType=PlayerType.Human
if(getPlayerCivilization().difficulty!="Chieftain")
difficulty= getPlayerCivilization().difficulty
for (civInfo in civilizations) civInfo.setTransients()

View File

@ -51,8 +51,8 @@ class 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.cities.size == 1) {
cityConstructions.addBuilding("Palace")

View File

@ -9,6 +9,7 @@ import com.unciv.logic.map.MapUnit
import com.unciv.logic.map.RoadStatus
import com.unciv.logic.map.TileInfo
import com.unciv.models.Counter
import com.unciv.models.gamebasics.Difficulty
import com.unciv.models.gamebasics.GameBasics
import com.unciv.models.gamebasics.tech.TechEra
import com.unciv.models.gamebasics.tile.ResourceType
@ -41,7 +42,7 @@ class CivilizationInfo {
var gold = 0
var happiness = 15
var difficulty = "Chieftain"
@Deprecated("As of 2.11.1") var difficulty = "Chieftain"
var playerType = PlayerType.AI
var civName = ""
var tech = TechManager()
@ -69,7 +70,7 @@ class CivilizationInfo {
val toReturn = CivilizationInfo()
toReturn.gold = gold
toReturn.happiness=happiness
toReturn.difficulty=difficulty
toReturn.playerType=playerType
toReturn.civName=civName
toReturn.tech = tech.clone()
toReturn.policies = policies.clone()
@ -84,7 +85,11 @@ class CivilizationInfo {
}
//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 getCapital()=cities.first { it.isCapital() }
fun isPlayerCivilization() = gameInfo.getPlayerCivilization()==this

View File

@ -157,6 +157,11 @@ class NewGameScreen: PickerScreen(){
newGameOptionsTable.add("{Difficulty}:".tr())
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()

View File

@ -43,7 +43,8 @@ class LoadScreen : PickerScreen() {
textToSet+="\n{Saved at}: ".tr()+ SimpleDateFormat("dd-MM-yy HH.mm").format(savedAt)
try{
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){
textToSet+="\n{Could not load game}!".tr()
}