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

%% 数据封包

%% 获取角色信息
encode(13001, []) ->
    {ok, <<>>};

encode(13012, [SetPkState]) ->
    {ok, <<SetPkState:8>>};

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

%% 数据解包

decode(13001, Bin) ->
    <<_RoleId:64, RestBin1/binary>> = Bin,
    {_PlatName, RestBin2} = pt:read_string(RestBin1),
    <<ServerId:16, _ServerNum:16, RestBin3/binary>> = RestBin2,
    {_ServerName, RestBin4} = pt:read_string(RestBin3),
    {Figure, RestBin5} = cli_simu_proto:read_figure(RestBin4),
    {Hp, HpLim, Speed, Attr, RestBin6} = cli_simu_proto:read_battle_attr(RestBin5),
    <<SceneId:32, X:16, Y:16, _DunId:32, _Exp:64, _ExpMax:64,
    Gold:32, _GoldBind:32, _FGold:32, Coin:32, _Honour:32, _GuildCoin:32,
    _Power:32, _GuildId:64, RestBin7/binary>> = RestBin6,
    {_GuildName, RestBin8} = pt:read_string(RestBin7),
    <<_PkCdTime:16, _PkValue:16, _TeamId:32, _MateRoleId:64, _RegTime:32,
    _WearMate:64, _GodId:16, _Hp:64, _HpLim:64, _RestBinEnd/binary>> = RestBin8,
    {ok, [ServerId, Figure, SceneId, X, Y, Gold, Coin, Hp, HpLim, Speed, Attr]};

decode(_Cmd, _BinData) ->
    ignore.

