Skip to content

Commit

Permalink
Support FP roll and No Support Found for TranslateFGO (#1667)
Browse files Browse the repository at this point in the history
  • Loading branch information
reconman committed Aug 26, 2023
1 parent 5811cfd commit 518a914
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
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

0 comments on commit 518a914

Please sign in to comment.