Before

1package com.unciv.logic.city
2
3import com.badlogic.gdx.math.Vector2
4import com.unciv.logic.city.managers.CityConquestFunctions
5import com.unciv.logic.civilization.Civilization
6import com.unciv.models.ruleset.unique.UniqueType
7import com.unciv.models.translations.fillPlaceholders
8import com.unciv.testing.GdxTestRunner
9import com.unciv.testing.TestGame
10import org.junit.Assert.assertEquals
11import org.junit.Assert.assertFalse
12import org.junit.Assert.assertTrue
…lines 13–29 unchanged (17 lines)
30 @Before
31 fun setUp() {
32 testGame.makeHexagonalMap(3)
33 attackerCiv = testGame.addCiv()
34 defenderCiv = testGame.addCiv()
35
36 defenderCity = testGame.addCity(defenderCiv, testGame.getTile(Vector2.Zero), initialPopulation = 10)
37 cityConquestFunctions = CityConquestFunctions(defenderCity)
38
39 // otherwise test crashes when puppetying city
40 testGame.gameInfo.currentPlayerCiv = testGame.addCiv()
41 testGame.gameInfo.currentPlayer = testGame.gameInfo.currentPlayerCiv.civName
42 }
…lines 43–80 unchanged (38 lines)
81
82 @Test
83 fun `should plunder more gold the more people live in the captured city`() {
84 // No repeat like `should plunder gold upon capture` - mor work and one range check might be enough
85
86 // given
87 val largeCity = testGame.addCity(defenderCiv, testGame.getTile(Vector2.X), initialPopulation = 20)
88 val smallCity = testGame.addCity(defenderCiv, testGame.getTile(Vector2.Y), initialPopulation = 5)
89 val secondAttackerCiv = testGame.addCiv()
90 testGame.gameInfo.turns = 50
91
92 // when
93 CityConquestFunctions(largeCity).puppetCity(attackerCiv)
94 CityConquestFunctions(smallCity).puppetCity(secondAttackerCiv)
…lines 95–100 unchanged (6 lines)
101 }
102
103 @Test
104 fun `should plunder more gold with building uniques upon capture`() {
105 // given
106 val building = testGame.createBuilding(UniqueType.GoldFromCapturingCity.text.fillPlaceholders("+100"))
107 val city = testGame.addCity(defenderCiv, testGame.getTile(Vector2.X), initialPopulation = 10)
108 city.cityConstructions.addBuilding(building.name)
109
110 val secondAttackerCiv = testGame.addCiv()
111 testGame.gameInfo.turns = 50
112
113 // when
…lines 114–156 unchanged (43 lines)
157 wonders.forEach { assertFalse(defenderCity.cityConstructions.builtBuildings.contains(it)) }
158 }
159
160 @Test
161 fun `should kill population upon capture`() {
162 // given
163 val largeCity = testGame.addCity(defenderCiv, testGame.getTile(Vector2.X), initialPopulation = 20)
164 val smallCity = testGame.addCity(defenderCiv, testGame.getTile(Vector2.Y), initialPopulation = 5)
165
166 // when
167 cityConquestFunctions.puppetCity(attackerCiv)
168 CityConquestFunctions(largeCity).puppetCity(attackerCiv)
169 CityConquestFunctions(smallCity).puppetCity(attackerCiv)
170
171 // then
172 assertEquals(7, defenderCity.population.population)
173 assertEquals(14, largeCity.population.population)
174 assertEquals(3, smallCity.population.population)
175 }
176
177 @Test
178 fun `should never reduce population below 1 upon capture`() {
179 // given
180 val onePopCity = testGame.addCity(defenderCiv, testGame.getTile(Vector2.X), initialPopulation = 1)
181
182 // when
183 CityConquestFunctions(onePopCity).puppetCity(attackerCiv)
184
185 // then
186 assertEquals(1, onePopCity.population.population)
…lines 187–194 unchanged (8 lines)
195 assertTrue(defenderCity.isInResistance())
196 }
197
198 @Test
199 fun `should relocate capital to largest upon city moving`() {
200 // given
201 val smallerCity = testGame.addCity(defenderCiv, testGame.getTile(Vector2.X), initialPopulation = 5)
202 val largerCity = testGame.addCity(defenderCiv, testGame.getTile(Vector2.Y), initialPopulation = 8)
203
204 // when
205 cityConquestFunctions.moveToCiv(attackerCiv)
206
207 // then
208 assertTrue(largerCity.isCapital())
209 assertFalse(smallerCity.isCapital())
210 }
211
212 @Test
213 fun `should remove free buildings upon city moving`() {
214 // given
215 val freeBuildingCiv = testGame.addCiv(gainFreeBuildingTestingUniqueText)
216 val city = testGame.addCity(freeBuildingCiv, testGame.getTile(Vector2.Y), initialPopulation = 10)
217
218 // when
219 CityConquestFunctions(city).moveToCiv(attackerCiv)
220
221 // then
222 assertFalse(city.cityConstructions.containsBuildingOrEquivalent("Monument"))
…lines 223–249 unchanged (27 lines)

After

1package com.unciv.logic.city
2
3import com.badlogic.gdx.math.Vector2
4import com.unciv.logic.city.managers.CityConquestFunctions
5import com.unciv.logic.civilization.Civilization
6import com.unciv.logic.map.HexCoord
7import com.unciv.models.ruleset.unique.UniqueType
8import com.unciv.models.translations.fillPlaceholders
9import com.unciv.testing.GdxTestRunner
10import com.unciv.testing.TestGame
11import org.junit.Assert.assertEquals
12import org.junit.Assert.assertFalse
…lines 13–30 unchanged (18 lines)
31 @Before
32 fun setUp() {
33 testGame.makeHexagonalMap(3)
34 attackerCiv = testGame.addCiv()
35 defenderCiv = testGame.addCiv()
36
37 defenderCity = testGame.addCity(defenderCiv, testGame.getTile(HexCoord.Zero), initialPopulation = 10)
38 cityConquestFunctions = CityConquestFunctions(defenderCity)
39
40 // otherwise test crashes when puppetying city
41 testGame.gameInfo.currentPlayerCiv = testGame.addCiv()
42 testGame.gameInfo.currentPlayer = testGame.gameInfo.currentPlayerCiv.civName
43 }
…lines 44–81 unchanged (38 lines)
82
83 @Test
84 fun `should plunder more gold the more people live in the captured city`() {
85 // No repeat like `should plunder gold upon capture` - mor work and one range check might be enough
86
87 // given
88 val largeCity = testGame.addCity(defenderCiv, testGame.getTile(1,0), initialPopulation = 20)
89 val smallCity = testGame.addCity(defenderCiv, testGame.getTile(0,1), initialPopulation = 5)
90 val secondAttackerCiv = testGame.addCiv()
91 testGame.gameInfo.turns = 50
92
93 // when
94 CityConquestFunctions(largeCity).puppetCity(attackerCiv)
95 CityConquestFunctions(smallCity).puppetCity(secondAttackerCiv)
…lines 96–101 unchanged (6 lines)
102 }
103
104 @Test
105 fun `should plunder more gold with building uniques upon capture`() {
106 // given
107 val building = testGame.createBuilding(UniqueType.GoldFromCapturingCity.text.fillPlaceholders("+100"))
108 val city = testGame.addCity(defenderCiv, testGame.getTile(1,0), initialPopulation = 10)
109 city.cityConstructions.addBuilding(building.name)
110
111 val secondAttackerCiv = testGame.addCiv()
112 testGame.gameInfo.turns = 50
113
114 // when
…lines 115–157 unchanged (43 lines)
158 wonders.forEach { assertFalse(defenderCity.cityConstructions.builtBuildings.contains(it)) }
159 }
160
161 @Test
162 fun `should kill population upon capture`() {
163 // given
164 val largeCity = testGame.addCity(defenderCiv, testGame.getTile(1,0), initialPopulation = 20)
165 val smallCity = testGame.addCity(defenderCiv, testGame.getTile(0,1), initialPopulation = 5)
166
167 // when
168 cityConquestFunctions.puppetCity(attackerCiv)
169 CityConquestFunctions(largeCity).puppetCity(attackerCiv)
170 CityConquestFunctions(smallCity).puppetCity(attackerCiv)
171
172 // then
173 assertEquals(7, defenderCity.population.population)
174 assertEquals(14, largeCity.population.population)
175 assertEquals(3, smallCity.population.population)
176 }
177
178 @Test
179 fun `should never reduce population below 1 upon capture`() {
180 // given
181 val onePopCity = testGame.addCity(defenderCiv, testGame.getTile(1,0), initialPopulation = 1)
182
183 // when
184 CityConquestFunctions(onePopCity).puppetCity(attackerCiv)
185
186 // then
187 assertEquals(1, onePopCity.population.population)
…lines 188–195 unchanged (8 lines)
196 assertTrue(defenderCity.isInResistance())
197 }
198
199 @Test
200 fun `should relocate capital to largest upon city moving`() {
201 // given
202 val smallerCity = testGame.addCity(defenderCiv, testGame.getTile(1,0), initialPopulation = 5)
203 val largerCity = testGame.addCity(defenderCiv, testGame.getTile(0,1), initialPopulation = 8)
204
205 // when
206 cityConquestFunctions.moveToCiv(attackerCiv)
207
208 // then
209 assertTrue(largerCity.isCapital())
210 assertFalse(smallerCity.isCapital())
211 }
212
213 @Test
214 fun `should remove free buildings upon city moving`() {
215 // given
216 val freeBuildingCiv = testGame.addCiv(gainFreeBuildingTestingUniqueText)
217 val city = testGame.addCity(freeBuildingCiv, testGame.getTile(0,1), initialPopulation = 10)
218
219 // when
220 CityConquestFunctions(city).moveToCiv(attackerCiv)
221
222 // then
223 assertFalse(city.cityConstructions.containsBuildingOrEquivalent("Monument"))
…lines 224–250 unchanged (27 lines)

Before

source_file
package_header
package "package"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "logic"
. "."
identifier "city"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "badlogic"
. "."
identifier "gdx"
. "."
identifier "math"
. "."
identifier "Vector2"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "logic"
. "."
identifier "city"
. "."
identifier "managers"
. "."
identifier "CityConquestFunctions"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "logic"
. "."
identifier "civilization"
. "."
identifier "Civilization"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "models"
. "."
identifier "ruleset"
. "."
identifier "unique"
. "."
identifier "UniqueType"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "models"
. "."
identifier "translations"
. "."
identifier "fillPlaceholders"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "testing"
. "."
identifier "GdxTestRunner"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "testing"
. "."
identifier "TestGame"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Assert"
. "."
identifier "assertEquals"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Assert"
. "."
identifier "assertFalse"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Assert"
. "."
identifier "assertTrue"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Before"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Test"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "runner"
. "."
identifier "RunWith"
class_declaration
modifiers
annotation
@ "@"
constructor_invocation
user_type
identifier "RunWith"
value_arguments
( "("
value_argument
navigation_expression
identifier "GdxTestRunner"
:: "::"
identifier "class"
) ")"
class "class"
identifier "CityConquestFunctionsTest"
class_body
{ "{"
property_declaration
modifiers
visibility_modifier
private "private"
member_modifier
lateinit "lateinit"
var "var"
variable_declaration
identifier "attackerCiv"
: ":"
user_type
identifier "Civilization"
property_declaration
modifiers
visibility_modifier
private "private"
member_modifier
lateinit "lateinit"
var "var"
variable_declaration
identifier "defenderCiv"
: ":"
user_type
identifier "Civilization"
property_declaration
modifiers
visibility_modifier
private "private"
member_modifier
lateinit "lateinit"
var "var"
variable_declaration
identifier "defenderCity"
: ":"
user_type
identifier "City"
property_declaration
modifiers
visibility_modifier
private "private"
member_modifier
lateinit "lateinit"
var "var"
variable_declaration
identifier "cityConquestFunctions"
: ":"
user_type
identifier "CityConquestFunctions"
property_declaration
modifiers
visibility_modifier
private "private"
val "val"
variable_declaration
identifier "testGame"
= "="
call_expression
identifier "TestGame"
value_arguments
( "("
) ")"
property_declaration (+33 nodes collapsed)
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Before"
fun "fun"
identifier "setUp"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "makeHexagonalMap"
value_arguments
( "("
value_argument
number_literal "3"
) ")"
assignment
identifier "attackerCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
assignment
identifier "defenderCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
assignment
identifier "defenderCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "Zero"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "10"
) ")"
assignment
identifier "cityConquestFunctions"
= "="
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "defenderCity"
) ")"
line_comment "// otherwise test crashes when puppetying city"
assignment
navigation_expression
navigation_expression
identifier "testGame"
. "."
identifier "gameInfo"
. "."
identifier "currentPlayerCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
assignment
navigation_expression
navigation_expression
identifier "testGame"
. "."
identifier "gameInfo"
. "."
identifier "currentPlayer"
= "="
navigation_expression
navigation_expression
navigation_expression
identifier "testGame"
. "."
identifier "gameInfo"
. "."
identifier "currentPlayerCiv"
. "."
identifier "civName"
} "}"
line_comment "// Note: diplomacy repercussions for capturing/liberating ci"...
function_declaration (+56 nodes collapsed)
function_declaration (+143 nodes collapsed)
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should plunder more gold the more people live in the captur"...
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// No repeat like `should plunder gold upon capture` - mor w"...
line_comment "// given"
property_declaration
val "val"
variable_declaration
identifier "largeCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "X"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "20"
) ")"
property_declaration
val "val"
variable_declaration
identifier "smallCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "Y"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "5"
) ")"
property_declaration
val "val"
variable_declaration
identifier "secondAttackerCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
assignment
navigation_expression
navigation_expression
identifier "testGame"
. "."
identifier "gameInfo"
. "."
identifier "turns"
= "="
number_literal "50"
line_comment "// when"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "largeCity"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "smallCity"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "secondAttackerCiv"
) ")"
line_comment "// then"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
binary_expression
navigation_expression
identifier "attackerCiv"
. "."
identifier "gold"
> ">"
navigation_expression
identifier "secondAttackerCiv"
. "."
identifier "gold"
) ")"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
in_expression
navigation_expression
identifier "attackerCiv"
. "."
identifier "gold"
in "in"
infix_expression
number_literal "220"
identifier "until"
number_literal "260"
) ")"
line_comment "// population 20"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
in_expression
navigation_expression
identifier "secondAttackerCiv"
. "."
identifier "gold"
in "in"
infix_expression
number_literal "70"
identifier "until"
number_literal "110"
) ")"
line_comment "// population 5"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should plunder more gold with building uniques upon capture"...
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// given"
property_declaration (+33 nodes collapsed)
property_declaration
val "val"
variable_declaration
identifier "city"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "X"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "10"
) ")"
call_expression
navigation_expression
navigation_expression
identifier "city"
. "."
identifier "cityConstructions"
. "."
identifier "addBuilding"
value_arguments
( "("
value_argument
navigation_expression
identifier "building"
. "."
identifier "name"
) ")"
property_declaration
val "val"
variable_declaration
identifier "secondAttackerCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
assignment
navigation_expression
navigation_expression
identifier "testGame"
. "."
identifier "gameInfo"
. "."
identifier "turns"
= "="
number_literal "50"
line_comment "// when"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "city"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "secondAttackerCiv"
) ")"
call_expression
navigation_expression
identifier "cityConquestFunctions"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
line_comment "// then"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
binary_expression
navigation_expression
identifier "attackerCiv"
. "."
identifier "gold"
< "<"
navigation_expression
identifier "secondAttackerCiv"
. "."
identifier "gold"
) ")"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
in_expression
navigation_expression
identifier "attackerCiv"
. "."
identifier "gold"
in "in"
infix_expression
number_literal "120"
identifier "until"
number_literal "160"
) ")"
line_comment "// Range for city size 10 and all modifiers 1"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
in_expression
navigation_expression
identifier "secondAttackerCiv"
. "."
identifier "gold"
in "in"
infix_expression
number_literal "240"
identifier "until"
number_literal "320"
) ")"
line_comment "// Doubled by Unique"
} "}"
function_declaration (+151 nodes collapsed)
function_declaration (+137 nodes collapsed)
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should kill population upon capture`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// given"
property_declaration
val "val"
variable_declaration
identifier "largeCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "X"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "20"
) ")"
property_declaration
val "val"
variable_declaration
identifier "smallCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "Y"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "5"
) ")"
line_comment "// when"
call_expression
navigation_expression
identifier "cityConquestFunctions"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "largeCity"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "smallCity"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
line_comment "// then"
call_expression
identifier "assertEquals"
value_arguments
( "("
value_argument
number_literal "7"
, ","
value_argument
navigation_expression
navigation_expression
identifier "defenderCity"
. "."
identifier "population"
. "."
identifier "population"
) ")"
call_expression
identifier "assertEquals"
value_arguments
( "("
value_argument
number_literal "14"
, ","
value_argument
navigation_expression
navigation_expression
identifier "largeCity"
. "."
identifier "population"
. "."
identifier "population"
) ")"
call_expression
identifier "assertEquals"
value_arguments
( "("
value_argument
number_literal "3"
, ","
value_argument
navigation_expression
navigation_expression
identifier "smallCity"
. "."
identifier "population"
. "."
identifier "population"
) ")"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should never reduce population below 1 upon capture`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// given"
property_declaration
val "val"
variable_declaration
identifier "onePopCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "X"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "1"
) ")"
line_comment "// when"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "onePopCity"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
line_comment "// then"
call_expression
identifier "assertEquals"
value_arguments
( "("
value_argument
number_literal "1"
, ","
value_argument
navigation_expression
navigation_expression
identifier "onePopCity"
. "."
identifier "population"
. "."
identifier "population"
) ")"
} "}"
function_declaration (+41 nodes collapsed)
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should relocate capital to largest upon city moving`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// given"
property_declaration
val "val"
variable_declaration
identifier "smallerCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "X"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "5"
) ")"
property_declaration
val "val"
variable_declaration
identifier "largerCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "Y"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "8"
) ")"
line_comment "// when"
call_expression
navigation_expression
identifier "cityConquestFunctions"
. "."
identifier "moveToCiv"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
line_comment "// then"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
call_expression
navigation_expression
identifier "largerCity"
. "."
identifier "isCapital"
value_arguments
( "("
) ")"
) ")"
call_expression
identifier "assertFalse"
value_arguments
( "("
value_argument
call_expression
navigation_expression
identifier "smallerCity"
. "."
identifier "isCapital"
value_arguments
( "("
) ")"
) ")"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should remove free buildings upon city moving`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// given"
property_declaration
val "val"
variable_declaration
identifier "freeBuildingCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
value_argument
identifier "gainFreeBuildingTestingUniqueText"
) ")"
property_declaration
val "val"
variable_declaration
identifier "city"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "freeBuildingCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "Y"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "10"
) ")"
line_comment "// when"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "city"
) ")"
. "."
identifier "moveToCiv"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
line_comment "// then"
call_expression (+22 nodes collapsed)
} "}"
function_declaration (+65 nodes collapsed)
function_declaration (+46 nodes collapsed)
} "}"

After

source_file
package_header
package "package"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "logic"
. "."
identifier "city"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "badlogic"
. "."
identifier "gdx"
. "."
identifier "math"
. "."
identifier "Vector2"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "logic"
. "."
identifier "city"
. "."
identifier "managers"
. "."
identifier "CityConquestFunctions"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "logic"
. "."
identifier "civilization"
. "."
identifier "Civilization"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "logic"
. "."
identifier "map"
. "."
identifier "HexCoord"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "models"
. "."
identifier "ruleset"
. "."
identifier "unique"
. "."
identifier "UniqueType"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "models"
. "."
identifier "translations"
. "."
identifier "fillPlaceholders"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "testing"
. "."
identifier "GdxTestRunner"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "testing"
. "."
identifier "TestGame"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Assert"
. "."
identifier "assertEquals"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Assert"
. "."
identifier "assertFalse"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Assert"
. "."
identifier "assertTrue"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Before"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Test"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "runner"
. "."
identifier "RunWith"
class_declaration
modifiers
annotation
@ "@"
constructor_invocation
user_type
identifier "RunWith"
value_arguments
( "("
value_argument
navigation_expression
identifier "GdxTestRunner"
:: "::"
identifier "class"
) ")"
class "class"
identifier "CityConquestFunctionsTest"
class_body
{ "{"
property_declaration
modifiers
visibility_modifier
private "private"
member_modifier
lateinit "lateinit"
var "var"
variable_declaration
identifier "attackerCiv"
: ":"
user_type
identifier "Civilization"
property_declaration
modifiers
visibility_modifier
private "private"
member_modifier
lateinit "lateinit"
var "var"
variable_declaration
identifier "defenderCiv"
: ":"
user_type
identifier "Civilization"
property_declaration
modifiers
visibility_modifier
private "private"
member_modifier
lateinit "lateinit"
var "var"
variable_declaration
identifier "defenderCity"
: ":"
user_type
identifier "City"
property_declaration
modifiers
visibility_modifier
private "private"
member_modifier
lateinit "lateinit"
var "var"
variable_declaration
identifier "cityConquestFunctions"
: ":"
user_type
identifier "CityConquestFunctions"
property_declaration
modifiers
visibility_modifier
private "private"
val "val"
variable_declaration
identifier "testGame"
= "="
call_expression
identifier "TestGame"
value_arguments
( "("
) ")"
property_declaration (+33 nodes collapsed)
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Before"
fun "fun"
identifier "setUp"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "makeHexagonalMap"
value_arguments
( "("
value_argument
number_literal "3"
) ")"
assignment
identifier "attackerCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
assignment
identifier "defenderCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
assignment
identifier "defenderCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "HexCoord"
. "."
identifier "Zero"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "10"
) ")"
assignment
identifier "cityConquestFunctions"
= "="
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "defenderCity"
) ")"
line_comment "// otherwise test crashes when puppetying city"
assignment
navigation_expression
navigation_expression
identifier "testGame"
. "."
identifier "gameInfo"
. "."
identifier "currentPlayerCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
assignment
navigation_expression
navigation_expression
identifier "testGame"
. "."
identifier "gameInfo"
. "."
identifier "currentPlayer"
= "="
navigation_expression
navigation_expression
navigation_expression
identifier "testGame"
. "."
identifier "gameInfo"
. "."
identifier "currentPlayerCiv"
. "."
identifier "civName"
} "}"
line_comment "// Note: diplomacy repercussions for capturing/liberating ci"...
function_declaration (+56 nodes collapsed)
function_declaration (+143 nodes collapsed)
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should plunder more gold the more people live in the captur"...
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// No repeat like `should plunder gold upon capture` - mor w"...
line_comment "// given"
property_declaration
val "val"
variable_declaration
identifier "largeCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
number_literal "1"
, ","
value_argument
number_literal "0"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "20"
) ")"
property_declaration
val "val"
variable_declaration
identifier "smallCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
number_literal "0"
, ","
value_argument
number_literal "1"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "5"
) ")"
property_declaration
val "val"
variable_declaration
identifier "secondAttackerCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
assignment
navigation_expression
navigation_expression
identifier "testGame"
. "."
identifier "gameInfo"
. "."
identifier "turns"
= "="
number_literal "50"
line_comment "// when"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "largeCity"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "smallCity"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "secondAttackerCiv"
) ")"
line_comment "// then"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
binary_expression
navigation_expression
identifier "attackerCiv"
. "."
identifier "gold"
> ">"
navigation_expression
identifier "secondAttackerCiv"
. "."
identifier "gold"
) ")"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
in_expression
navigation_expression
identifier "attackerCiv"
. "."
identifier "gold"
in "in"
infix_expression
number_literal "220"
identifier "until"
number_literal "260"
) ")"
line_comment "// population 20"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
in_expression
navigation_expression
identifier "secondAttackerCiv"
. "."
identifier "gold"
in "in"
infix_expression
number_literal "70"
identifier "until"
number_literal "110"
) ")"
line_comment "// population 5"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should plunder more gold with building uniques upon capture"...
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// given"
property_declaration (+33 nodes collapsed)
property_declaration
val "val"
variable_declaration
identifier "city"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
number_literal "1"
, ","
value_argument
number_literal "0"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "10"
) ")"
call_expression
navigation_expression
navigation_expression
identifier "city"
. "."
identifier "cityConstructions"
. "."
identifier "addBuilding"
value_arguments
( "("
value_argument
navigation_expression
identifier "building"
. "."
identifier "name"
) ")"
property_declaration
val "val"
variable_declaration
identifier "secondAttackerCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
assignment
navigation_expression
navigation_expression
identifier "testGame"
. "."
identifier "gameInfo"
. "."
identifier "turns"
= "="
number_literal "50"
line_comment "// when"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "city"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "secondAttackerCiv"
) ")"
call_expression
navigation_expression
identifier "cityConquestFunctions"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
line_comment "// then"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
binary_expression
navigation_expression
identifier "attackerCiv"
. "."
identifier "gold"
< "<"
navigation_expression
identifier "secondAttackerCiv"
. "."
identifier "gold"
) ")"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
in_expression
navigation_expression
identifier "attackerCiv"
. "."
identifier "gold"
in "in"
infix_expression
number_literal "120"
identifier "until"
number_literal "160"
) ")"
line_comment "// Range for city size 10 and all modifiers 1"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
in_expression
navigation_expression
identifier "secondAttackerCiv"
. "."
identifier "gold"
in "in"
infix_expression
number_literal "240"
identifier "until"
number_literal "320"
) ")"
line_comment "// Doubled by Unique"
} "}"
function_declaration (+151 nodes collapsed)
function_declaration (+137 nodes collapsed)
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should kill population upon capture`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// given"
property_declaration
val "val"
variable_declaration
identifier "largeCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
number_literal "1"
, ","
value_argument
number_literal "0"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "20"
) ")"
property_declaration
val "val"
variable_declaration
identifier "smallCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
number_literal "0"
, ","
value_argument
number_literal "1"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "5"
) ")"
line_comment "// when"
call_expression
navigation_expression
identifier "cityConquestFunctions"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "largeCity"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "smallCity"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
line_comment "// then"
call_expression
identifier "assertEquals"
value_arguments
( "("
value_argument
number_literal "7"
, ","
value_argument
navigation_expression
navigation_expression
identifier "defenderCity"
. "."
identifier "population"
. "."
identifier "population"
) ")"
call_expression
identifier "assertEquals"
value_arguments
( "("
value_argument
number_literal "14"
, ","
value_argument
navigation_expression
navigation_expression
identifier "largeCity"
. "."
identifier "population"
. "."
identifier "population"
) ")"
call_expression
identifier "assertEquals"
value_arguments
( "("
value_argument
number_literal "3"
, ","
value_argument
navigation_expression
navigation_expression
identifier "smallCity"
. "."
identifier "population"
. "."
identifier "population"
) ")"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should never reduce population below 1 upon capture`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// given"
property_declaration
val "val"
variable_declaration
identifier "onePopCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
number_literal "1"
, ","
value_argument
number_literal "0"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "1"
) ")"
line_comment "// when"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "onePopCity"
) ")"
. "."
identifier "puppetCity"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
line_comment "// then"
call_expression
identifier "assertEquals"
value_arguments
( "("
value_argument
number_literal "1"
, ","
value_argument
navigation_expression
navigation_expression
identifier "onePopCity"
. "."
identifier "population"
. "."
identifier "population"
) ")"
} "}"
function_declaration (+41 nodes collapsed)
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should relocate capital to largest upon city moving`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// given"
property_declaration
val "val"
variable_declaration
identifier "smallerCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
number_literal "1"
, ","
value_argument
number_literal "0"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "5"
) ")"
property_declaration
val "val"
variable_declaration
identifier "largerCity"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "defenderCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
number_literal "0"
, ","
value_argument
number_literal "1"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "8"
) ")"
line_comment "// when"
call_expression
navigation_expression
identifier "cityConquestFunctions"
. "."
identifier "moveToCiv"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
line_comment "// then"
call_expression
identifier "assertTrue"
value_arguments
( "("
value_argument
call_expression
navigation_expression
identifier "largerCity"
. "."
identifier "isCapital"
value_arguments
( "("
) ")"
) ")"
call_expression
identifier "assertFalse"
value_arguments
( "("
value_argument
call_expression
navigation_expression
identifier "smallerCity"
. "."
identifier "isCapital"
value_arguments
( "("
) ")"
) ")"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`should remove free buildings upon city moving`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// given"
property_declaration
val "val"
variable_declaration
identifier "freeBuildingCiv"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCiv"
value_arguments
( "("
value_argument
identifier "gainFreeBuildingTestingUniqueText"
) ")"
property_declaration
val "val"
variable_declaration
identifier "city"
= "="
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "freeBuildingCiv"
, ","
value_argument
call_expression
navigation_expression
identifier "testGame"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
number_literal "0"
, ","
value_argument
number_literal "1"
) ")"
, ","
value_argument
identifier "initialPopulation"
= "="
number_literal "10"
) ")"
line_comment "// when"
call_expression
navigation_expression
call_expression
identifier "CityConquestFunctions"
value_arguments
( "("
value_argument
identifier "city"
) ")"
. "."
identifier "moveToCiv"
value_arguments
( "("
value_argument
identifier "attackerCiv"
) ")"
line_comment "// then"
call_expression (+22 nodes collapsed)
} "}"
function_declaration (+65 nodes collapsed)
function_declaration (+46 nodes collapsed)
} "}"