Before

1package com.unciv.uniques
2
3import com.badlogic.gdx.math.Vector2
4import com.unciv.json.json
5import com.unciv.logic.map.mapunit.UnitTurnManager
6import com.unciv.models.UnitActionType
7import com.unciv.models.ruleset.tile.TileImprovement
8import com.unciv.models.ruleset.unique.UniqueType
9import com.unciv.models.translations.fillPlaceholders
10import com.unciv.testing.GdxTestRunner
11import com.unciv.testing.TestGame
…lines 12–28 unchanged (17 lines)
29
30 @Test
31 fun `Sweden can gift Great Persons to City States`() {
32 // when
33 game.makeHexagonalMap(1)
34 val cityState = game.addCiv(cityStateType = "Cultured")
35 val cityStateCapitalTile = game.getTile(Vector2.Zero)
36 val cityStateCapital = game.addCity(cityState, cityStateCapitalTile)
37
38 val mainCiv = game.addCiv("Gain [90] Influence with a [Great Person] gift to a City-State",
39 isPlayer = true
40 )
41
42 val unitTile = game.getTile(Vector2(1f, 0f))
43 cityStateCapital.expansion.takeOwnership(unitTile)
44
45 val greatPerson = game.addUnit("Great Scientist", mainCiv, unitTile)
46
47 // then
48 val giftAction = UnitActions.getUnitActions(greatPerson, UnitActionType.GiftUnit)
…lines 49–61 unchanged (13 lines)
62 Assert.assertFalse("Test preparation failed to add ConsumesResources to Manufactory",
63 improvement.uniqueObjects.none { it.type == UniqueType.ConsumesResources })
64 game.ruleset.tileImprovements["Manufactory"] = improvement
65
66 game.makeHexagonalMap(1)
67 val civ = game.addCiv(isPlayer = true)
68 val centerTile = game.getTile(Vector2.Zero)
69 val capital = game.addCity(civ, centerTile)
70
71 // Place an Engineer and see if he could create a Manufactory
72 val unitTile = game.getTile(Vector2(1f,0f))
73 val unit = game.addUnit("Great Engineer", civ, unitTile)
74 unit.currentMovement = unit.baseUnit.movement.toFloat() // Required!
75 val actionsWithoutIron = try {
76 UnitActionsFromUniques.getImprovementConstructionActionsFromGeneralUnique(unit, unitTile)
77 } catch (ex: Throwable) {
78 // Give that IndexOutOfBoundsException a nicer name
79 Assert.fail("getImprovementConstructionActions throws Exception ${ex.javaClass.simpleName}")
80 game.ruleset.tileImprovements["Manufactory"] = oldImprovement
81 return
82 }.filter { it.action != null }
83 Assert.assertTrue("Great Engineer should NOT be able to create a Manufactory modded to require Iron with 0 Iron",
84 actionsWithoutIron.none())
85
86 // Supply Iron
87 val ironTile = game.getTile(Vector2(0f,1f))
88 ironTile.resource = "Iron"
89 ironTile.resourceAmount = 3
90 ironTile.improvement = "Mine"
91 civ.tech.addTechnology("Mining")
92 civ.tech.addTechnology("Iron Working")
93 // capital already owns tile, but this relinquishes first - shouldn't require manual setTerrainTransients, updateCivResources called automatically
…lines 94–102 unchanged (9 lines)
103 game.ruleset.tileImprovements["Manufactory"] = oldImprovement
104 }
105
106 @Test
107 fun `Check Hakkapeliitta TransferMovement ability`() {
108 val civ = game.addCiv(isPlayer = true)
109 val centerTile = game.getTile(Vector2.Zero)
110
111 // Hardcoded names mean test *must* run under G&K ruleset, not Vanilla, which the TestGame class ensures
112 val general = game.addUnit("Great General", civ, centerTile)
113 val boostingUnit = game.addUnit("Hakkapeliitta", civ, centerTile)
114 boostingUnit.baseUnit.promotions.forEach { boostingUnit.promotions.addPromotion(it, true) }
115 boostingUnit.updateUniques()
…lines 116–124 unchanged (9 lines)
125 }
126
127 @Test
128 fun testCanGetPromotionsWithXP() {
129 val civ = game.addCiv(isPlayer = true)
130
131 val centerTile = game.getTile(Vector2.Zero)
132 val unit = game.addUnit("Scout", civ, centerTile)
133 val tree = PromotionTree(unit)
134
135 Assert.assertFalse(tree.allNodes().any { !it.unreachable && tree.canBuyUpTo(it.promotion) })
136 unit.promotions.XP += 10
137 Assert.assertTrue(tree.allNodes().any { !it.unreachable && tree.canBuyUpTo(it.promotion) })
…lines 138–142 unchanged (5 lines)
143 * @see unciv.models.ruleset.unique.UniqueType.OneTimeUnitGetsName
144 */
145 @Test
146 fun testOneTimeUnitGetsName() {
147 val unit = game.addDefaultMeleeUnitWithUniques(
148 game.addCiv(),
149 game.getTile(Vector2.Zero),
150 "[This Unit] gets a name from the [Scientist] group <upon turn start>")
151 UnitTurnManager(unit).startTurn()
152
153 Assert.assertTrue(unit.instanceName != null)
154 Assert.assertTrue(game.ruleset.unitNameGroups["Scientist"]?.unitNames?.contains(unit.instanceName) ?: false)
155 }
…lines 156–210 unchanged (55 lines)

After

1package com.unciv.uniques
2
3import com.badlogic.gdx.math.Vector2
4import com.unciv.json.json
5import com.unciv.logic.map.HexCoord
6import com.unciv.logic.map.mapunit.UnitTurnManager
7import com.unciv.models.UnitActionType
8import com.unciv.models.ruleset.tile.TileImprovement
9import com.unciv.models.ruleset.unique.UniqueType
10import com.unciv.models.translations.fillPlaceholders
11import com.unciv.testing.GdxTestRunner
…lines 12–29 unchanged (18 lines)
30
31 @Test
32 fun `Sweden can gift Great Persons to City States`() {
33 // when
34 game.makeHexagonalMap(1)
35 val cityState = game.addCiv(cityStateType = "Cultured")
36 val cityStateCapitalTile = game.getTile(HexCoord.Zero)
37 val cityStateCapital = game.addCity(cityState, cityStateCapitalTile)
38
39 val mainCiv = game.addCiv("Gain [90] Influence with a [Great Person] gift to a City-State",
40 isPlayer = true
41 )
42
43 val unitTile = game.getTile(1,0)
44 cityStateCapital.expansion.takeOwnership(unitTile)
45
46 val greatPerson = game.addUnit("Great Scientist", mainCiv, unitTile)
47
48 // then
49 val giftAction = UnitActions.getUnitActions(greatPerson, UnitActionType.GiftUnit)
…lines 50–62 unchanged (13 lines)
63 Assert.assertFalse("Test preparation failed to add ConsumesResources to Manufactory",
64 improvement.uniqueObjects.none { it.type == UniqueType.ConsumesResources })
65 game.ruleset.tileImprovements["Manufactory"] = improvement
66
67 game.makeHexagonalMap(1)
68 val civ = game.addCiv(isPlayer = true)
69 val centerTile = game.getTile(HexCoord.Zero)
70 val capital = game.addCity(civ, centerTile)
71
72 // Place an Engineer and see if he could create a Manufactory
73 val unitTile = game.getTile(HexCoord(1,0))
74 val unit = game.addUnit("Great Engineer", civ, unitTile)
75 unit.currentMovement = unit.baseUnit.movement.toFloat() // Required!
76 val actionsWithoutIron = try {
77 UnitActionsFromUniques.getImprovementConstructionActionsFromGeneralUnique(unit, unitTile)
78 } catch (ex: Throwable) {
79 // Give that IndexOutOfBoundsException a nicer name
80 Assert.fail("getImprovementConstructionActions throws Exception ${ex.javaClass.simpleName}")
81 game.ruleset.tileImprovements["Manufactory"] = oldImprovement
82 return
83 }.filter { it.action != null }
84 Assert.assertTrue("Great Engineer should NOT be able to create a Manufactory modded to require Iron with 0 Iron",
85 actionsWithoutIron.none())
86
87 // Supply Iron
88 val ironTile = game.getTile(HexCoord(0,1))
89 ironTile.resource = "Iron"
90 ironTile.resourceAmount = 3
91 ironTile.improvement = "Mine"
92 civ.tech.addTechnology("Mining")
93 civ.tech.addTechnology("Iron Working")
94 // capital already owns tile, but this relinquishes first - shouldn't require manual setTerrainTransients, updateCivResources called automatically
…lines 95–103 unchanged (9 lines)
104 game.ruleset.tileImprovements["Manufactory"] = oldImprovement
105 }
106
107 @Test
108 fun `Check Hakkapeliitta TransferMovement ability`() {
109 val civ = game.addCiv(isPlayer = true)
110 val centerTile = game.getTile(HexCoord.Zero)
111
112 // Hardcoded names mean test *must* run under G&K ruleset, not Vanilla, which the TestGame class ensures
113 val general = game.addUnit("Great General", civ, centerTile)
114 val boostingUnit = game.addUnit("Hakkapeliitta", civ, centerTile)
115 boostingUnit.baseUnit.promotions.forEach { boostingUnit.promotions.addPromotion(it, true) }
116 boostingUnit.updateUniques()
…lines 117–125 unchanged (9 lines)
126 }
127
128 @Test
129 fun testCanGetPromotionsWithXP() {
130 val civ = game.addCiv(isPlayer = true)
131
132 val centerTile = game.getTile(HexCoord.Zero)
133 val unit = game.addUnit("Scout", civ, centerTile)
134 val tree = PromotionTree(unit)
135
136 Assert.assertFalse(tree.allNodes().any { !it.unreachable && tree.canBuyUpTo(it.promotion) })
137 unit.promotions.XP += 10
138 Assert.assertTrue(tree.allNodes().any { !it.unreachable && tree.canBuyUpTo(it.promotion) })
…lines 139–143 unchanged (5 lines)
144 * @see unciv.models.ruleset.unique.UniqueType.OneTimeUnitGetsName
145 */
146 @Test
147 fun testOneTimeUnitGetsName() {
148 val unit = game.addDefaultMeleeUnitWithUniques(
149 game.addCiv(),
150 game.getTile(HexCoord.Zero),
151 "[This Unit] gets a name from the [Scientist] group <upon turn start>")
152 UnitTurnManager(unit).startTurn()
153
154 Assert.assertTrue(unit.instanceName != null)
155 Assert.assertTrue(game.ruleset.unitNameGroups["Scientist"]?.unitNames?.contains(unit.instanceName) ?: false)
156 }
…lines 157–211 unchanged (55 lines)

Before

source_file
package_header
package "package"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "uniques"
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 "json"
. "."
identifier "json"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "logic"
. "."
identifier "map"
. "."
identifier "mapunit"
. "."
identifier "UnitTurnManager"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "models"
. "."
identifier "UnitActionType"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "models"
. "."
identifier "ruleset"
. "."
identifier "tile"
. "."
identifier "TileImprovement"
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 "com"
. "."
identifier "unciv"
. "."
identifier "ui"
. "."
identifier "screens"
. "."
identifier "pickerscreens"
. "."
identifier "PromotionTree"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "ui"
. "."
identifier "screens"
. "."
identifier "worldscreen"
. "."
identifier "unit"
. "."
identifier "actions"
. "."
identifier "UnitActions"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "ui"
. "."
identifier "screens"
. "."
identifier "worldscreen"
. "."
identifier "unit"
. "."
identifier "actions"
. "."
identifier "UnitActionsFromUniques"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Assert"
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"
import
import "import"
qualified_identifier
identifier "kotlin"
. "."
identifier "math"
. "."
identifier "roundToInt"
class_declaration
modifiers
annotation
@ "@"
constructor_invocation
user_type
identifier "RunWith"
value_arguments
( "("
value_argument
navigation_expression
identifier "GdxTestRunner"
:: "::"
identifier "class"
) ")"
class "class"
identifier "UnitUniquesTests"
class_body
{ "{"
property_declaration
modifiers
visibility_modifier
private "private"
member_modifier
lateinit "lateinit"
var "var"
variable_declaration
identifier "game"
: ":"
user_type
identifier "TestGame"
function_declaration (+23 nodes collapsed)
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`Sweden can gift Great Persons to City States`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// when"
call_expression
navigation_expression
identifier "game"
. "."
identifier "makeHexagonalMap"
value_arguments
( "("
value_argument
number_literal "1"
) ")"
property_declaration
val "val"
variable_declaration
identifier "cityState"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCiv"
value_arguments
( "("
value_argument
identifier "cityStateType"
= "="
string_literal
" "\""
string_content "Cultured"
" "\""
) ")"
property_declaration
val "val"
variable_declaration
identifier "cityStateCapitalTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "Zero"
) ")"
property_declaration
val "val"
variable_declaration
identifier "cityStateCapital"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "cityState"
, ","
value_argument
identifier "cityStateCapitalTile"
) ")"
property_declaration (+23 nodes collapsed)
property_declaration
val "val"
variable_declaration
identifier "unitTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
call_expression
identifier "Vector2"
value_arguments
( "("
value_argument
float_literal "1f"
, ","
value_argument
float_literal "0f"
) ")"
) ")"
call_expression
navigation_expression
navigation_expression
identifier "cityStateCapital"
. "."
identifier "expansion"
. "."
identifier "takeOwnership"
value_arguments
( "("
value_argument
identifier "unitTile"
) ")"
property_declaration (+24 nodes collapsed)
line_comment "// then"
property_declaration (+36 nodes collapsed)
line_comment "// This tests that the action should be enabled, too"
call_expression
navigation_expression
identifier "Assert"
. "."
identifier "assertNotNull"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Great Person should have a gift action"
" "\""
, ","
value_argument
identifier "giftAction"
) ")"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "canConstructResourceRequiringImprovement"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// Do this early so the uniqueObjects lazy is still un-trigg"...
property_declaration (+30 nodes collapsed)
line_comment "// Get a clone with lazies un-tripped"
property_declaration (+21 nodes collapsed)
property_declaration (+40 nodes collapsed)
call_expression
navigation_expression
navigation_expression
identifier "improvement"
. "."
identifier "uniques"
. "."
identifier "add"
value_arguments
( "("
value_argument
identifier "requireUnique"
) ")"
call_expression (+37 nodes collapsed)
assignment
index_expression
navigation_expression
navigation_expression
identifier "game"
. "."
identifier "ruleset"
. "."
identifier "tileImprovements"
[ "["
string_literal
" "\""
string_content "Manufactory"
" "\""
] "]"
= "="
identifier "improvement"
call_expression
navigation_expression
identifier "game"
. "."
identifier "makeHexagonalMap"
value_arguments
( "("
value_argument
number_literal "1"
) ")"
property_declaration
val "val"
variable_declaration
identifier "civ"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCiv"
value_arguments
( "("
value_argument
identifier "isPlayer"
= "="
identifier "true"
) ")"
property_declaration
val "val"
variable_declaration
identifier "centerTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "Zero"
) ")"
property_declaration
val "val"
variable_declaration
identifier "capital"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "civ"
, ","
value_argument
identifier "centerTile"
) ")"
line_comment "// Place an Engineer and see if he could create a Manufactor"...
property_declaration
val "val"
variable_declaration
identifier "unitTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
call_expression
identifier "Vector2"
value_arguments
( "("
value_argument
float_literal "1f"
, ","
value_argument
float_literal "0f"
) ")"
) ")"
property_declaration (+24 nodes collapsed)
assignment
navigation_expression
identifier "unit"
. "."
identifier "currentMovement"
= "="
call_expression
navigation_expression
navigation_expression
navigation_expression
identifier "unit"
. "."
identifier "baseUnit"
. "."
identifier "movement"
. "."
identifier "toFloat"
value_arguments
( "("
) ")"
line_comment "// Required!"
property_declaration (+92 nodes collapsed)
call_expression (+23 nodes collapsed)
line_comment "// Supply Iron"
property_declaration
val "val"
variable_declaration
identifier "ironTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
call_expression
identifier "Vector2"
value_arguments
( "("
value_argument
float_literal "0f"
, ","
value_argument
float_literal "1f"
) ")"
) ")"
assignment
navigation_expression
identifier "ironTile"
. "."
identifier "resource"
= "="
string_literal
" "\""
string_content "Iron"
" "\""
assignment
navigation_expression
identifier "ironTile"
. "."
identifier "resourceAmount"
= "="
number_literal "3"
assignment
navigation_expression
identifier "ironTile"
. "."
identifier "improvement"
= "="
string_literal
" "\""
string_content "Mine"
" "\""
call_expression
navigation_expression
navigation_expression
identifier "civ"
. "."
identifier "tech"
. "."
identifier "addTechnology"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Mining"
" "\""
) ")"
call_expression
navigation_expression
navigation_expression
identifier "civ"
. "."
identifier "tech"
. "."
identifier "addTechnology"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Iron Working"
" "\""
) ")"
line_comment "// capital already owns tile, but this relinquishes first - "...
call_expression
navigation_expression
navigation_expression
identifier "capital"
. "."
identifier "expansion"
. "."
identifier "takeOwnership"
value_arguments
( "("
value_argument
identifier "ironTile"
) ")"
property_declaration
val "val"
variable_declaration
identifier "ironAvailable"
= "="
call_expression
navigation_expression
identifier "civ"
. "."
identifier "getResourceAmount"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Iron"
" "\""
) ")"
call_expression
navigation_expression
identifier "Assert"
. "."
identifier "assertTrue"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Test preparation failed to add Iron to Civ resources"
" "\""
, ","
value_argument
binary_expression
identifier "ironAvailable"
>= ">="
number_literal "3"
) ")"
line_comment "// See if that same Engineer could create a Manufactory NOW"
property_declaration (+33 nodes collapsed)
call_expression (+23 nodes collapsed)
assignment
index_expression
navigation_expression
navigation_expression
identifier "game"
. "."
identifier "ruleset"
. "."
identifier "tileImprovements"
[ "["
string_literal
" "\""
string_content "Manufactory"
" "\""
] "]"
= "="
identifier "oldImprovement"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`Check Hakkapeliitta TransferMovement ability`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
property_declaration
val "val"
variable_declaration
identifier "civ"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCiv"
value_arguments
( "("
value_argument
identifier "isPlayer"
= "="
identifier "true"
) ")"
property_declaration
val "val"
variable_declaration
identifier "centerTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "Zero"
) ")"
line_comment "// Hardcoded names mean test *must* run under G&K ruleset, n"...
property_declaration (+24 nodes collapsed)
property_declaration (+24 nodes collapsed)
call_expression (+31 nodes collapsed)
call_expression
navigation_expression
identifier "boostingUnit"
. "."
identifier "updateUniques"
value_arguments
( "("
) ")"
property_declaration
val "val"
variable_declaration
identifier "baseMovement"
= "="
navigation_expression
navigation_expression
identifier "general"
. "."
identifier "baseUnit"
. "."
identifier "movement"
call_expression
navigation_expression
call_expression
identifier "UnitTurnManager"
value_arguments
( "("
value_argument
identifier "general"
) ")"
. "."
identifier "startTurn"
value_arguments
( "("
) ")"
property_declaration
val "val"
variable_declaration
identifier "actualMovement"
= "="
call_expression
navigation_expression
navigation_expression
identifier "general"
. "."
identifier "currentMovement"
. "."
identifier "roundToInt"
value_arguments
( "("
) ")"
property_declaration
val "val"
variable_declaration
identifier "boosterMovement"
= "="
navigation_expression
navigation_expression
identifier "boostingUnit"
. "."
identifier "baseUnit"
. "."
identifier "movement"
call_expression
navigation_expression
identifier "Assert"
. "."
identifier "assertEquals"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Great General stacked with a Hakkapeliitta should have incre"...
" "\""
, ","
value_argument
identifier "boosterMovement"
, ","
value_argument
identifier "actualMovement"
) ")"
line_comment "// This effectively tests whether the G&K rules have not bee"...
call_expression
navigation_expression
identifier "Assert"
. "."
identifier "assertNotEquals"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Great General stacked with a Hakkapeliitta should NOT have i"...
" "\""
, ","
value_argument
identifier "baseMovement"
, ","
value_argument
identifier "actualMovement"
) ")"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "testCanGetPromotionsWithXP"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
property_declaration
val "val"
variable_declaration
identifier "civ"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCiv"
value_arguments
( "("
value_argument
identifier "isPlayer"
= "="
identifier "true"
) ")"
property_declaration
val "val"
variable_declaration
identifier "centerTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "Zero"
) ")"
property_declaration (+24 nodes collapsed)
property_declaration
val "val"
variable_declaration
identifier "tree"
= "="
call_expression
identifier "PromotionTree"
value_arguments
( "("
value_argument
identifier "unit"
) ")"
call_expression (+46 nodes collapsed)
assignment
navigation_expression
navigation_expression
identifier "unit"
. "."
identifier "promotions"
. "."
identifier "XP"
+= "+="
number_literal "10"
call_expression (+46 nodes collapsed)
} "}"
block_comment "/**\n * Ensures units are assigned instance names.\n *"...
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "testOneTimeUnitGetsName"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
property_declaration
val "val"
variable_declaration
identifier "unit"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addDefaultMeleeUnitWithUniques"
value_arguments
( "("
value_argument
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
, ","
value_argument
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "Vector2"
. "."
identifier "Zero"
) ")"
, ","
value_argument
string_literal
" "\""
string_content "[This Unit] gets a name from the [Scientist] group <upon tur"...
" "\""
) ")"
call_expression
navigation_expression
call_expression
identifier "UnitTurnManager"
value_arguments
( "("
value_argument
identifier "unit"
) ")"
. "."
identifier "startTurn"
value_arguments
( "("
) ")"
call_expression
navigation_expression
identifier "Assert"
. "."
identifier "assertTrue"
value_arguments
( "("
value_argument
binary_expression
navigation_expression
identifier "unit"
. "."
identifier "instanceName"
!= "!="
identifier "null"
) ")"
call_expression (+41 nodes collapsed)
} "}"
function_declaration (+542 nodes collapsed)
} "}"

After

source_file
package_header
package "package"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "uniques"
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 "json"
. "."
identifier "json"
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 "logic"
. "."
identifier "map"
. "."
identifier "mapunit"
. "."
identifier "UnitTurnManager"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "models"
. "."
identifier "UnitActionType"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "models"
. "."
identifier "ruleset"
. "."
identifier "tile"
. "."
identifier "TileImprovement"
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 "com"
. "."
identifier "unciv"
. "."
identifier "ui"
. "."
identifier "screens"
. "."
identifier "pickerscreens"
. "."
identifier "PromotionTree"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "ui"
. "."
identifier "screens"
. "."
identifier "worldscreen"
. "."
identifier "unit"
. "."
identifier "actions"
. "."
identifier "UnitActions"
import
import "import"
qualified_identifier
identifier "com"
. "."
identifier "unciv"
. "."
identifier "ui"
. "."
identifier "screens"
. "."
identifier "worldscreen"
. "."
identifier "unit"
. "."
identifier "actions"
. "."
identifier "UnitActionsFromUniques"
import
import "import"
qualified_identifier
identifier "org"
. "."
identifier "junit"
. "."
identifier "Assert"
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"
import
import "import"
qualified_identifier
identifier "kotlin"
. "."
identifier "math"
. "."
identifier "roundToInt"
class_declaration
modifiers
annotation
@ "@"
constructor_invocation
user_type
identifier "RunWith"
value_arguments
( "("
value_argument
navigation_expression
identifier "GdxTestRunner"
:: "::"
identifier "class"
) ")"
class "class"
identifier "UnitUniquesTests"
class_body
{ "{"
property_declaration
modifiers
visibility_modifier
private "private"
member_modifier
lateinit "lateinit"
var "var"
variable_declaration
identifier "game"
: ":"
user_type
identifier "TestGame"
function_declaration (+23 nodes collapsed)
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`Sweden can gift Great Persons to City States`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// when"
call_expression
navigation_expression
identifier "game"
. "."
identifier "makeHexagonalMap"
value_arguments
( "("
value_argument
number_literal "1"
) ")"
property_declaration
val "val"
variable_declaration
identifier "cityState"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCiv"
value_arguments
( "("
value_argument
identifier "cityStateType"
= "="
string_literal
" "\""
string_content "Cultured"
" "\""
) ")"
property_declaration
val "val"
variable_declaration
identifier "cityStateCapitalTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "HexCoord"
. "."
identifier "Zero"
) ")"
property_declaration
val "val"
variable_declaration
identifier "cityStateCapital"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "cityState"
, ","
value_argument
identifier "cityStateCapitalTile"
) ")"
property_declaration (+23 nodes collapsed)
property_declaration
val "val"
variable_declaration
identifier "unitTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
number_literal "1"
, ","
value_argument
number_literal "0"
) ")"
call_expression
navigation_expression
navigation_expression
identifier "cityStateCapital"
. "."
identifier "expansion"
. "."
identifier "takeOwnership"
value_arguments
( "("
value_argument
identifier "unitTile"
) ")"
property_declaration (+24 nodes collapsed)
line_comment "// then"
property_declaration (+36 nodes collapsed)
line_comment "// This tests that the action should be enabled, too"
call_expression
navigation_expression
identifier "Assert"
. "."
identifier "assertNotNull"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Great Person should have a gift action"
" "\""
, ","
value_argument
identifier "giftAction"
) ")"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "canConstructResourceRequiringImprovement"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
line_comment "// Do this early so the uniqueObjects lazy is still un-trigg"...
property_declaration (+30 nodes collapsed)
line_comment "// Get a clone with lazies un-tripped"
property_declaration (+21 nodes collapsed)
property_declaration (+40 nodes collapsed)
call_expression
navigation_expression
navigation_expression
identifier "improvement"
. "."
identifier "uniques"
. "."
identifier "add"
value_arguments
( "("
value_argument
identifier "requireUnique"
) ")"
call_expression (+37 nodes collapsed)
assignment
index_expression
navigation_expression
navigation_expression
identifier "game"
. "."
identifier "ruleset"
. "."
identifier "tileImprovements"
[ "["
string_literal
" "\""
string_content "Manufactory"
" "\""
] "]"
= "="
identifier "improvement"
call_expression
navigation_expression
identifier "game"
. "."
identifier "makeHexagonalMap"
value_arguments
( "("
value_argument
number_literal "1"
) ")"
property_declaration
val "val"
variable_declaration
identifier "civ"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCiv"
value_arguments
( "("
value_argument
identifier "isPlayer"
= "="
identifier "true"
) ")"
property_declaration
val "val"
variable_declaration
identifier "centerTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "HexCoord"
. "."
identifier "Zero"
) ")"
property_declaration
val "val"
variable_declaration
identifier "capital"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCity"
value_arguments
( "("
value_argument
identifier "civ"
, ","
value_argument
identifier "centerTile"
) ")"
line_comment "// Place an Engineer and see if he could create a Manufactor"...
property_declaration
val "val"
variable_declaration
identifier "unitTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
call_expression
identifier "HexCoord"
value_arguments
( "("
value_argument
number_literal "1"
, ","
value_argument
number_literal "0"
) ")"
) ")"
property_declaration (+24 nodes collapsed)
assignment
navigation_expression
identifier "unit"
. "."
identifier "currentMovement"
= "="
call_expression
navigation_expression
navigation_expression
navigation_expression
identifier "unit"
. "."
identifier "baseUnit"
. "."
identifier "movement"
. "."
identifier "toFloat"
value_arguments
( "("
) ")"
line_comment "// Required!"
property_declaration (+92 nodes collapsed)
call_expression (+23 nodes collapsed)
line_comment "// Supply Iron"
property_declaration
val "val"
variable_declaration
identifier "ironTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
call_expression
identifier "HexCoord"
value_arguments
( "("
value_argument
number_literal "0"
, ","
value_argument
number_literal "1"
) ")"
) ")"
assignment
navigation_expression
identifier "ironTile"
. "."
identifier "resource"
= "="
string_literal
" "\""
string_content "Iron"
" "\""
assignment
navigation_expression
identifier "ironTile"
. "."
identifier "resourceAmount"
= "="
number_literal "3"
assignment
navigation_expression
identifier "ironTile"
. "."
identifier "improvement"
= "="
string_literal
" "\""
string_content "Mine"
" "\""
call_expression
navigation_expression
navigation_expression
identifier "civ"
. "."
identifier "tech"
. "."
identifier "addTechnology"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Mining"
" "\""
) ")"
call_expression
navigation_expression
navigation_expression
identifier "civ"
. "."
identifier "tech"
. "."
identifier "addTechnology"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Iron Working"
" "\""
) ")"
line_comment "// capital already owns tile, but this relinquishes first - "...
call_expression
navigation_expression
navigation_expression
identifier "capital"
. "."
identifier "expansion"
. "."
identifier "takeOwnership"
value_arguments
( "("
value_argument
identifier "ironTile"
) ")"
property_declaration
val "val"
variable_declaration
identifier "ironAvailable"
= "="
call_expression
navigation_expression
identifier "civ"
. "."
identifier "getResourceAmount"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Iron"
" "\""
) ")"
call_expression
navigation_expression
identifier "Assert"
. "."
identifier "assertTrue"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Test preparation failed to add Iron to Civ resources"
" "\""
, ","
value_argument
binary_expression
identifier "ironAvailable"
>= ">="
number_literal "3"
) ")"
line_comment "// See if that same Engineer could create a Manufactory NOW"
property_declaration (+33 nodes collapsed)
call_expression (+23 nodes collapsed)
assignment
index_expression
navigation_expression
navigation_expression
identifier "game"
. "."
identifier "ruleset"
. "."
identifier "tileImprovements"
[ "["
string_literal
" "\""
string_content "Manufactory"
" "\""
] "]"
= "="
identifier "oldImprovement"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "`Check Hakkapeliitta TransferMovement ability`"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
property_declaration
val "val"
variable_declaration
identifier "civ"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCiv"
value_arguments
( "("
value_argument
identifier "isPlayer"
= "="
identifier "true"
) ")"
property_declaration
val "val"
variable_declaration
identifier "centerTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "HexCoord"
. "."
identifier "Zero"
) ")"
line_comment "// Hardcoded names mean test *must* run under G&K ruleset, n"...
property_declaration (+24 nodes collapsed)
property_declaration (+24 nodes collapsed)
call_expression (+31 nodes collapsed)
call_expression
navigation_expression
identifier "boostingUnit"
. "."
identifier "updateUniques"
value_arguments
( "("
) ")"
property_declaration
val "val"
variable_declaration
identifier "baseMovement"
= "="
navigation_expression
navigation_expression
identifier "general"
. "."
identifier "baseUnit"
. "."
identifier "movement"
call_expression
navigation_expression
call_expression
identifier "UnitTurnManager"
value_arguments
( "("
value_argument
identifier "general"
) ")"
. "."
identifier "startTurn"
value_arguments
( "("
) ")"
property_declaration
val "val"
variable_declaration
identifier "actualMovement"
= "="
call_expression
navigation_expression
navigation_expression
identifier "general"
. "."
identifier "currentMovement"
. "."
identifier "roundToInt"
value_arguments
( "("
) ")"
property_declaration
val "val"
variable_declaration
identifier "boosterMovement"
= "="
navigation_expression
navigation_expression
identifier "boostingUnit"
. "."
identifier "baseUnit"
. "."
identifier "movement"
call_expression
navigation_expression
identifier "Assert"
. "."
identifier "assertEquals"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Great General stacked with a Hakkapeliitta should have incre"...
" "\""
, ","
value_argument
identifier "boosterMovement"
, ","
value_argument
identifier "actualMovement"
) ")"
line_comment "// This effectively tests whether the G&K rules have not bee"...
call_expression
navigation_expression
identifier "Assert"
. "."
identifier "assertNotEquals"
value_arguments
( "("
value_argument
string_literal
" "\""
string_content "Great General stacked with a Hakkapeliitta should NOT have i"...
" "\""
, ","
value_argument
identifier "baseMovement"
, ","
value_argument
identifier "actualMovement"
) ")"
} "}"
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "testCanGetPromotionsWithXP"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
property_declaration
val "val"
variable_declaration
identifier "civ"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCiv"
value_arguments
( "("
value_argument
identifier "isPlayer"
= "="
identifier "true"
) ")"
property_declaration
val "val"
variable_declaration
identifier "centerTile"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "HexCoord"
. "."
identifier "Zero"
) ")"
property_declaration (+24 nodes collapsed)
property_declaration
val "val"
variable_declaration
identifier "tree"
= "="
call_expression
identifier "PromotionTree"
value_arguments
( "("
value_argument
identifier "unit"
) ")"
call_expression (+46 nodes collapsed)
assignment
navigation_expression
navigation_expression
identifier "unit"
. "."
identifier "promotions"
. "."
identifier "XP"
+= "+="
number_literal "10"
call_expression (+46 nodes collapsed)
} "}"
block_comment "/**\n * Ensures units are assigned instance names.\n *"...
function_declaration
modifiers
annotation
@ "@"
user_type
identifier "Test"
fun "fun"
identifier "testOneTimeUnitGetsName"
function_value_parameters
( "("
) ")"
function_body
block
{ "{"
property_declaration
val "val"
variable_declaration
identifier "unit"
= "="
call_expression
navigation_expression
identifier "game"
. "."
identifier "addDefaultMeleeUnitWithUniques"
value_arguments
( "("
value_argument
call_expression
navigation_expression
identifier "game"
. "."
identifier "addCiv"
value_arguments
( "("
) ")"
, ","
value_argument
call_expression
navigation_expression
identifier "game"
. "."
identifier "getTile"
value_arguments
( "("
value_argument
navigation_expression
identifier "HexCoord"
. "."
identifier "Zero"
) ")"
, ","
value_argument
string_literal
" "\""
string_content "[This Unit] gets a name from the [Scientist] group <upon tur"...
" "\""
) ")"
call_expression
navigation_expression
call_expression
identifier "UnitTurnManager"
value_arguments
( "("
value_argument
identifier "unit"
) ")"
. "."
identifier "startTurn"
value_arguments
( "("
) ")"
call_expression
navigation_expression
identifier "Assert"
. "."
identifier "assertTrue"
value_arguments
( "("
value_argument
binary_expression
navigation_expression
identifier "unit"
. "."
identifier "instanceName"
!= "!="
identifier "null"
) ")"
call_expression (+41 nodes collapsed)
} "}"
function_declaration (+542 nodes collapsed)
} "}"