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 PartyTimeSolver(SceneGraphSolver, BaseMixin):
    solver_name = "线索交流结束时间"

    def run(self):
        super().run()

    def transition(self) -> bool:
        if (
            scene := self.scene()
        ) == Scene.INFRA_DETAILS and self.detect_room() == "meeting":
            if self.find("clue/title_party", scope=((1600, 190), (1880, 260))):
                config.party_time = self.double_read_time(((1768, 438), (1902, 480)))
                logger.info(f"线索交流结束时间：{config.party_time}")
                return True
            else:
                config.party_time = None
                logger.info("线索交流未开启")
                return True
        elif scene == Scene.INFRA_CONFIDENTIAL:
            self.back()
        else:
            EnterRoomSolver().run("meeting", detail=False)
