From 4797b0622bd2be74f1364d1cfea6ae3fc915d43e Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 7 Aug 2020 18:05:04 +0300 Subject: [PATCH] Fixed tile improvement tests --- ...Tests.kt => TileImprovementConstructionTests.kt} | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) rename tests/src/com/unciv/logic/map/{TileInfoTests.kt => TileImprovementConstructionTests.kt} (85%) diff --git a/tests/src/com/unciv/logic/map/TileInfoTests.kt b/tests/src/com/unciv/logic/map/TileImprovementConstructionTests.kt similarity index 85% rename from tests/src/com/unciv/logic/map/TileInfoTests.kt rename to tests/src/com/unciv/logic/map/TileImprovementConstructionTests.kt index 04bd34a47b..f7f52c3052 100644 --- a/tests/src/com/unciv/logic/map/TileInfoTests.kt +++ b/tests/src/com/unciv/logic/map/TileImprovementConstructionTests.kt @@ -1,6 +1,8 @@ // Taken from https://github.com/TomGrill/gdx-testing package com.unciv.logic.map +import com.badlogic.gdx.math.Vector2 +import com.unciv.logic.city.CityInfo import com.unciv.logic.civilization.CivilizationInfo import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.RulesetCache @@ -11,10 +13,11 @@ import org.junit.Test import org.junit.runner.RunWith @RunWith(GdxTestRunner::class) -class TileInfoTests { +class TileImprovementConstructionTests { private var tile = TileInfo() private var civInfo = CivilizationInfo() + private var city = CityInfo() private var ruleSet = Ruleset() @Before @@ -24,6 +27,11 @@ class TileInfoTests { tile.ruleset = ruleSet civInfo.tech.researchedTechnologies.addAll(ruleSet.technologies.values) civInfo.tech.techsResearched.addAll(ruleSet.technologies.keys) + + // This is so all improvements can be built + tile.owningCity = city + tile.position = Vector2(1f, 1f) // so that it's not on the same position as the city + city.civInfo = civInfo } @@ -42,7 +50,8 @@ class TileInfoTests { @Test fun allResourceImprovementsCanBeBuilt() { for (improvement in ruleSet.tileImprovements.values) { - tile.resource = ruleSet.tileResources.values.firstOrNull { it.improvement == improvement.name}?.name + tile.resource = ruleSet.tileResources.values + .firstOrNull { it.improvement == improvement.name}?.name if (tile.resource == null) continue tile.baseTerrain = "Plains" tile.setTransients()