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

from . import data
from .rogue_navi import RogueNaviSolver


class RogueAbandonExploreSolver(SceneGraphSolver):
    solver_name = "放弃探索"

    def run(self) -> bool:
        super().run()
        data.next_step = {}
        data.last_node_id = ""

    def transition(self):
        if self.scene() == Scene.ROGUE_INDEX:
            if pos := self.find(f"rogue/abandon_explore/{config.conf.maa_rg_theme}"):
                self.tap(pos)
                return
            return True

        else:
            RogueNaviSolver().run()
