from mower.utils.graph import SceneGraphSolver
from mower.utils.recognize import Scene

from .utils.utils import find_text


class ChooseSupportAwardSolver(SceneGraphSolver):
    solver_name = "选择支援奖励"
    _award = ["做思想准备", "随手拿点啥", "出发前演讲", "储备金支援"]

    def transition(self):
        if (scene := self.scene()) == Scene.ROGUE_AWARD_BEFORE_EXPLORE:
            if self.animation(interval=0.2):
                return
            if pos := self.find("rogue/team_check_to_do"):
                self.ctap(pos, 3)
                return
            for text in self._award:
                if pos := find_text(text, 39, scope=((250, 600), (1750, 800))):
                    self.tap(pos)
                    return

        elif scene in self.waiting_scene:
            self.waiting_solver()
        else:
            return True
