Exemple #1
0
def enter_friend_home(uid, f_id):
    island_logic.refresh_income_info(f_id)
    # 需要记录谁进来了
    hero_action = HeroAction(f_id)
    f_action = FormationAction(f_id)
    res = {
        'id': f_id,
        'heroes': hero_action.get_model_info(),
        'formation': f_action.get_model_info(),
    }
    return res
Exemple #2
0
def get_user_data(open_id, open_key, platform):
    start_time = time.time()
    platform_info = platform_logic.get_user_info_by_platform(open_id, open_key)
    if platform_info is False:
        return False
    # 需要获得一个用户的游戏里的唯一ID
    a_action = AccountAction('')
    game_user_id = a_action.get_model_info_by_id(open_id, platform)
    if game_user_id is False:
        game_user_id = a_action.create_model(open_id, platform)
    uid = game_user_id
    print('game_user_id', game_user_id)
    # 当日首次登陆的检查
    note_model = NoteModel(uid)
    last_refresh_time = note_model.get_login_time()
    cur_time = time.time()
    today_zero_time = cur_time - cur_time % 86400 + time.timezone
    if last_refresh_time < today_zero_time:
        note_model.set_login_time()
        # 刷新体力
        user_logic.refresh_vit(uid)
    # 刷新收入
    island_logic.refresh_income_info(uid)

    refresh_config = {
        'income': 60,  # 收入刷新的间隔
        'vit': 3600,  # 体力刷新的时间
    }
    r_action = RecordAction(uid)
    r_info = r_action.get_model_info()
    res = {
        'game_user_id': uid,
        'user': platform_info,
        'userInfo': user_logic.get_user_info(uid),
        'inventory': inventory_logic.get_inventory_info(uid),
        'note': machine_logic.get_note_info(uid),
        'rank': rank_logic.get_rank_info(uid, open_key, platform),
        'formation': formation_logic.get_formation_info(uid),
        'artifact': artifact_logic.get_artifact_info(uid),
        'pve': pve_logic.get_pve_info(uid),
        'mail': mail_logic.get_mail_info(uid),
        'refresh': refresh_config,
        'record': r_info,
        'task': task_logic.get_task_info(uid),
    }
    print('get_user_data cost time', time.time() - start_time)
    return res
Exemple #3
0
def refresh_income_info(request):
    if request.method == "GET":
        try:
            uid = request.query_params.get('uid')
        except Exception as e:
            print(e)
            return 1, "参数错误"
    try:
        data = island_logic.refresh_income_info(uid)
        return 0, data
    except Exception as e:
        print(e)
        return 1, "数据错误"
Exemple #4
0
def get_user_test(open_id, open_key, platform):
    start_time = time.time()
    platform_info = platform_logic.get_user_info_by_platform(open_id, open_key)
    if platform_info is False:
        return False
    time_str_0 = time.time()
    # 需要获得一个用户的游戏里的唯一ID
    a_action = AccountAction('')
    game_user_id = a_action.get_model_info_by_id(open_id, platform)
    if game_user_id is False:
        game_user_id = a_action.create_model(open_id, platform)
    uid = game_user_id
    time_str_1 = time.time()
    # 当日首次登陆的检查
    note_model = NoteModel(uid)
    last_refresh_time = note_model.get_login_time()
    cur_time = time.time()
    today_zero_time = cur_time - cur_time % 86400 + time.timezone
    if last_refresh_time < today_zero_time:
        note_model.set_login_time()
        # 刷新体力
        user_logic.refresh_vit(uid)
    # 刷新收入
    island_logic.refresh_income_info(uid)

    refresh_config = {
        'income': 60,  # 收入刷新的间隔
        'vit': 3600,  # 体力刷新的时间
    }
    r_action = RecordAction(uid)
    r_info = r_action.get_model_info()
    time_str_2 = time.time()
    user_info = user_logic.get_user_info(uid)
    inventory = inventory_logic.get_inventory_info(uid)
    note_info = machine_logic.get_note_info(uid)
    time_str_3 = time.time()
    ran_info = rank_logic.get_rank_info(uid, open_key)
    time_str_4 = time.time()
    formation_info = formation_logic.get_formation_info(uid)
    artifact_info = artifact_logic.get_artifact_info(uid)
    pve_info = pve_logic.get_pve_info(uid)
    mail_info = mail_logic.get_mail_info(uid)
    task_info = task_logic.get_task_info(uid)
    time_str_5 = time.time()
    res = {
        'game_user_id': uid,
        'user': platform_info,
        'user_info': user_info,
        'inventory': inventory,
        'note': note_info,
        'rank': ran_info,
        'formation': formation_info,
        'artifact': artifact_info,
        'pve': pve_info,
        'mail': mail_info,
        'refresh': refresh_config,
        'record': r_info,
        'task': task_info,
    }
    print('step0', time_str_0 - start_time)
    print('step1', time_str_1 - time_str_0)
    print('step2', time_str_2 - time_str_1)
    print('step3', time_str_3 - time_str_2)
    print('step4', time_str_4 - time_str_3)
    print('step5', time_str_5 - time_str_4)
    print('get_user_data cost time', time.time() - start_time)
    return res