use bd2::prost::Message;
use bd2::proto::proto_net::{Notify, PackDbInfo, PackInfoRequest, PackInfoResponse};
use common::packet_code::PacketCodeType;
use crypto::network::GameResponse;
use sqlx::SqlitePool;
use tracing::info;

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

    let pack_info = vec![
        PackDbInfo {
            id: Some(1),
            clear_quest_count: Some(1),
            is_pack_complete: Some(false),
            quest_level: Some(0),
            quest_opt: Some(0),
            sub_quest_count: Some(0),
            active_time: Some(0),
            is_buy: Some(true),
        },
        PackDbInfo {
            id: Some(3007),
            clear_quest_count: Some(1),
            is_pack_complete: Some(false),
            quest_level: Some(0),
            quest_opt: Some(0),
            sub_quest_count: Some(0),
            active_time: Some(0),
            is_buy: Some(false),
        },
    ];

    let quest_level_info = vec![];

    let pack_clear_reward_info = vec![];

    let evil_castle_clear_reward_info = vec![];

    let response = PackInfoResponse {
        pack_info,
        quest_level_info,
        pack_clear_reward_info,
        evil_castle_clear_reward_info,
    };

    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::PackInfo.info();
    GameResponse::success(route, &resp_bytes, code).with_notify(&notify)
}
