from mower.solvers.infra.base_mixin import BaseMixin
from mower.solvers.infra.enter_room import EnterRoomSolver
from mower.utils import config
from mower.utils.graph import SceneGraphSolver
from mower.utils.log import logger
from mower.utils.recognize import Scene


class GetClueCountSolver(SceneGraphSolver, BaseMixin):
    def run(self) -> int:
        self.res = -1
        super().run()
        if self.res >= 0:
            return self.res
        raise ValueError("未找到线索数量")

    def transition(self) -> bool:
        if self.find("arrange_check_in"):
            self.res = self.read_screen(
                config.recog.img, limit=10, cord=((645, 977), (755, 1018))
            )
            logger.info(f"当前拥有线索数量为{self.res}")
            return True
        elif self.scene() == Scene.INFRA_CONFIDENTIAL:
            self.back()
        else:
            EnterRoomSolver().run("meeting", detail=False)
