From 04423be44fc8ddafb656a3dd0a272efd926c295d Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Tue, 14 May 2024 10:00:51 +0200 Subject: [PATCH] Fix "Move a unit" tutorial isn't completed by moving via right-click (#11591) --- .../unciv/ui/screens/worldscreen/WorldMapHolder.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/ui/screens/worldscreen/WorldMapHolder.kt b/core/src/com/unciv/ui/screens/worldscreen/WorldMapHolder.kt index 6e24b66571..0586446dc7 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/WorldMapHolder.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/WorldMapHolder.kt @@ -267,6 +267,11 @@ class WorldMapHolder( worldScreen.shouldUpdate = localShouldUpdate } + private fun markUnitMoveTutorialComplete(unit: MapUnit) { + val key = if (unit.baseUnit.movesLikeAirUnits()) "Move an air unit" else "Move unit" + UncivGame.Current.settings.addCompletedTutorialTask(key) + } + private fun moveUnitToTargetTile(selectedUnits: List, targetTile: Tile) { // this can take a long time, because of the unit-to-tile calculation needed, so we put it in a different thread // THIS PART IS REALLY ANNOYING @@ -277,6 +282,7 @@ class WorldMapHolder( // and then calling the function again but without the unit that moved. val selectedUnit = selectedUnits.first() + markUnitMoveTutorialComplete(selectedUnit) // not too expensive to have it repeat too often Concurrency.run("TileToMoveTo") { // these are the heavy parts, finding where we want to go @@ -334,6 +340,7 @@ class WorldMapHolder( } private fun swapMoveUnitToTargetTile(selectedUnit: MapUnit, targetTile: Tile) { + markUnitMoveTutorialComplete(selectedUnit) selectedUnit.movement.swapMoveToTile(targetTile) if (selectedUnit.isExploring() || selectedUnit.isMoving()) @@ -531,9 +538,6 @@ class WorldMapHolder( if (unitsThatCanMove.isEmpty()) moveHereButton.color.a = 0.5f else { moveHereButton.onActivation(UncivSound.Silent) { - UncivGame.Current.settings.addCompletedTutorialTask("Move unit") - if (unitsThatCanMove.any { it.baseUnit.movesLikeAirUnits() }) - UncivGame.Current.settings.addCompletedTutorialTask("Move an air unit") moveUnitToTargetTile(unitsThatCanMove, dto.tile) } moveHereButton.keyShortcuts.add(KeyCharAndCode.TAB) @@ -558,9 +562,6 @@ class WorldMapHolder( swapWithButton.addActor(unitIcon) swapWithButton.onActivation(UncivSound.Silent) { - UncivGame.Current.settings.addCompletedTutorialTask("Move unit") - if (dto.unit.baseUnit.movesLikeAirUnits()) - UncivGame.Current.settings.addCompletedTutorialTask("Move an air unit") swapMoveUnitToTargetTile(dto.unit, dto.tile) } swapWithButton.keyShortcuts.add(KeyCharAndCode.TAB)