%%%--------------------------------------
%%% @Module  : lib_draw_record_api.
%%% @Author  : lhy
%%% @Created : 2019-06-04
%%% @Description:  定制活动抽奖记录
%%%--------------------------------------

-module(lib_draw_record_api).
-include("custom_act.hrl").
-include("figure.hrl").
-include("predefine.hrl").
-include("role.hrl").
-include("server.hrl").
-include("common.hrl").
-include("goods.hrl").
-include("custom_act_draw_record.hrl").

-export([
        %% 通用接口
         refresh_local_draw_record/4       %% 刷新本服抽奖记录 本服活动
        ,refresh_kf_draw_record_local/4    %% 刷新个人记录(本服节点) 跨服活动抽奖记录
        ,refresh_kf_draw_record/4          %% 刷新跨服抽奖记录(跨服节点) 跨服活动抽奖记录
        ,get_upper_limit_length/2          %% 自定义活动抽奖记录的长度

	    %% 本服活动 自定义配置
        ,get_local_act_list/0            %% 本服活动
        ,get_record_config_local/3       %% 根据活动类型配置本服记录的记录条件


	    %% 跨服活动 自定义配置
        ,get_kf_zone_act_list/0          %% 跨服活动(分区)
        ,get_kf_whole_act_list/0         %% 跨服活动(全服)
]).

%% --------------------------------------------- 本服活动必要自定义接口配置 ------------------------------------------------------------
%% ！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
%% 本服活动 注:本服活动记录抽奖记录需在此加上主活动类型 用于清除活动数据 ！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
get_local_act_list() ->
    [
      ?CUSTOM_ACT_TYPE_JOY_WISH
    ].

%% ---------------------------------------------------------------------------
%% 自定义刷新本服记录的记录限制条件(个人记录不受限制)
-spec get_record_config_local(Type, SubType, GradeId) -> Res when
    Type        :: integer(),    %% 活动主类型
    SubType     :: integer(),    %% 活动子类型
    GradeId     :: integer(),    %% 奖励档次id
    Res         :: true | false.
%% ---------------------------------------------------------------------------
get_record_config_local(?CUSTOM_ACT_TYPE_JOY_WISH = Type, SubType, GradeId ) ->
    lib_joy_wish_act:get_record_config_local(Type, SubType, GradeId);
get_record_config_local(_Type, _SubType, _GradeId) -> true.

%% ---------------------------------------------- 跨服活动必要自定义接口配置 -----------------------------------------------------------
%% ！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
%% 注: 1.跨服活动记录抽奖记录需在此加上主活动类型
%%     2.需在custom_act.hrl(?KF_CUSTOM_ACT_TYPE)定义跨服类型用于活动结束清除数据
%% 跨服分区活动
get_kf_zone_act_list() ->
    [
    ].

%% 跨服全服活动
get_kf_whole_act_list() ->
    [].

%% ---------------------------------------------- 通用接口 ------------------------------------------------------------
%% ---------------------------------------------------------------------------
%% @doc 刷新本服抽奖记录 本服活动
-spec refresh_local_draw_record(PlayerInfo, Type, SubType, GradeIdList) -> Res when
    PlayerInfo  :: integer() | #player_status{},    %% 玩家Id或者玩家记录
    Type        :: integer(),    %% 活动主类型
    SubType     :: integer(),    %% 活动子类型
    GradeIdList :: [integer()],     %% 奖励档次id列表
    Res         :: {ok, #player_status{}}.   %% 返回玩家记录
%% ---------------------------------------------------------------------------
refresh_local_draw_record(RoleId, Type, SubType, GradeIdList) when is_integer(RoleId) ->
    lib_player:apply_cast(RoleId, ?APPLY_CAST_STATUS, lib_draw_record, refresh_local_draw_record, [Type, SubType, GradeIdList]);
refresh_local_draw_record(PS, Type, SubType, GradeIdList) when is_record(PS, player_status) ->
    lib_draw_record:refresh_local_draw_record(PS, Type, SubType, GradeIdList).

%% ---------------------------------------------------------------------------
%% @doc 刷新个人记录(本服节点) 跨服活动抽奖记录
-spec refresh_kf_draw_record_local(PlayerInfo, Type, SubType, GradeIdList) -> Res when
    PlayerInfo  :: integer() | #player_status{},    %% 玩家Id或者玩家记录
    Type        :: integer(),    %% 活动主类型
    SubType     :: integer(),    %% 活动子类型
    GradeIdList :: [integer()],     %% 奖励档次id列表
    Res         :: {ok, #player_status{}}.   %% 返回玩家记录
%% ---------------------------------------------------------------------------
refresh_kf_draw_record_local(RoleId, Type, SubType, GradeIdList) when is_integer(RoleId) ->
    lib_player:apply_cast(RoleId, ?APPLY_CAST_STATUS, lib_draw_record, refresh_kf_draw_record_local, [Type, SubType, GradeIdList]);
refresh_kf_draw_record_local(PS, Type, SubType, GradeIdList) when is_record(PS, player_status) ->
    lib_draw_record:refresh_kf_draw_record_local(PS, Type, SubType, GradeIdList).

%% ---------------------------------------------------------------------------
%% @doc 刷新跨服抽奖记录(跨服节点) 跨服活动抽奖记录
-spec refresh_kf_draw_record(PlayerInfo, Type, SubType, GradeIdList) -> Res when
    PlayerInfo  :: integer() | #player_status{},    %% 玩家Id或者玩家记录
    Type        :: integer(),    %% 活动主类型
    SubType     :: integer(),    %% 活动子类型
    GradeIdList :: [integer()],     %% 奖励档次id列表
    Res         :: {ok, #player_status{}}.   %% 返回玩家记录
%% ---------------------------------------------------------------------------
refresh_kf_draw_record(RoleId, Type, SubType, GradeIdList) when is_integer(RoleId) ->
    lib_player:apply_cast(RoleId, ?APPLY_CAST_STATUS, lib_draw_record, refresh_kf_draw_record, [Type, SubType, GradeIdList]);
refresh_kf_draw_record(PS, Type, SubType, GradeIdList) when is_record(PS, player_status) ->
    lib_draw_record:refresh_kf_draw_record(PS, Type, SubType, GradeIdList).

%% ---------------------------------------------------------------------------
%% @doc 自定义活动抽奖记录的长度
-spec get_upper_limit_length(Type, SubType) -> Res when
    Type        :: integer(),   %% 活动主类型
    SubType     :: integer(),   %% 活动子类型
    Res         :: integer().   %% 抽奖记录的长度上限
%% ---------------------------------------------------------------------------
get_upper_limit_length(?CUSTOM_ACT_TYPE_JOY_WISH, _SubType) -> ?WISH_RECORD_NUM_LIMIT;
get_upper_limit_length(_Type, _SubType) -> 20.
