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


class PartyTimeSolver(SceneGraphSolver, BaseMixin):
    def run(self):
        super().run()
        return self.party_time

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