import betterproto
from game_server.net.session import Session
from lib.proto import GetConfigReq, GetConfigRsp, GetConfigRspAntiCheatStageCheckConfig
from utils.time import get_unix_in_seconds
from pprint import pprint


async def handle(session: Session, msg: GetConfigReq) -> betterproto.Message:
    # rsp = GetConfigRsp(
    #     retcode=0,
    #     stamina_recover_config_time=360,
    #     same_type_power_up_rate=60,
    #     day_time_offset=120,
    #     server_cur_time=get_unix_in_seconds(),
    #     power_up_scoin_cost_rate=1684572830,
    #     max_friend_num=50,
    #     avatar_max_add_goodfeel=148,
    #     gacha_ticket_list=[1000],
    #     region_name="overseas01",
    #     discount_schedule_config_list=[25],
    #     stigmata_refine_value_back_percent=[8,16,100,1061660],
    #     scoin_convert_per_exp=[111,118,101,114,115,101,97,115,48,49],
    #     mp_reset_skill_hcoin_cost=26,
    #     mp_member_exhausted_drop_ratio=[8,4,16,600,24,1684353600,32,1686888000],
    #     friend_bond_level_config_list=[120],
    #     friend_assistant_add_bond=1599184800,
    #     armada_manage_mail_length=1599444000,
    #     armada_contact_length=2,
    #     armada_bulletin_length=999999999,
    #     openworld_judge_para_type1=500000000,
    #     openworld_judge_para_type4=7034,
    #     trial_avatar_player_min_level=5,
    #     disjoin_equipment_max_batch_num=86400,
    #     anti_cheat_stage_check_config=GetConfigRspAntiCheatStageCheckConfig(
    #         check_stage_id_list=[16295],
    #         check_stage_type_list=[4],
    #     ),
    #     is_can_gal_touch=[True,True,True,True],
    #     is_resistance_open=True,
    #     next_day_begin_time=get_unix_in_seconds() + (604800 // 7)
    # )
    byte_array = bytes.fromhex(
        "[encoded data, 24290 characters]"
    )

    ms = memoryview(byte_array)
    rsp = GetConfigRsp()
    rsp.parse(ms.tobytes())
    rsp.server_cur_time = get_unix_in_seconds()
    rsp.region_name = "overseas01"
    rsp.next_day_begin_time = int(get_unix_in_seconds() + 604800 / 7)

    stage_ids = [146033, 146056, 146077, 146078]
    for id in stage_ids:
        rsp.anti_cheat_stage_check_config.check_stage_id_list.append(id)

    return rsp
