use bd2::prost::Message;
use bd2::proto::proto_net::{
    EventHubDbInfo, EventHubInfoRequest, EventHubInfoResponse, EventHubSettingDbInfo, Notify,
};
use common::packet_code::PacketCodeType;
use crypto::network::GameResponse;
use sqlx::SqlitePool;
use tracing::info;

pub async fn handle(_pool: &SqlitePool, _uid: i64, req: EventHubInfoRequest) -> GameResponse {
    info!("Handling EventHubInfoRequest: {:?}", req);

    let event_hub_info = vec![
        EventHubDbInfo {
            setting_info: vec![
                EventHubSettingDbInfo {
                    slot: Some(0),
                    hub_content_type: Some(1),
                    event_uid: vec![1167, 1168, 1169, 1170, 1171],
                },
                EventHubSettingDbInfo {
                    slot: Some(1),
                    hub_content_type: Some(2),
                    event_uid: vec![1165],
                },
                EventHubSettingDbInfo {
                    slot: Some(2),
                    hub_content_type: Some(2),
                    event_uid: vec![1166],
                },
                EventHubSettingDbInfo {
                    slot: Some(4),
                    hub_content_type: Some(3),
                    event_uid: vec![50],
                },
                EventHubSettingDbInfo {
                    slot: Some(6),
                    hub_content_type: Some(9),
                    event_uid: vec![1179],
                },
                EventHubSettingDbInfo {
                    slot: Some(7),
                    hub_content_type: Some(8),
                    event_uid: vec![1161],
                },
                EventHubSettingDbInfo {
                    slot: Some(9),
                    hub_content_type: Some(1),
                    event_uid: vec![1172, 1173, 1174, 1175, 1176],
                },
            ],
            uid: Some(50),
            hub_id: Some(10),
            start_time: Some(1760054400000),
            play_end_time: Some(1761177599000),
            end_time: Some(1762387199000),
        },
        EventHubDbInfo {
            setting_info: vec![
                EventHubSettingDbInfo {
                    slot: Some(0),
                    hub_content_type: Some(1),
                    event_uid: vec![
                        1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191,
                        1192, 1193,
                    ],
                },
                EventHubSettingDbInfo {
                    slot: Some(1),
                    hub_content_type: Some(2),
                    event_uid: vec![1194],
                },
                EventHubSettingDbInfo {
                    slot: Some(2),
                    hub_content_type: Some(2),
                    event_uid: vec![1195],
                },
                EventHubSettingDbInfo {
                    slot: Some(4),
                    hub_content_type: Some(3),
                    event_uid: vec![51],
                },
                EventHubSettingDbInfo {
                    slot: Some(6),
                    hub_content_type: Some(9),
                    event_uid: vec![1196],
                },
                EventHubSettingDbInfo {
                    slot: Some(7),
                    hub_content_type: Some(8),
                    event_uid: vec![1197],
                },
            ],
            uid: Some(51),
            hub_id: Some(38),
            start_time: Some(1761177600000),
            play_end_time: Some(1762387199000),
            end_time: Some(1763596799000),
        },
    ];

    let response = EventHubInfoResponse {
        event_hub_info,
        ..Default::default()
    };

    let resp_bytes = response.encode_to_vec();

    let notify = Notify {
        achievement_update_info: vec![],
        mission_update_info: vec![],
        event_mission_update_info: vec![],
        active_login_event: vec![1, 2, 628, 629],
        active_contents_info: vec![],
        ll_type: Some("".to_string()),
        is_purchasing_disabled: Some(false),
        maintenance_start_date: Some(1688646600000),
        notice_last_seq: Some(8909),
        ..Default::default()
    };

    let (route, code) = PacketCodeType::Common.info();
    GameResponse::success(route, &resp_bytes, code).with_notify(&notify)
}
