mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 07:17:50 +07:00
Fixed pillage tests
This commit is contained in:
@ -237,10 +237,10 @@ class ConsoleTileCommands: ConsoleCommandNode {
|
||||
|
||||
class ConsoleCivCommands : ConsoleCommandNode {
|
||||
override val subcommands = hashMapOf<String, ConsoleCommand>(
|
||||
"addstat" to ConsoleAction { console, params ->
|
||||
"add" to ConsoleAction { console, params ->
|
||||
var statPos = 0
|
||||
if (params.size !in 2..3)
|
||||
return@ConsoleAction DevConsoleResponse.hint("Format: civ addstat [civ] [stat] <amount>")
|
||||
return@ConsoleAction DevConsoleResponse.hint("Format: civ add [civ] <stat> <amount>")
|
||||
val civ = if (params.size == 2) console.screen.selectedCiv
|
||||
else {
|
||||
statPos++
|
||||
|
@ -11,7 +11,6 @@ import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.stats.Stat
|
||||
import com.unciv.models.stats.Stats
|
||||
import com.unciv.ui.popups.ConfirmPopup
|
||||
import com.unciv.ui.popups.hasOpenPopups
|
||||
import kotlin.random.Random
|
||||
|
||||
object UnitActionsPillage {
|
||||
@ -19,21 +18,19 @@ object UnitActionsPillage {
|
||||
fun getPillageActions(unit: MapUnit, tile: Tile): List<UnitAction> {
|
||||
val pillageAction = getPillageAction(unit, tile)
|
||||
?: return listOf()
|
||||
if (pillageAction.action == null)
|
||||
if (pillageAction.action == null || unit.civ.isAI())
|
||||
return listOf(pillageAction)
|
||||
else return listOf(UnitAction(UnitActionType.Pillage, pillageAction.title) {
|
||||
if (!GUI.getWorldScreen().hasOpenPopups()) {
|
||||
val pillageText = "Are you sure you want to pillage this [${tile.getImprovementToPillageName()!!}]?"
|
||||
ConfirmPopup(
|
||||
GUI.getWorldScreen(),
|
||||
pillageText,
|
||||
"Pillage",
|
||||
true
|
||||
) {
|
||||
(pillageAction.action)()
|
||||
GUI.setUpdateWorldOnNextRender()
|
||||
}.open()
|
||||
}
|
||||
val pillageText = "Are you sure you want to pillage this [${tile.getImprovementToPillageName()!!}]?"
|
||||
ConfirmPopup(
|
||||
GUI.getWorldScreen(),
|
||||
pillageText,
|
||||
"Pillage",
|
||||
true
|
||||
) {
|
||||
(pillageAction.action)()
|
||||
GUI.setUpdateWorldOnNextRender()
|
||||
}.open()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,10 @@ package com.unciv.uniques
|
||||
|
||||
import com.badlogic.gdx.math.Vector2
|
||||
import com.unciv.Constants
|
||||
import com.unciv.models.UnitActionType
|
||||
import com.unciv.testing.GdxTestRunner
|
||||
import com.unciv.testing.TestGame
|
||||
import com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsPillage
|
||||
import com.unciv.ui.screens.worldscreen.unit.actions.UnitActions
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@ -35,8 +36,7 @@ class TileUniquesTests {
|
||||
val unit = game.addUnit("Warrior", civInfo, tile)
|
||||
unit.currentMovement = 2f
|
||||
|
||||
val pillageAction = UnitActionsPillage.getPillageAction(unit)
|
||||
pillageAction?.action?.invoke()
|
||||
UnitActions.invokeUnitAction(unit, UnitActionType.Pillage)
|
||||
Assert.assertTrue("Pillaging should transfer gold to the civ", civInfo.gold == 20)
|
||||
Assert.assertTrue("Pillaging should transfer food to the nearest city", city.population.foodStored == 11)
|
||||
}
|
||||
|
Reference in New Issue
Block a user