%%% -------------------------------------------------------
%%% @author huangyongxing@yeah.net
%%% @doc
%%% @end
%%% -------------------------------------------------------
-module(cli_pt_200).
-export([
        encode/2
        , decode/2
    ]).

%% 数据封包

%% 攻击
encode(20001, [HitMonIds, HitRoleIds, SkillId, AttX, AttY, AttAngle]) ->
    FunWriteMon = fun(MonId) -> <<MonId:32>> end,
    FunWriteRole = fun(RoleId) -> <<RoleId:64>> end,
    HitMonsBin = pt:write_array(FunWriteMon, HitMonIds),
    HitRolesBin = pt:write_array(FunWriteRole, HitRoleIds),
    AttObjId = 0,
    SkillStage = 1,
    MainType = 0,   % 0人1怪
    {ok, <<HitMonsBin/binary, HitRolesBin/binary, SkillId:32, AttX:16, AttY:16,
        AttAngle:32, AttObjId:32, SkillStage:8, MainType:8>>
    };

%% 复活
encode(20004, [Type]) ->
    {ok, <<Type:8>>};

encode(_Cmd, _Data) ->
    {error, unknown_data}.

%% 数据解包

%% 被杀通知
decode(20013, _Bin) ->
    % <<AttSign:8, RestBin1/binary>> = _Bin,
    % {Name, RestBin2} = pt:read_string(RestBin1),
    % <<PkValue:16, BGold:8, Lv:16, Turn:8, AttId:64, Seconds:16, _/binary>> = RestBin2,
    {ok, []};

decode(_Cmd, _BinData) ->
    ignore.

