From d00b72806b8121c3923030ada13ac3ea1af81d61 Mon Sep 17 00:00:00 2001 From: Jack Rainy Date: Sun, 8 May 2022 21:19:55 +0300 Subject: [PATCH] Leftovers from previous PRs (#6725) * Leftovers from #6698 * Leftovers from #6718 * Better naming --- android/assets/jsons/translations/template.properties | 4 ++++ core/src/com/unciv/logic/map/MapUnit.kt | 2 +- core/src/com/unciv/logic/map/TileInfo.kt | 3 +-- core/src/com/unciv/ui/pickerscreens/GitHub.kt | 4 +++- core/src/com/unciv/ui/saves/LoadGameScreen.kt | 6 +++--- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 9f4a78a126..1f902ac423 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -601,6 +601,10 @@ Load from custom location = Could not load game from custom location! = Save to custom location = Could not save game to custom location! = +Missing mods are downloaded successfully. = +Could not load the missing mods! = +Could not download mod list. = +Could not find a mod named "[modName]". = # Options diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 0281c7aa85..4f082314ad 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -866,7 +866,7 @@ class MapUnit { clearEncampment(tile) // Check whether any civilians without military units are there. // Keep in mind that putInTile(), which calls this method, - // might has already placed your military unit in this tile. + // might have already placed your military unit in this tile. val unguardedCivilian = tile.getUnguardedCivilian(this) // Capture Enemy Civilian Unit if you move on top of it if (isMilitary() && unguardedCivilian != null && civInfo.isAtWarWith(unguardedCivilian.civInfo)) { diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index b3d2ee97be..250796b14c 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -145,10 +145,9 @@ open class TileInfo { return null } - /** Return null if military/air units on tile, or no civilian */ + /** Return null if military on tile, or no civilian */ fun getUnguardedCivilian(attacker: MapUnit): MapUnit? { if (militaryUnit != null && militaryUnit != attacker) return null - if (airUnits.isNotEmpty()) return null if (civilianUnit != null) return civilianUnit!! return null } diff --git a/core/src/com/unciv/ui/pickerscreens/GitHub.kt b/core/src/com/unciv/ui/pickerscreens/GitHub.kt index a37d0ce5fd..aa1fc4ab45 100644 --- a/core/src/com/unciv/ui/pickerscreens/GitHub.kt +++ b/core/src/com/unciv/ui/pickerscreens/GitHub.kt @@ -220,7 +220,9 @@ object Github { * @see Github API doc */ fun tryGetGithubReposWithTopic(amountPerPage:Int, page:Int, searchRequest: String = ""): RepoSearch? { - val link = "https://api.github.com/search/repositories?q=${searchRequest}topic:unciv-mod&sort:stars&per_page=$amountPerPage&page=$page" + // Add + here to separate the query text from its parameters + val searchText = if (searchRequest != "") "$searchRequest+" else "" + val link = "https://api.github.com/search/repositories?q=${searchText}topic:unciv-mod&sort:stars&per_page=$amountPerPage&page=$page" var retries = 2 while (retries > 0) { retries-- diff --git a/core/src/com/unciv/ui/saves/LoadGameScreen.kt b/core/src/com/unciv/ui/saves/LoadGameScreen.kt index ca9fbeadf6..68d13c0223 100644 --- a/core/src/com/unciv/ui/saves/LoadGameScreen.kt +++ b/core/src/com/unciv/ui/saves/LoadGameScreen.kt @@ -162,10 +162,10 @@ class LoadGameScreen(previousScreen:BaseScreen) : PickerScreen(disableScroll = t try { val mods = missingModsToLoad.replace(' ', '-').lowercase().splitToSequence(",-") for (modName in mods) { - val repos = Github.tryGetGithubReposWithTopic(10, 1, "$modName+") // + is important here! - ?: throw UncivShowableException("Could not download mod list") + val repos = Github.tryGetGithubReposWithTopic(10, 1, modName) + ?: throw UncivShowableException("Could not download mod list.".tr()) val repo = repos.items.firstOrNull { it.name.lowercase() == modName } - ?: throw UncivShowableException("The $modName is not found.") + ?: throw UncivShowableException("Could not find a mod named \"[$modName]\".".tr()) val modFolder = Github.downloadAndExtract( repo.html_url, repo.default_branch, Gdx.files.local("mods")