from mower.data import base_room_list
from mower.solvers.infra.get_agent_from_room import GetAgentFromRoomSolver
from mower.utils import config
from mower.utils.config.plan import Facility

run_order_op = ["但书", "龙舌兰", "佩佩"]


class MiniBase:
    """
    只保存干员心情数据，根据历史与当前心情数据无状态地生成任务
    1. 收产物
    2. 读所有站的跑单时间
        - 没有订单就继续
        - 有一笔订单在前置时间以内就跑这一单
        - 有多笔订单在前置时间以内，按时间用无人机跑前面几单
    3. 读取干员信息
    4. 立即执行
        - 修正与排班表不一致的地方
        - 休息好的干员换上来
        - 心情低的干员安排休息
        - 肥鸭充能
    5. 若过贸易站或刷新列表中的人，重复步骤2
    6. 生成任务
        - 跑单
        - 肥鸭充能
        - 心情恢复结束
        - 暖机干员下班
    """

    solver_name = "基建·青春版"

    def run_order_room(self) -> list[str]:
        """获取跑单房间"""
        result = []
        for row in range(1, 4):
            for col in range(1, 4):
                room = f"room_{row}_{col}"
                facility: Facility = getattr(config.plan.plan1, room)
                for plan in facility.plans:
                    if any(op in plan.replacement for op in run_order_op):
                        result.append(room)
        return result

    def run(self):
        # 1. 收产物，等elaina的todo solver

        # 2. 读所有站的订单剩余时间，没有无人机跑单，暂时跳过
        # run_order_time = []
        # for room in self.run_order_room():
        #     run_order_time.append(
        #         (
        #             datetime.now()
        #             + timedelta(seconds=GetOrderRemainingTimeSolver().run(room)),
        #             room,
        #         )
        #     )
        # run_order_time.sort()
        # time_limt = datetime.now() + timedelta(minutes=config.conf.run_order_delay)

        # 3. 读取干员信息，先不管以前的数据
        op_data = {}
        for room in base_room_list:
            op_data[room] = GetAgentFromRoomSolver().run(room)
