%%%-------------------------------------------------------------------
%%% @author liushl
%%% @doc
%%%     靓丽大赛-协议入口
%%% @end
%%%-------------------------------------------------------------------
-module(pp_beauty_contest).
-author("liushl").

-include("server.hrl").
-include("beauty_contest.hrl").
-include("errcode.hrl").
-include("def_module.hrl").
-include("figure.hrl").
%% API
-export([]).
-compile(export_all).

%% 靓丽大赛:活动数据
handle(_Cmd = 41600, Player, _) ->
    beauty_contest:get_act_state(Player#player_status.sid),
    ok;
%% 靓丽大赛:报名数据
handle(_Cmd = 41601, Player, _) ->
    beauty_contest:get_sign_state(Player#player_status.id),
    ok;
%% 靓丽大赛:个人数据
handle(_Cmd = 41602, Player, _) ->
    beauty_contest:get_my_info(Player#player_status.id),
    ok;
%% 靓丽大赛:报名
handle(_Cmd = 41603, Player, _) ->
    beauty_contest:sign_up(Player#player_status.id, Player#player_status.figure#figure.name, lib_fashion:get_fashion_power(Player)),
    ok;
%% 靓丽大赛:榜单
handle(_Cmd = 41605, Player, _) ->
    beauty_contest:get_rank_info(Player#player_status.sid),
    ok;
%% 靓丽大赛:投票候选
handle(_Cmd = 41606, Player, _) ->
    beauty_contest:get_vote_candidate(Player#player_status.id),
    ok;
%% 靓丽大赛:投票
handle(_Cmd = 41607, Player, [VoteRole]) ->
    DailyVote = lib_daily:get_count(Player#player_status.id, ?MOD_BC, ?BC_COUNTER_DAILY_VOTE),
    beauty_contest:vote(Player#player_status.id, VoteRole, DailyVote),
    ok;
%% 靓丽大赛:投票记录
handle(Cmd = 41608, Player, _) ->
    #player_status{
        sid = Sid,
        beauty_contest = #role_beauty_contest{
            vote_log = VoteLog
        }
    } = Player,
    {ok, Bin} = pt_416:write(Cmd, [VoteLog]),
    lib_server_send:send_to_sid(Sid, Bin),
    ok;
%% 靓丽大赛:上期排名
handle(_Cmd = 41609, Player, _) ->
    beauty_contest:get_log_info(Player#player_status.sid),
    ok;
%% 靓丽大赛:调整外观
handle(Cmd = 41610, Player, [CData]) ->
    case beauty_contest_api:check_contest_data(Player, CData) of
        true  -> beauty_contest:update_contest_data(Player#player_status.id, CData);
        {false, _Error} ->
            {ok, Bin} = pt_416:write(Cmd, [?ERRCODE(err416_look_lock)]),
            lib_server_send:send_to_sid(Player#player_status.sid, Bin)
    end,
    ok;
%% 靓丽大赛:今日投票次数
handle(Cmd = 41611, Player, _) ->
    DailyVote = lib_daily:get_count(Player#player_status.id, ?MOD_BC, ?BC_COUNTER_DAILY_VOTE),
    {ok, Bin} = pt_416:write(Cmd, [DailyVote]),
    lib_server_send:send_to_sid(Player#player_status.sid, Bin),
    ok;

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