%%%-------------------------------------------------------------------
%%% author : ljy
%%% desc   : 舞姿
%%% Time   : 2021.04.08
%%%-------------------------------------------------------------------
-module(pp_dance).
-author("ljy").

-export([handle/3]).
-include("server.hrl").
-include("errcode.hrl").
-include("common.hrl").

%% 舞姿总览
handle(42500, Player, _) ->
    lib_dance:dance_show(Player),
    ok;

%% 舞姿激活
handle(42501, Player, [DanceId]) ->
    case lib_dance:dance_activate(Player, DanceId) of
        {ok, NewPlayer} ->
            ErrCode = ?SUCCESS;
        {false, ErrCode} ->
            NewPlayer = Player
    end,
    {ok, Bin} = pt_425:write(42501, [ErrCode, DanceId]),
    lib_server_send:send_to_sid(Player#player_status.sid, Bin),
    {ok, NewPlayer};

%% 切换舞姿动作
handle(42502, Player, [DanceId]) ->
    case lib_dance:dance_switch(Player, DanceId) of
        {ok, NewPlayer} ->
            ErrCode = ?SUCCESS;
        {false, ErrCode} ->
            NewPlayer = Player
    end,
    {ok, Bin} = pt_425:write(42502, [ErrCode, DanceId]),
    lib_server_send:send_to_sid(Player#player_status.sid, Bin),
    {ok, NewPlayer};

%% 随机舞姿
handle(42503, Player, [Type]) when Type == 0 orelse Type == 1 ->
    lib_dance:dance_rand(Player, Type);

%% 进入晚宴、舞池时发送，用于判断是否随机舞姿
handle(42504, Player, []) ->
    lib_dance:enter_dance_state(Player);

handle(Cmd, _Ps, Args) ->
    ?ERR("pp_dance cmd unmatch ~p ~p", [Cmd, Args]),
    ok.

