mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 02:09:21 +07:00
Fixed tests
This commit is contained in:
@ -92,7 +92,6 @@ open class TileInfo {
|
|||||||
for (airUnit in airUnits) toReturn.airUnits.add(airUnit.clone())
|
for (airUnit in airUnits) toReturn.airUnits.add(airUnit.clone())
|
||||||
toReturn.position = position.cpy()
|
toReturn.position = position.cpy()
|
||||||
toReturn.baseTerrain = baseTerrain
|
toReturn.baseTerrain = baseTerrain
|
||||||
// toReturn.terrainFeature = terrainFeature
|
|
||||||
convertTerrainFeatureToArray()
|
convertTerrainFeatureToArray()
|
||||||
toReturn.terrainFeatures.addAll(terrainFeatures)
|
toReturn.terrainFeatures.addAll(terrainFeatures)
|
||||||
toReturn.naturalWonder = naturalWonder
|
toReturn.naturalWonder = naturalWonder
|
||||||
|
@ -32,11 +32,18 @@ class TileImprovementConstructionTests {
|
|||||||
tile.owningCity = city
|
tile.owningCity = city
|
||||||
tile.position = Vector2(1f, 1f) // so that it's not on the same position as the city
|
tile.position = Vector2(1f, 1f) // so that it's not on the same position as the city
|
||||||
city.civInfo = civInfo
|
city.civInfo = civInfo
|
||||||
|
|
||||||
|
|
||||||
|
// Needed for convertHillToTerrainFeature to not crash
|
||||||
|
val tileMap = TileMap()
|
||||||
|
tileMap.tileMatrix.add(ArrayList<TileInfo?>().apply { add(tile) })
|
||||||
|
tile.tileMap = tileMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun allTerrainSpecificImprovementsCanBeBuilt() {
|
fun allTerrainSpecificImprovementsCanBeBuilt() {
|
||||||
|
|
||||||
for (improvement in ruleSet.tileImprovements.values) {
|
for (improvement in ruleSet.tileImprovements.values) {
|
||||||
val terrain = improvement.terrainsCanBeBuiltOn.firstOrNull() ?: continue
|
val terrain = improvement.terrainsCanBeBuiltOn.firstOrNull() ?: continue
|
||||||
tile.baseTerrain = terrain
|
tile.baseTerrain = terrain
|
||||||
|
@ -30,6 +30,7 @@ class UnitMovementAlgorithmsTests {
|
|||||||
RulesetCache.loadRulesets()
|
RulesetCache.loadRulesets()
|
||||||
ruleSet = RulesetCache.getBaseRuleset()
|
ruleSet = RulesetCache.getBaseRuleset()
|
||||||
tile.ruleset = ruleSet
|
tile.ruleset = ruleSet
|
||||||
|
tile.baseTerrain = Constants.grassland
|
||||||
civInfo.tech.techsResearched.addAll(ruleSet.technologies.keys)
|
civInfo.tech.techsResearched.addAll(ruleSet.technologies.keys)
|
||||||
civInfo.tech.embarkedUnitsCanEnterOcean = true
|
civInfo.tech.embarkedUnitsCanEnterOcean = true
|
||||||
civInfo.tech.unitsCanEmbark = true
|
civInfo.tech.unitsCanEmbark = true
|
||||||
@ -38,6 +39,13 @@ class UnitMovementAlgorithmsTests {
|
|||||||
cities = arrayListOf("The Capital")
|
cities = arrayListOf("The Capital")
|
||||||
}
|
}
|
||||||
unit.civInfo = civInfo
|
unit.civInfo = civInfo
|
||||||
|
|
||||||
|
|
||||||
|
// Needed for convertHillToTerrainFeature to not crash
|
||||||
|
val tileMap = TileMap()
|
||||||
|
tileMap.tileMatrix.add(ArrayList<TileInfo?>().apply { add(tile) })
|
||||||
|
tile.tileMap = tileMap
|
||||||
|
tile.setTransients()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -55,27 +63,32 @@ class UnitMovementAlgorithmsTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun unitCanEnterTheCity() {
|
fun unitCanEnterTheCity() {
|
||||||
|
|
||||||
val map = TileMap()
|
val map = TileMap()
|
||||||
tile.baseTerrain = Constants.hill
|
val cityTile = tile.clone() // reset, so that the isCoastalTile won't be carried over from previous tests
|
||||||
tile.tileMap = map
|
cityTile.baseTerrain = Constants.grassland
|
||||||
tile.setTransients()
|
cityTile.tileMap = map
|
||||||
|
cityTile.ruleset = ruleSet
|
||||||
|
cityTile.setTransients()
|
||||||
|
map.tileMatrix.add(arrayListOf(cityTile)) // needed for tile.setTransients()
|
||||||
|
|
||||||
val otherTile = tile.clone()
|
val otherTile = tile.clone()
|
||||||
otherTile.baseTerrain = Constants.coast
|
otherTile.baseTerrain = Constants.coast
|
||||||
otherTile.position.y = 1f
|
otherTile.position.y = 1f
|
||||||
|
map.tileMatrix[0].add(otherTile)
|
||||||
map.tileMatrix.add(arrayListOf(tile, otherTile))
|
|
||||||
|
|
||||||
val city = CityInfo()
|
val city = CityInfo()
|
||||||
city.location = tile.position
|
city.location = cityTile.position
|
||||||
city.civInfo = civInfo
|
city.civInfo = civInfo
|
||||||
tile.owningCity = city
|
cityTile.owningCity = city
|
||||||
|
|
||||||
for (type in UnitType.values())
|
for (type in UnitType.values())
|
||||||
{
|
{
|
||||||
unit.owner = civInfo.civName
|
unit.owner = civInfo.civName
|
||||||
unit.baseUnit = BaseUnit().apply { unitType = type }
|
unit.baseUnit = BaseUnit().apply { unitType = type }
|
||||||
Assert.assertTrue(type.name, unit.movement.canPassThrough(tile))
|
if(!unit.movement.canPassThrough(cityTile))
|
||||||
|
unit.movement.canPassThrough(cityTile)
|
||||||
|
Assert.assertTrue(type.name, unit.movement.canPassThrough(cityTile))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user