%% ---------------------------------------------------------------------------
%% @doc 巅峰竞技本服管理进程
%% @author hek
%% @since  2016-11-14
%% @deprecated
%% ---------------------------------------------------------------------------
-module(mod_top_pk_local).
-behaviour(gen_server).
-include("common.hrl").
-include("top_pk.hrl").
-include("def_gen_server.hrl").

%% API
-export([start_link/0, apply_cast/1, daily_update/0, advance/0]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).

start_link() ->
    gen_server:start_link({local,?MODULE}, ?MODULE, [], []).
apply_cast(Msg) ->
    gen_server:cast(?MODULE, Msg).
daily_update() ->
    gen_server:cast(?MODULE, {'daily_update', none}).
advance() ->
    gen_server:cast(?MODULE, 'advance').

init(Args) ->
    ?DO_INIT(Args).
handle_call(Request, From, State) ->
    ?DO_HANDLE_CALL(Request, From, State).
handle_cast(Msg, State) ->
    ?DO_HANDLE_CAST(Msg, State).
handle_info(Info, State) ->
    ?DO_HANDLE_INFO(Info, State).
terminate(Reason, State) ->
    ?DO_TERMINATE(Reason, State).
code_change(OldVsn, State, Extra) ->
    ?DO_CODE_CHANGE(OldVsn, State, Extra).

do_init([]) ->
    {ok, State} = lib_top_pk_local_mod:init(),
    {ok, State}.
do_handle_call(_Request, _From, State) ->
    {reply, ok, State}.

do_handle_cast({'sync_rank_info', Msg}, State) ->
    {ok, NewState} = lib_top_pk_local_mod:sync_rank_info(State, Msg),
    {noreply, NewState};
do_handle_cast({'daily_update', FromSource}, State) ->
    {ok, NewState} = lib_top_pk_local_mod:daily_update(State, FromSource),
    {noreply, NewState};
do_handle_cast({'start_local_new_season', SeasonId},State) ->
    {ok, NewState} = lib_top_pk_local_mod:start_local_new_season(State, SeasonId),
    {noreply, NewState};
do_handle_cast('advance', State) ->
    {ok, NewState} = lib_top_pk_local_mod:advance(State),
    {noreply, NewState};
do_handle_cast({'act_start', Args}, State) ->
    lib_top_pk_local_mod:act_start(State, Args),
    {noreply, State};
do_handle_cast({'local_sync_act_status', Status}, State) ->
    {ok, NewState} = lib_top_pk_local_mod:local_sync_act_status(State, Status),
    {noreply, NewState};
do_handle_cast({'center_sync_act_status', Status}, State) ->
    {ok, NewState} = lib_top_pk_local_mod:center_sync_act_status(State, Status),
    {noreply, NewState};
do_handle_cast({'enter_match', Node, RoleId, Args}, State) ->
    lib_top_pk_local_mod:enter_match(State, Node, RoleId, Args),
    {noreply, State};
do_handle_cast({'get_rank_info', PlayerId, Page, PageSize}, State) ->
    lib_top_pk_local_mod:get_rank_info(State, PlayerId, Page, PageSize),
    {noreply, State};
do_handle_cast({'send_local_rank_reward', RoleId, RankId, Score}, State) ->
    lib_top_pk_local_mod:send_local_rank_reward(State, RoleId, RankId, Score),
    {noreply, State};
do_handle_cast({'refresh_rank', RankRole}, State) ->
    {ok, NewState} = lib_top_pk_local_mod:refresh_rank(State, RankRole),
    {noreply, NewState};
do_handle_cast({'update_role', RoleId, KeyValueList}, State) ->
    {ok, NewState} = lib_top_pk_local_mod:update_role(State, RoleId, KeyValueList),
    {noreply, NewState};
do_handle_cast({'gm_start', Time}, State) ->
    {ok, NewState} = lib_top_pk_local_mod:gm_start(State, Time),
    {noreply, NewState};
do_handle_cast({'gm_end'}, State) ->
    {ok, NewState} = lib_top_pk_local_mod:gm_end(State),
    {noreply, NewState};
do_handle_cast({'gm_season_end'}, State) ->
    {ok, NewState} = lib_top_pk_local_mod:gm_season_end(State),
    {noreply, NewState};
do_handle_cast(_Msg, State) ->
    {noreply, State}.
do_handle_info(_Info, State) ->
    {noreply, State}.
do_terminate(_Reason, _State) ->
    ok.
do_code_change(_OldVsn, State, _Extra) ->
    {ok, State}.

%% --------------------------------------------------------------------------
%%% Internal functions
%% --------------------------------------------------------------------------

