mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-26 07:39:44 +07:00
Leftovers from previous PRs (#6725)
* Leftovers from #6698 * Leftovers from #6718 * Better naming
This commit is contained in:
@ -601,6 +601,10 @@ Load from custom location =
|
|||||||
Could not load game from custom location! =
|
Could not load game from custom location! =
|
||||||
Save to custom location =
|
Save to custom location =
|
||||||
Could not save game 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
|
# Options
|
||||||
|
|
||||||
|
@ -866,7 +866,7 @@ class MapUnit {
|
|||||||
clearEncampment(tile)
|
clearEncampment(tile)
|
||||||
// Check whether any civilians without military units are there.
|
// Check whether any civilians without military units are there.
|
||||||
// Keep in mind that putInTile(), which calls this method,
|
// 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)
|
val unguardedCivilian = tile.getUnguardedCivilian(this)
|
||||||
// Capture Enemy Civilian Unit if you move on top of it
|
// Capture Enemy Civilian Unit if you move on top of it
|
||||||
if (isMilitary() && unguardedCivilian != null && civInfo.isAtWarWith(unguardedCivilian.civInfo)) {
|
if (isMilitary() && unguardedCivilian != null && civInfo.isAtWarWith(unguardedCivilian.civInfo)) {
|
||||||
|
@ -145,10 +145,9 @@ open class TileInfo {
|
|||||||
return null
|
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? {
|
fun getUnguardedCivilian(attacker: MapUnit): MapUnit? {
|
||||||
if (militaryUnit != null && militaryUnit != attacker) return null
|
if (militaryUnit != null && militaryUnit != attacker) return null
|
||||||
if (airUnits.isNotEmpty()) return null
|
|
||||||
if (civilianUnit != null) return civilianUnit!!
|
if (civilianUnit != null) return civilianUnit!!
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,9 @@ object Github {
|
|||||||
* @see <a href="https://docs.github.com/en/rest/reference/search#search-repositories">Github API doc</a>
|
* @see <a href="https://docs.github.com/en/rest/reference/search#search-repositories">Github API doc</a>
|
||||||
*/
|
*/
|
||||||
fun tryGetGithubReposWithTopic(amountPerPage:Int, page:Int, searchRequest: String = ""): RepoSearch? {
|
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
|
var retries = 2
|
||||||
while (retries > 0) {
|
while (retries > 0) {
|
||||||
retries--
|
retries--
|
||||||
|
@ -162,10 +162,10 @@ class LoadGameScreen(previousScreen:BaseScreen) : PickerScreen(disableScroll = t
|
|||||||
try {
|
try {
|
||||||
val mods = missingModsToLoad.replace(' ', '-').lowercase().splitToSequence(",-")
|
val mods = missingModsToLoad.replace(' ', '-').lowercase().splitToSequence(",-")
|
||||||
for (modName in mods) {
|
for (modName in mods) {
|
||||||
val repos = Github.tryGetGithubReposWithTopic(10, 1, "$modName+") // + is important here!
|
val repos = Github.tryGetGithubReposWithTopic(10, 1, modName)
|
||||||
?: throw UncivShowableException("Could not download mod list")
|
?: throw UncivShowableException("Could not download mod list.".tr())
|
||||||
val repo = repos.items.firstOrNull { it.name.lowercase() == modName }
|
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(
|
val modFolder = Github.downloadAndExtract(
|
||||||
repo.html_url, repo.default_branch,
|
repo.html_url, repo.default_branch,
|
||||||
Gdx.files.local("mods")
|
Gdx.files.local("mods")
|
||||||
|
Reference in New Issue
Block a user