use crate::logic::{EOperator, ESystem};

use super::*;

use data::tables;

pub async fn on_get_tips_info(
    _session: &NetSession,
    _player: &mut Player,
    req: GetTipsInfoCsReq,
) -> NetResult<GetTipsInfoScRsp> {
    Ok(GetTipsInfoScRsp {
        retcode: Retcode::RetSucc.into(),
        tips_info: Some(TipsInfo::default()),
        r#type: req.r#type, // tips group type
    })
}

pub async fn on_get_client_systems_info(
    _session: &NetSession,
    player: &mut Player,
    _req: GetClientSystemsInfoCsReq,
) -> NetResult<GetClientSystemsInfoScRsp> {
    Ok(GetClientSystemsInfoScRsp {
        retcode: Retcode::RetSucc.into(),
        info: Some(ClientSystemsInfo {
            post_girl_data: Some(PostGirlData {
                selected_post_girl_id_list: tables::post_girl_config_template_tb::iter()
                    .map(|template| template.id.value())
                    .collect(),
                post_girl_list: tables::post_girl_config_template_tb::iter()
                    .map(|template| PostGirlItem {
                        template_id: template.id.value(),
                        unlock_time: 1000,
                    })
                    .collect(),
                ..Default::default()
            }),
            unlock_data: Some(player.lock_model.to_client()),
            hbhfjgbahgf: Some(Aboegnnepmi::default()),
            ..Default::default()
        }),
    })
}

pub async fn on_get_news_stand_data(
    _session: &NetSession,
    _player: &mut Player,
    _req: GetNewsStandDataCsReq,
) -> NetResult<GetNewsStandDataScRsp> {
    Ok(GetNewsStandDataScRsp {
        retcode: Retcode::RetSucc.into(),
        news_stand_data: Some(NewsStandData::default()),
    })
}

pub async fn on_news_stand_seen(
    _session: &NetSession,
    _player: &mut Player,
    _req: NewsStandSeenCsReq,
) -> NetResult<NewsStandSeenScRsp> {
    Ok(NewsStandSeenScRsp {
        retcode: Retcode::RetSucc.into(),
    })
}

pub async fn on_get_trashbin_hermit_data(
    _session: &NetSession,
    _player: &mut Player,
    _req: GetTrashbinHermitDataCsReq,
) -> NetResult<GetTrashbinHermitDataScRsp> {
    Ok(GetTrashbinHermitDataScRsp {
        retcode: Retcode::RetSucc.into(),
        trashbin_hermit_data: Some(TrashbinHermitData::default()),
    })
}

pub async fn on_get_exploration_data(
    _session: &NetSession,
    _player: &mut Player,
    _req: GetExplorationDataCsReq,
) -> NetResult<GetExplorationDataScRsp> {
    Ok(GetExplorationDataScRsp {
        retcode: Retcode::RetSucc.into(),
        ..Default::default()
    })
}

pub async fn on_report_ui_layout_platform(
    _session: &NetSession,
    _player: &mut Player,
    _req: ReportUiLayoutPlatformCsReq,
) -> NetResult<ReportUiLayoutPlatformScRsp> {
    Ok(ReportUiLayoutPlatformScRsp {
        retcode: Retcode::RetSucc.into(),
    })
}

pub async fn on_unlock_newbie_group(
    _session: &NetSession,
    _player: &mut Player,
    req: UnlockNewbieGroupCsReq,
) -> NetResult<UnlockNewbieGroupScRsp> {
    Ok(UnlockNewbieGroupScRsp {
        retcode: Retcode::RetSucc.into(),
        group_id: req.group_id,
    })
}

pub async fn on_battle_report(
    _session: &NetSession,
    _player: &mut Player,
    _req: BattleReportCsReq,
) -> NetResult<BattleReportScRsp> {
    Ok(BattleReportScRsp {
        retcode: Retcode::RetSucc.into(),
    })
}

pub async fn on_player_operation(
    _session: &NetSession,
    _player: &mut Player,
    req: PlayerOperationCsReq,
) -> NetResult<PlayerOperationScRsp> {
    tracing::info!(
        "PlayerOperation(system={:?}, operator={:?}, param={})",
        ESystem::from(req.system),
        EOperator::from(req.operator),
        req.param
    );

    Ok(PlayerOperationScRsp {
        retcode: Retcode::RetSucc.into(),
    })
}

pub async fn on_player_system_parameter_change(
    _session: &NetSession,
    _player: &mut Player,
    req: PlayerSystemParameterChangeCsReq,
) -> NetResult<PlayerSystemParameterChangeScRsp> {
    tracing::info!(
        "PlayerSystemParameterChange(type={}, param={})",
        req.r#type,
        req.params,
    );

    Ok(PlayerSystemParameterChangeScRsp {
        retcode: Retcode::RetSucc.into(),
    })
}

pub async fn on_pop_up_window_seen(
    _session: &NetSession,
    _player: &mut Player,
    req: PopUpWindowSeenCsReq,
) -> NetResult<PopUpWindowSeenScRsp> {
    Ok(PopUpWindowSeenScRsp {
        retcode: Retcode::RetSucc.into(),
        popup_group_id_list: req.popup_group_id_list,
    })
}

pub async fn on_report_system_settings_change(
    _session: &NetSession,
    _player: &mut Player,
    req: ReportSystemSettingsChangeCsReq,
) -> NetResult<ReportSystemSettingsChangeScRsp> {
    tracing::info!("system settings change {req:?}");

    Ok(ReportSystemSettingsChangeScRsp {
        retcode: Retcode::RetSucc.into(),
    })
}

pub async fn on_interact_with_scene_object(
    _session: &NetSession,
    _player: &mut Player,
    _req: InteractWithSceneObjectCsReq,
) -> NetResult<InteractWithSceneObjectScRsp> {
    // this request is used for interaction with STATIC scene objects (not controlled by server, e.g. door in workshop)
    Ok(InteractWithSceneObjectScRsp {
        retcode: Retcode::RetSucc.into(),
    })
}
