-module(pt_408).
-include("common.hrl").
-export([
        read/2,
        write/2
    ]).

read(40801, _) ->
    {ok, []};
read(40802, _) ->
    {ok, []};
read(40803, _) ->
    {ok, []};
read(40806, _) ->
    {ok, []};
read(40808, Bin0) ->
    <<SupportedId:64, _Bin1/binary>> = Bin0, 
    {ok, [SupportedId]};
read(40809, Bin0) ->
    <<SupportSid:64, _Bin1/binary>> = Bin0, 
    {ok, [SupportSid]};
read(40810, _) ->
    {ok, []};
read(_Cmd, _R) -> {error, no_match}.

write (40801,[
    State,
    EndTime,
    Type
] = Src_Data) ->
    Data = <<
        State:8,
        EndTime:32,
        Type:8
    >>,
    {ok, pt:encode(40801, Data, Src_Data)};

write (40802,[
    Count
] = Src_Data) ->
    Data = <<
        Count:8
    >>,
    {ok, pt:encode(40802, Data, Src_Data)};

write (40803,[
    Count1,
    TotalCount
] = Src_Data) ->
    Data = <<
        Count1:8,
        TotalCount:8
    >>,
    {ok, pt:encode(40803, Data, Src_Data)};

write (40804,[
    State,
    Type
] = Src_Data) ->
    Data = <<
        State:8,
        Type:8
    >>,
    {ok, pt:encode(40804, Data, Src_Data)};

write (40805,[
] = Src_Data) ->
    Data = <<
    >>,
    {ok, pt:encode(40805, Data, Src_Data)};

write (40806,[
    Count
] = Src_Data) ->
    Data = <<
        Count:8
    >>,
    {ok, pt:encode(40806, Data, Src_Data)};

write (40807,[
    BossId,
    Index,
    RoleId,
    Name,
    Hurt
] = Src_Data) ->
    Bin_Name = pt:write_string(Name), 

    Data = <<
        BossId:32,
        Index:16,
        RoleId:64,
        Bin_Name/binary,
        Hurt:64
    >>,
    {ok, pt:encode(40807, Data, Src_Data)};

write (40808,[
    Errcode,
    MonId
] = Src_Data) ->
    Data = <<
        Errcode:8,
        MonId:64
    >>,
    {ok, pt:encode(40808, Data, Src_Data)};

write (40809,[
    Errcode,
    SupportSid
] = Src_Data) ->
    Data = <<
        Errcode:32,
        SupportSid:64
    >>,
    {ok, pt:encode(40809, Data, Src_Data)};

write (40810,[
    Errcode
] = Src_Data) ->
    Data = <<
        Errcode:32
    >>,
    {ok, pt:encode(40810, Data, Src_Data)};

write (40811,[
    Type,
    SupportSid,
    SupportCfgId,
    Figure,
    Status,
    BossId,
    ShowTime
] = Src_Data) ->
    Bin_Figure = pt:write_figure(Figure), 

    Data = <<
        Type:8,
        SupportSid:64,
        SupportCfgId:16,
        Bin_Figure/binary,
        Status:8,
        BossId:32,
        ShowTime:32
    >>,
    {ok, pt:encode(40811, Data, Src_Data)};

write (40812,[
    SupportSid
] = Src_Data) ->
    Data = <<
        SupportSid:64
    >>,
    {ok, pt:encode(40812, Data, Src_Data)};

write(_Cmd, _R) -> ?DEBUG("no_match:~p,~p~n", [_Cmd, _R]), {ok, pt:pack(0, <<>>)}.


