%%%-------------------------------------------------------------------
%%% @author liushl
%%% @doc
%%%     狂战领域
%%% @end
%%%-------------------------------------------------------------------
-module(pp_madness_land).
-author("liushl").

-include("server.hrl").
-include("guild.hrl").

%% API
-export([handle/3]).


%% 狂战领域:活动数据
handle(_Cmd = 41500, Player, _) ->
    madness_land:ask_madness_land_info(Player#player_status.sid),
    ok;

%% 狂战领域:请求进入
handle(Cmd = 41501, Player, _) ->
    case madness_land_api:ask_enter_madness_land(Player) of
        {false, Error} ->
            {ok, Bin} = pt_415:write(Cmd, [Error]),
            lib_server_send:send_to_sid(Player#player_status.sid, Bin);
        _ ->
            ok
    end;

%% 狂战领域:退出场景
handle(_Cmd = 41502, Player, _) ->
    {ok, madness_land_api:leave_scene(Player)};

%% 狂战领域:日志信息（个人排行：只推N个）
handle(_Cmd = 41506, Player, [Type]) when Type =:= 1 orelse Type =:= 2 ->
    madness_land:ask_role_rank(Player#player_status.id, Player#player_status.sid, Type),
    ok;

%% 狂战领域:日志信息（社团排行：只推N个）
handle(_Cmd = 41507, Player, [Type]) when Type =:= 1 orelse Type =:= 2  ->
    madness_land:ask_guild_rank(Type, Player#player_status.guild#status_guild.id, Player#player_status.sid),
    ok;

%% 狂战领域:活动信息
handle(Cmd = 41510, Player, _) ->
    Type = madness_land_api:get_act_type(),
    {ok, Bin} = pt_415:write(Cmd, [Type]),
    lib_server_send:send_to_sid(Player#player_status.sid, Bin);

%% 狂战领域:活动信息
handle(_Cmd = 41512, Player, _) ->
    madness_land:ask_role_score(Player#player_status.id, Player#player_status.sid, Player#player_status.scene),
    ok;

handle(Cmd, _Player, Data) ->
    erlang:display({"[LIUSHL]", erlang:localtime(), ?MODULE, ?LINE, Cmd, Data}),
    ok.
%%%===================================================================
%%% Internal functions
%%%===================================================================