mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-23 01:04:24 +07:00
4.7.6-patch2
Resolved crash when moving cities between civs, added tests to ensure future changes do not break city moving functionality
This commit is contained in:
parent
afbf772d3d
commit
06377feaeb
@ -4,8 +4,8 @@ package com.unciv.build
|
||||
object BuildConfig {
|
||||
const val kotlinVersion = "1.8.21"
|
||||
const val appName = "Unciv"
|
||||
const val appCodeNumber = 887
|
||||
const val appVersion = "4.7.6-patch1"
|
||||
const val appCodeNumber = 888
|
||||
const val appVersion = "4.7.6-patch2"
|
||||
|
||||
const val gdxVersion = "1.11.0"
|
||||
const val ktorVersion = "2.2.3"
|
||||
|
@ -536,7 +536,7 @@ open class UncivGame(val isConsoleMode: Boolean = false) : Game(), PlatformSpeci
|
||||
|
||||
companion object {
|
||||
//region AUTOMATICALLY GENERATED VERSION DATA - DO NOT CHANGE THIS REGION, INCLUDING THIS COMMENT
|
||||
val VERSION = Version("4.7.6-patch1", 887)
|
||||
val VERSION = Version("4.7.6-patch2", 888)
|
||||
//endregion
|
||||
|
||||
lateinit var Current: UncivGame
|
||||
|
@ -810,7 +810,9 @@ class Civilization : IsPartOfGameInfoSerialization {
|
||||
city.cityConstructions.addBuilding(city.capitalCityIndicator())
|
||||
city.isBeingRazed = false // stop razing the new capital if it was being razed
|
||||
}
|
||||
oldCapital?.cityConstructions?.removeBuilding(oldCapital.capitalCityIndicator())
|
||||
// Don't use removeBuilding, since that rebuilds uniques and can generate errors when we have no capital
|
||||
// We're going to recalc the uniques anyway once we move it to the new civ
|
||||
oldCapital?.cityConstructions?.builtBuildings?.remove(oldCapital.capitalCityIndicator())
|
||||
}
|
||||
|
||||
fun moveCapitalToNextLargest() {
|
||||
|
@ -4,7 +4,7 @@ import java.io.File
|
||||
|
||||
class UiElementDocsWriter {
|
||||
companion object {
|
||||
private const val docPath = "../../docs/Modders/5-Creating-a-UI-skin.md"
|
||||
private const val docPath = "../../docs/Modders/Creating-a-UI-skin.md"
|
||||
private const val startMarker = "<!--- DO NOT REMOVE OR MODIFY THIS LINE UI_ELEMENT_TABLE_REGION -->"
|
||||
private const val endMarker = "<!--- DO NOT REMOVE OR MODIFY THIS LINE UI_ELEMENT_TABLE_REGION_END -->"
|
||||
private const val srcPath = "../../core/src/com/unciv/"
|
||||
|
107
tests/src/com/unciv/logic/civilization/CityMovingTests.kt
Normal file
107
tests/src/com/unciv/logic/civilization/CityMovingTests.kt
Normal file
@ -0,0 +1,107 @@
|
||||
package com.unciv.logic.civilization
|
||||
|
||||
import com.unciv.logic.map.tile.RoadStatus
|
||||
import com.unciv.testing.GdxTestRunner
|
||||
import com.unciv.uniques.TestGame
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(GdxTestRunner::class)
|
||||
class UnitMovementTests {
|
||||
|
||||
private lateinit var civInfo: Civilization
|
||||
private lateinit var enemy: Civilization
|
||||
private var testGame = TestGame()
|
||||
|
||||
@Before
|
||||
fun initTheWorld() {
|
||||
testGame.makeHexagonalMap(5) // enough space for lots of cities
|
||||
civInfo = testGame.addCiv()
|
||||
enemy = testGame.addCiv()
|
||||
|
||||
// Required for enemy to utilize roads
|
||||
enemy.tech.techsResearched.addAll(testGame.ruleset.technologies.keys)
|
||||
|
||||
civInfo.diplomacyFunctions.makeCivilizationsMeet(enemy)
|
||||
civInfo.getDiplomacyManager(enemy).declareWar()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun moveOtherCityToUs() {
|
||||
val ourCapital = testGame.addCity(civInfo, testGame.tileMap[2,2])
|
||||
val theirCapital = testGame.addCity(enemy, testGame.tileMap[-2,-2])
|
||||
val theirOtherCity = testGame.addCity(enemy, testGame.tileMap[-2, 2])
|
||||
|
||||
theirOtherCity.moveToCiv(civInfo)
|
||||
Assert.assertTrue(!theirOtherCity.isCapital())
|
||||
Assert.assertTrue(theirOtherCity.civ == civInfo)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun moveCapitalToUs() {
|
||||
val ourCapital = testGame.addCity(civInfo, testGame.tileMap[2,2])
|
||||
val theirCapital = testGame.addCity(enemy, testGame.tileMap[-2,-2])
|
||||
val theirOtherCity = testGame.addCity(enemy, testGame.tileMap[-2, 2])
|
||||
|
||||
for (i in listOf(-1,0,1)){
|
||||
val tile = testGame.tileMap[-2, i]
|
||||
tile.roadStatus = RoadStatus.Road
|
||||
}
|
||||
enemy.cache.updateCitiesConnectedToCapital()
|
||||
Assert.assertTrue(theirOtherCity.isConnectedToCapital())
|
||||
|
||||
theirCapital.moveToCiv(civInfo)
|
||||
Assert.assertTrue(theirOtherCity.isCapital())
|
||||
Assert.assertTrue(theirCapital.isCapital())
|
||||
Assert.assertTrue(theirCapital.civ == civInfo)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun moveCapitalToUsWhenWeHaveNoCities() {
|
||||
val theirCapital = testGame.addCity(enemy, testGame.tileMap[-2,-2])
|
||||
val theirOtherCity = testGame.addCity(enemy, testGame.tileMap[-2, 2])
|
||||
|
||||
for (i in listOf(-1,0,1)){
|
||||
val tile = testGame.tileMap[-2, i]
|
||||
tile.roadStatus = RoadStatus.Road
|
||||
}
|
||||
enemy.cache.updateCitiesConnectedToCapital()
|
||||
Assert.assertTrue(theirOtherCity.isConnectedToCapital())
|
||||
|
||||
theirCapital.moveToCiv(civInfo)
|
||||
Assert.assertTrue(theirOtherCity.isCapital())
|
||||
Assert.assertTrue(theirOtherCity.civ == enemy)
|
||||
Assert.assertTrue(theirCapital.isCapital())
|
||||
Assert.assertTrue(theirCapital.civ == civInfo)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun moveNonCapitalToUsWhenWeHaveNoCities() {
|
||||
val theirCapital = testGame.addCity(enemy, testGame.tileMap[-2,-2])
|
||||
val theirOtherCity = testGame.addCity(enemy, testGame.tileMap[-2, 2])
|
||||
|
||||
for (i in listOf(-1,0,1)){
|
||||
val tile = testGame.tileMap[-2, i]
|
||||
tile.roadStatus = RoadStatus.Road
|
||||
}
|
||||
enemy.cache.updateCitiesConnectedToCapital()
|
||||
Assert.assertTrue(theirOtherCity.isConnectedToCapital())
|
||||
|
||||
theirOtherCity.moveToCiv(civInfo)
|
||||
Assert.assertTrue(theirOtherCity.isCapital())
|
||||
Assert.assertTrue(theirCapital.isCapital())
|
||||
Assert.assertTrue(theirOtherCity.civ == civInfo)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun moveTheirOnlyCityToUsWhenWeHaveNoCities() {
|
||||
val theirCapital = testGame.addCity(enemy, testGame.tileMap[-2,-2])
|
||||
enemy.cache.updateCitiesConnectedToCapital()
|
||||
|
||||
theirCapital.moveToCiv(civInfo)
|
||||
Assert.assertTrue(theirCapital.isCapital())
|
||||
Assert.assertTrue(theirCapital.civ == civInfo)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user