Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FP roll and No Support Found for TranslateFGO #1667

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package io.github.fate_grand_automata.scripts

import io.github.fate_grand_automata.scripts.enums.GameServer
import io.github.fate_grand_automata.scripts.locations.Locations
import io.github.fate_grand_automata.scripts.prefs.IPreferences
import io.github.lib_automata.AutomataApi
import io.github.lib_automata.Region

interface IFgoAutomataApi : AutomataApi {
val prefs: IPreferences
val images: IImageLoader
val locations: Locations
val messages: IScriptMessages

/**
* Helper method to search for the current server's image and to also search for the English one in case of TranslateFGO.
*/
fun findImage(region: Region, image: Images) =
images[image] in region || (prefs.gameServer is GameServer.Jp && images[image, GameServer.default] in region)
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class AutoBattle @Inject constructor(

// for TranslateFGO where the Repeat button is in English
if (match == null && prefs.gameServer is GameServer.Jp) {
match = locations.continueRegion.find(images[Images.Repeat, GameServer.En.Original])
match = locations.continueRegion.find(images[Images.Repeat, GameServer.default])
}
return match
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ class AutoDetect @Inject constructor(
}

when {
images[Images.FriendSummon] in locations.fp.summonCheck || images[Images.FPSummonContinue] in locations.fp.continueSummonRegion ->
images[Images.FriendSummon] in locations.fp.summonCheck || findImage(locations.fp.continueSummonRegion, Images.FPSummonContinue) ->
ScriptModeEnum.FP

images[Images.LotteryBoxFinished] in locations.lottery.checkRegion || images[Images.LotteryBoxFinished] in locations.lottery.finishedRegion ->
ScriptModeEnum.Lottery

images[Images.GoldXP] in emberSearchRegion || images[Images.SilverXP] in emberSearchRegion ->
ScriptModeEnum.PresentBox

locations.support.confirmSetupButtonRegion.exists(images[Images.SupportConfirmSetupButton], similarity = 0.75) ->
ScriptModeEnum.SupportImageMaker

images[Images.CEEnhance] in locations.ceEnhanceRegion ->
ScriptModeEnum.CEBomb

else -> ScriptModeEnum.Battle
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AutoFriendGacha @Inject constructor(
}

override fun script(): Nothing {
if (images[Images.FPSummonContinue] !in locations.fp.continueSummonRegion) {
if (!isSummonButtonVisible()) {
locations.fp.first10SummonClick.click()
0.3.seconds.wait()
locations.fp.okClick.click()
Expand All @@ -47,7 +47,7 @@ class AutoFriendGacha @Inject constructor(
throw ExitException(ExitReason.InventoryFull)
}

if (images[Images.FPSummonContinue] in locations.fp.continueSummonRegion) {
if (isSummonButtonVisible()) {
countNext()

locations.fp.continueSummonClick.click()
Expand All @@ -57,4 +57,6 @@ class AutoFriendGacha @Inject constructor(
} else locations.fp.skipRapidClick.click(15)
}
}

private fun isSummonButtonVisible() = findImage(locations.fp.continueSummonRegion, Images.FPSummonContinue)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class RealSupportScreen @Inject constructor(
override fun isAnyDialogOpen() =
images[Images.SupportExtra] !in locations.support.extraRegion

override fun noSupportsPresent() =
images[Images.SupportNotFound] in locations.support.notFoundRegion
override fun noSupportsPresent() = findImage(locations.support.notFoundRegion, Images.SupportNotFound)

override fun someSupportsPresent() =
locations.support.confirmSetupButtonRegion.exists(
Expand Down