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

read(61001, Bin0) ->
    <<DunId:32, Bin1/binary>> = Bin0, 
    <<Opty:8, _Bin2/binary>> = Bin1, 
    {ok, [DunId, Opty]};
read(61002, _) ->
    {ok, []};
read(61003, _) ->
    {ok, []};
read(61004, _) ->
    {ok, []};
read(61011, Bin0) ->
    <<DunId:32, _Bin1/binary>> = Bin0, 
    {ok, [DunId]};
read(61018, _) ->
    {ok, []};
read(61020, Bin0) ->
    <<DunType:8, _Bin1/binary>> = Bin0, 
    {ok, [DunType]};
read(61021, Bin0) ->
    <<DunId:32, Bin1/binary>> = Bin0, 
    <<Count:16, _Bin2/binary>> = Bin1, 
    {ok, [DunId, Count]};
read(61022, Bin0) ->
    <<DunId:32, Bin1/binary>> = Bin0, 
    <<AutoNum:16, Bin2/binary>> = Bin1, 
    <<CostType:8, _Bin3/binary>> = Bin2, 
    {ok, [DunId, AutoNum, CostType]};
read(61024, _) ->
    {ok, []};
read(61025, _) ->
    {ok, []};
read(61026, _) ->
    {ok, []};
read(61027, _) ->
    {ok, []};
read(61028, Bin0) ->
    <<DunType:8, Bin1/binary>> = Bin0, 
    <<Type:8, _Bin2/binary>> = Bin1, 
    {ok, [DunType, Type]};
read(61029, _) ->
    {ok, []};
read(61030, _) ->
    {ok, []};
read(61031, _) ->
    {ok, []};
read(61032, _) ->
    {ok, []};
read(61033, Bin0) ->
    <<ChapterId:8, Bin1/binary>> = Bin0, 
    <<StarNum:8, _Bin2/binary>> = Bin1, 
    {ok, [ChapterId, StarNum]};
read(61034, _) ->
    {ok, []};
read(61045, Bin0) ->
    <<DunId:32, Bin1/binary>> = Bin0, 
    <<Wave:16, _Bin2/binary>> = Bin1, 
    {ok, [DunId, Wave]};
read(61046, _) ->
    {ok, []};
read(61047, Bin0) ->
    <<Index:16, _Bin1/binary>> = Bin0, 
    {ok, [Index]};
read(61048, _) ->
    {ok, []};
read(61049, _) ->
    {ok, []};
read(61050, Bin0) ->
    <<Type:8, Bin1/binary>> = Bin0, 
    <<RewardArg:8, _Bin2/binary>> = Bin1, 
    {ok, [Type, RewardArg]};
read(61051, _) ->
    {ok, []};
read(61052, _) ->
    {ok, []};
read(61053, _) ->
    {ok, []};
read(61054, Bin0) ->
    <<PageSize:16, Bin1/binary>> = Bin0, 
    <<PageNo:16, _Bin2/binary>> = Bin1, 
    {ok, [PageSize, PageNo]};
read(61055, _) ->
    {ok, []};
read(61065, Bin0) ->
    <<DunId:32, _Bin1/binary>> = Bin0, 
    {ok, [DunId]};
read(61066, Bin0) ->
    <<DunType:8, _Bin1/binary>> = Bin0, 
    {ok, [DunType]};
read(61067, _) ->
    {ok, []};
read(61068, Bin0) ->
    <<DunType:8, Bin1/binary>> = Bin0, 
    <<Index:16, _Bin2/binary>> = Bin1, 
    {ok, [DunType, Index]};
read(61069, Bin0) ->
    <<DunId:32, _Bin1/binary>> = Bin0, 
    {ok, [DunId]};
read(61070, Bin0) ->
    <<DunId:32, _Bin1/binary>> = Bin0, 
    {ok, [DunId]};
read(61071, _) ->
    {ok, []};
read(61072, _) ->
    {ok, []};
read(61073, _) ->
    {ok, []};
read(61074, Bin0) ->
    <<DunId:32, _Bin1/binary>> = Bin0, 
    {ok, [DunId]};
read(61075, Bin0) ->
    <<Type:8, _Bin1/binary>> = Bin0, 
    {ok, [Type]};
read(61076, _) ->
    {ok, []};
read(61077, _) ->
    {ok, []};
read(61078, Bin0) ->
    <<BuffId:8, Bin1/binary>> = Bin0, 
    <<X:16, Bin2/binary>> = Bin1, 
    <<Y:16, _Bin3/binary>> = Bin2, 
    {ok, [BuffId, X, Y]};
read(61079, _) ->
    {ok, []};
read(61080, Bin0) ->
    <<DunId:32, _Bin1/binary>> = Bin0, 
    {ok, [DunId]};
read(61081, Bin0) ->
    <<DunId:32, _Bin1/binary>> = Bin0, 
    {ok, [DunId]};
read(61082, Bin0) ->
    <<DunId:32, Bin1/binary>> = Bin0, 
    <<Wave:16, _Bin2/binary>> = Bin1, 
    {ok, [DunId, Wave]};
read(61083, _) ->
    {ok, []};
read(61084, _) ->
    {ok, []};
read(61087, Bin0) ->
    <<DunId:32, _Bin1/binary>> = Bin0, 
    {ok, [DunId]};
read(61088, Bin0) ->
    <<Type:8, _Bin1/binary>> = Bin0, 
    {ok, [Type]};
read(61090, _) ->
    {ok, []};
read(61091, Bin0) ->
    <<Id:16, Bin1/binary>> = Bin0, 
    <<Num:8, _Bin2/binary>> = Bin1, 
    {ok, [Id, Num]};
read(61092, Bin0) ->
    <<Wave:32, _Bin1/binary>> = Bin0, 
    {ok, [Wave]};
read(61093, Bin0) ->
    <<Wave:32, _Bin1/binary>> = Bin0, 
    {ok, [Wave]};
read(61094, Bin0) ->
    <<MonId:32, _Bin1/binary>> = Bin0, 
    {ok, [MonId]};
read(61095, Bin0) ->
    <<MonId:32, _Bin1/binary>> = Bin0, 
    {ok, [MonId]};
read(61096, _) ->
    {ok, []};
read(61098, Bin0) ->
    <<Type:8, _Bin1/binary>> = Bin0, 
    {ok, [Type]};
read(61099, Bin0) ->
    <<DunId:32, _Bin1/binary>> = Bin0, 
    {ok, [DunId]};
read(_Cmd, _R) -> {error, no_match}.

write (61000,[
    ErrorCode,
    ErrorCodeArgs
] = Src_Data) ->
    Bin_ErrorCodeArgs = pt:write_string(ErrorCodeArgs), 

    Data = <<
        ErrorCode:32,
        Bin_ErrorCodeArgs/binary
    >>,
    {ok, pt:encode(61000, Data, Src_Data)};

write (61001,[
    DunId,
    SceneId,
    ErrorCode,
    ErrorCodeArgs,
    Opty
] = Src_Data) ->
    Bin_ErrorCodeArgs = pt:write_string(ErrorCodeArgs), 

    Data = <<
        DunId:32,
        SceneId:32,
        ErrorCode:32,
        Bin_ErrorCodeArgs/binary,
        Opty:8
    >>,
    {ok, pt:encode(61001, Data, Src_Data)};

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

write (61003,[
    Result,
    ResultSubtype,
    DunId,
    SceneId,
    Wave,
    RewardList,
    CustomActRewardList,
    ExData
] = Src_Data) ->
    Bin_RewardList = pt:write_object_list(RewardList), 

    Bin_CustomActRewardList = pt:write_object_list(CustomActRewardList), 

    BinList_ExData = [
        item_to_bin_0(ExData_Item) || ExData_Item <- ExData
    ], 

    ExData_Len = length(ExData), 
    Bin_ExData = list_to_binary(BinList_ExData),

    Data = <<
        Result:8,
        ResultSubtype:8,
        DunId:32,
        SceneId:32,
        Wave:16,
        Bin_RewardList/binary,
        Bin_CustomActRewardList/binary,
        ExData_Len:16, Bin_ExData/binary
    >>,
    {ok, pt:encode(61003, Data, Src_Data)};

write (61004,[
    SceneId,
    DunId,
    StartTime,
    EndTime,
    WaveNum,
    WaveStartTime,
    LevelEndTime
] = Src_Data) ->
    Data = <<
        SceneId:32,
        DunId:32,
        StartTime:32,
        EndTime:32,
        WaveNum:32,
        WaveStartTime:32,
        LevelEndTime:32
    >>,
    {ok, pt:encode(61004, Data, Src_Data)};

write (61005,[
    DunId,
    Wave,
    DieNum,
    Num
] = Src_Data) ->
    Data = <<
        DunId:32,
        Wave:16,
        DieNum:16,
        Num:16
    >>,
    {ok, pt:encode(61005, Data, Src_Data)};

write (61011,[
    LeftHelpCount,
    DunId
] = Src_Data) ->
    Data = <<
        LeftHelpCount:8,
        DunId:32
    >>,
    {ok, pt:encode(61011, Data, Src_Data)};

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

write (61020,[
    DunType,
    DunList
] = Src_Data) ->
    BinList_DunList = [
        item_to_bin_1(DunList_Item) || DunList_Item <- DunList
    ], 

    DunList_Len = length(DunList), 
    Bin_DunList = list_to_binary(BinList_DunList),

    Data = <<
        DunType:8,
        DunList_Len:16, Bin_DunList/binary
    >>,
    {ok, pt:encode(61020, Data, Src_Data)};

write (61021,[
    ErrorCode,
    DunId,
    BuyCount
] = Src_Data) ->
    Data = <<
        ErrorCode:32,
        DunId:32,
        BuyCount:16
    >>,
    {ok, pt:encode(61021, Data, Src_Data)};

write (61022,[
    ErrorCode,
    DunId,
    RewardList,
    CustomActRewardList,
    Result,
    ResultSubtype,
    Wave,
    ExData
] = Src_Data) ->
    Bin_RewardList = pt:write_object_list(RewardList), 

    Bin_CustomActRewardList = pt:write_object_list(CustomActRewardList), 

    BinList_ExData = [
        item_to_bin_3(ExData_Item) || ExData_Item <- ExData
    ], 

    ExData_Len = length(ExData), 
    Bin_ExData = list_to_binary(BinList_ExData),

    Data = <<
        ErrorCode:32,
        DunId:32,
        Bin_RewardList/binary,
        Bin_CustomActRewardList/binary,
        Result:8,
        ResultSubtype:8,
        Wave:16,
        ExData_Len:16, Bin_ExData/binary
    >>,
    {ok, pt:encode(61022, Data, Src_Data)};

write (61024,[
    DunList
] = Src_Data) ->
    BinList_DunList = [
        item_to_bin_4(DunList_Item) || DunList_Item <- DunList
    ], 

    DunList_Len = length(DunList), 
    Bin_DunList = list_to_binary(BinList_DunList),

    Data = <<
        DunList_Len:16, Bin_DunList/binary
    >>,
    {ok, pt:encode(61024, Data, Src_Data)};

write (61025,[
    ErrorCode,
    DunList
] = Src_Data) ->
    BinList_DunList = [
        item_to_bin_5(DunList_Item) || DunList_Item <- DunList
    ], 

    DunList_Len = length(DunList), 
    Bin_DunList = list_to_binary(BinList_DunList),

    Data = <<
        ErrorCode:32,
        DunList_Len:16, Bin_DunList/binary
    >>,
    {ok, pt:encode(61025, Data, Src_Data)};

write (61026,[
    Result,
    ResultSubtype,
    DunId,
    SceneId,
    PassTime,
    FirstRewardList,
    StarRewardList,
    Star
] = Src_Data) ->
    Bin_FirstRewardList = pt:write_object_list(FirstRewardList), 

    Bin_StarRewardList = pt:write_object_list(StarRewardList), 

    Data = <<
        Result:8,
        ResultSubtype:8,
        DunId:32,
        SceneId:32,
        PassTime:32,
        Bin_FirstRewardList/binary,
        Bin_StarRewardList/binary,
        Star:8
    >>,
    {ok, pt:encode(61026, Data, Src_Data)};

write (61027,[
    Result,
    ResultSubtype,
    DunId,
    SceneId,
    Rating,
    RewardList,
    CustomActRewardList,
    MonHurtRank
] = Src_Data) ->
    Bin_RewardList = pt:write_object_list(RewardList), 

    Bin_CustomActRewardList = pt:write_object_list(CustomActRewardList), 

    BinList_MonHurtRank = [
        item_to_bin_6(MonHurtRank_Item) || MonHurtRank_Item <- MonHurtRank
    ], 

    MonHurtRank_Len = length(MonHurtRank), 
    Bin_MonHurtRank = list_to_binary(BinList_MonHurtRank),

    Data = <<
        Result:8,
        ResultSubtype:8,
        DunId:32,
        SceneId:32,
        Rating:8,
        Bin_RewardList/binary,
        Bin_CustomActRewardList/binary,
        MonHurtRank_Len:16, Bin_MonHurtRank/binary
    >>,
    {ok, pt:encode(61027, Data, Src_Data)};

write (61028,[
    ErrorCode,
    Type,
    DunType
] = Src_Data) ->
    Data = <<
        ErrorCode:32,
        Type:8,
        DunType:8
    >>,
    {ok, pt:encode(61028, Data, Src_Data)};

write (61029,[
    TeamMate
] = Src_Data) ->
    BinList_TeamMate = [
        item_to_bin_7(TeamMate_Item) || TeamMate_Item <- TeamMate
    ], 

    TeamMate_Len = length(TeamMate), 
    Bin_TeamMate = list_to_binary(BinList_TeamMate),

    Data = <<
        TeamMate_Len:16, Bin_TeamMate/binary
    >>,
    {ok, pt:encode(61029, Data, Src_Data)};

write (61030,[
    Result,
    ResultSubtype,
    DunId,
    SceneId,
    RewardList,
    NewRec,
    MaxWave,
    Wave,
    MonHurtRank
] = Src_Data) ->
    Bin_RewardList = pt:write_object_list(RewardList), 

    BinList_MonHurtRank = [
        item_to_bin_8(MonHurtRank_Item) || MonHurtRank_Item <- MonHurtRank
    ], 

    MonHurtRank_Len = length(MonHurtRank), 
    Bin_MonHurtRank = list_to_binary(BinList_MonHurtRank),

    Data = <<
        Result:8,
        ResultSubtype:8,
        DunId:32,
        SceneId:32,
        Bin_RewardList/binary,
        NewRec:8,
        MaxWave:8,
        Wave:8,
        MonHurtRank_Len:16, Bin_MonHurtRank/binary
    >>,
    {ok, pt:encode(61030, Data, Src_Data)};

write (61031,[
    ReviveList
] = Src_Data) ->
    BinList_ReviveList = [
        item_to_bin_9(ReviveList_Item) || ReviveList_Item <- ReviveList
    ], 

    ReviveList_Len = length(ReviveList), 
    Bin_ReviveList = list_to_binary(BinList_ReviveList),

    Data = <<
        ReviveList_Len:16, Bin_ReviveList/binary
    >>,
    {ok, pt:encode(61031, Data, Src_Data)};

write (61032,[
    ChapterId,
    DunId,
    StarsList
] = Src_Data) ->
    BinList_StarsList = [
        item_to_bin_10(StarsList_Item) || StarsList_Item <- StarsList
    ], 

    StarsList_Len = length(StarsList), 
    Bin_StarsList = list_to_binary(BinList_StarsList),

    Data = <<
        ChapterId:8,
        DunId:32,
        StarsList_Len:16, Bin_StarsList/binary
    >>,
    {ok, pt:encode(61032, Data, Src_Data)};

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

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

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

write (61046,[
    DunId,
    WaveList
] = Src_Data) ->
    BinList_WaveList = [
        item_to_bin_11(WaveList_Item) || WaveList_Item <- WaveList
    ], 

    WaveList_Len = length(WaveList), 
    Bin_WaveList = list_to_binary(BinList_WaveList),

    Data = <<
        DunId:32,
        WaveList_Len:16, Bin_WaveList/binary
    >>,
    {ok, pt:encode(61046, Data, Src_Data)};

write (61047,[
    ErrorCode,
    Index,
    CurVal,
    SumVal,
    EndTime,
    Reset,
    LuckyList
] = Src_Data) ->
    BinList_LuckyList = [
        item_to_bin_12(LuckyList_Item) || LuckyList_Item <- LuckyList
    ], 

    LuckyList_Len = length(LuckyList), 
    Bin_LuckyList = list_to_binary(BinList_LuckyList),

    Data = <<
        ErrorCode:32,
        Index:16,
        CurVal:32,
        SumVal:32,
        EndTime:32,
        Reset:8,
        LuckyList_Len:16, Bin_LuckyList/binary
    >>,
    {ok, pt:encode(61047, Data, Src_Data)};

write (61048,[
    RewardList
] = Src_Data) ->
    BinList_RewardList = [
        item_to_bin_14(RewardList_Item) || RewardList_Item <- RewardList
    ], 

    RewardList_Len = length(RewardList), 
    Bin_RewardList = list_to_binary(BinList_RewardList),

    Data = <<
        RewardList_Len:16, Bin_RewardList/binary
    >>,
    {ok, pt:encode(61048, Data, Src_Data)};

write (61049,[
    DunId,
    RewardList
] = Src_Data) ->
    BinList_RewardList = [
        item_to_bin_15(RewardList_Item) || RewardList_Item <- RewardList
    ], 

    RewardList_Len = length(RewardList), 
    Bin_RewardList = list_to_binary(BinList_RewardList),

    Data = <<
        DunId:32,
        RewardList_Len:16, Bin_RewardList/binary
    >>,
    {ok, pt:encode(61049, Data, Src_Data)};

write (61050,[
    Errcode,
    Type,
    RewardArg,
    RewardList
] = Src_Data) ->
    BinList_RewardList = [
        item_to_bin_16(RewardList_Item) || RewardList_Item <- RewardList
    ], 

    RewardList_Len = length(RewardList), 
    Bin_RewardList = list_to_binary(BinList_RewardList),

    Data = <<
        Errcode:32,
        Type:8,
        RewardArg:8,
        RewardList_Len:16, Bin_RewardList/binary
    >>,
    {ok, pt:encode(61050, Data, Src_Data)};

write (61051,[
    MaxCount,
    UseCount,
    Time
] = Src_Data) ->
    Data = <<
        MaxCount:16,
        UseCount:16,
        Time:32
    >>,
    {ok, pt:encode(61051, Data, Src_Data)};

write (61052,[
    Time,
    OfflineExp,
    RestOfflineTime,
    TimeLast
] = Src_Data) ->
    Data = <<
        Time:32,
        OfflineExp:64,
        RestOfflineTime:32,
        TimeLast:32
    >>,
    {ok, pt:encode(61052, Data, Src_Data)};

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

write (61054,[
    PageTotal,
    PageNo,
    RankList
] = Src_Data) ->
    BinList_RankList = [
        item_to_bin_17(RankList_Item) || RankList_Item <- RankList
    ], 

    RankList_Len = length(RankList), 
    Bin_RankList = list_to_binary(BinList_RankList),

    Data = <<
        PageTotal:16,
        PageNo:16,
        RankList_Len:16, Bin_RankList/binary
    >>,
    {ok, pt:encode(61054, Data, Src_Data)};

write (61055,[
    MyRank,
    RankList
] = Src_Data) ->
    BinList_RankList = [
        item_to_bin_18(RankList_Item) || RankList_Item <- RankList
    ], 

    RankList_Len = length(RankList), 
    Bin_RankList = list_to_binary(BinList_RankList),

    Data = <<
        MyRank:16,
        RankList_Len:16, Bin_RankList/binary
    >>,
    {ok, pt:encode(61055, Data, Src_Data)};

write (61065,[
    DunId,
    InfoList
] = Src_Data) ->
    BinList_InfoList = [
        item_to_bin_19(InfoList_Item) || InfoList_Item <- InfoList
    ], 

    InfoList_Len = length(InfoList), 
    Bin_InfoList = list_to_binary(BinList_InfoList),

    Data = <<
        DunId:32,
        InfoList_Len:16, Bin_InfoList/binary
    >>,
    {ok, pt:encode(61065, Data, Src_Data)};

write (61066,[
    ErrorCode,
    DunType,
    SweepList
] = Src_Data) ->
    BinList_SweepList = [
        item_to_bin_20(SweepList_Item) || SweepList_Item <- SweepList
    ], 

    SweepList_Len = length(SweepList), 
    Bin_SweepList = list_to_binary(BinList_SweepList),

    Data = <<
        ErrorCode:32,
        DunType:8,
        SweepList_Len:16, Bin_SweepList/binary
    >>,
    {ok, pt:encode(61066, Data, Src_Data)};

write (61067,[
    DunType,
    FreeTimes,
    AllTimes,
    CurVal,
    SumVal,
    OnePrice,
    AllPrice
] = Src_Data) ->
    Data = <<
        DunType:8,
        FreeTimes:16,
        AllTimes:16,
        CurVal:32,
        SumVal:32,
        OnePrice:32,
        AllPrice:32
    >>,
    {ok, pt:encode(61067, Data, Src_Data)};

write (61068,[
    ErrorCode,
    Index,
    DunType,
    FreeTimes,
    AllTimes,
    CurVal,
    SumVal,
    Reset,
    OnePrice,
    AllPrice,
    RewardList
] = Src_Data) ->
    BinList_RewardList = [
        item_to_bin_21(RewardList_Item) || RewardList_Item <- RewardList
    ], 

    RewardList_Len = length(RewardList), 
    Bin_RewardList = list_to_binary(BinList_RewardList),

    Data = <<
        ErrorCode:32,
        Index:16,
        DunType:8,
        FreeTimes:16,
        AllTimes:16,
        CurVal:32,
        SumVal:32,
        Reset:8,
        OnePrice:32,
        AllPrice:32,
        RewardList_Len:16, Bin_RewardList/binary
    >>,
    {ok, pt:encode(61068, Data, Src_Data)};

write (61069,[
    DunId,
    KillList
] = Src_Data) ->
    BinList_KillList = [
        item_to_bin_22(KillList_Item) || KillList_Item <- KillList
    ], 

    KillList_Len = length(KillList), 
    Bin_KillList = list_to_binary(BinList_KillList),

    Data = <<
        DunId:32,
        KillList_Len:16, Bin_KillList/binary
    >>,
    {ok, pt:encode(61069, Data, Src_Data)};

write (61070,[
    DunId,
    Rating,
    EndTime
] = Src_Data) ->
    Data = <<
        DunId:32,
        Rating:16,
        EndTime:32
    >>,
    {ok, pt:encode(61070, Data, Src_Data)};

write (61071,[
    YdayPassDunId,
    YdayPassWave,
    DunList
] = Src_Data) ->
    BinList_DunList = [
        item_to_bin_23(DunList_Item) || DunList_Item <- DunList
    ], 

    DunList_Len = length(DunList), 
    Bin_DunList = list_to_binary(BinList_DunList),

    Data = <<
        YdayPassDunId:32,
        YdayPassWave:16,
        DunList_Len:16, Bin_DunList/binary
    >>,
    {ok, pt:encode(61071, Data, Src_Data)};

write (61072,[
    ErrorCode,
    RewardList,
    CustomActRewardList
] = Src_Data) ->
    BinList_RewardList = [
        item_to_bin_25(RewardList_Item) || RewardList_Item <- RewardList
    ], 

    RewardList_Len = length(RewardList), 
    Bin_RewardList = list_to_binary(BinList_RewardList),

    Bin_CustomActRewardList = pt:write_object_list(CustomActRewardList), 

    Data = <<
        ErrorCode:32,
        RewardList_Len:16, Bin_RewardList/binary,
        Bin_CustomActRewardList/binary
    >>,
    {ok, pt:encode(61072, Data, Src_Data)};

write (61073,[
    RewardList
] = Src_Data) ->
    BinList_RewardList = [
        item_to_bin_26(RewardList_Item) || RewardList_Item <- RewardList
    ], 

    RewardList_Len = length(RewardList), 
    Bin_RewardList = list_to_binary(BinList_RewardList),

    Data = <<
        RewardList_Len:16, Bin_RewardList/binary
    >>,
    {ok, pt:encode(61073, Data, Src_Data)};

write (61074,[
    Res,
    DunId,
    RewardStatus
] = Src_Data) ->
    Data = <<
        Res:32,
        DunId:32,
        RewardStatus:8
    >>,
    {ok, pt:encode(61074, Data, Src_Data)};

write (61075,[
    Type,
    RankList,
    MyRank,
    MyScore,
    MyScoreLv,
    MyScoreWave
] = Src_Data) ->
    BinList_RankList = [
        item_to_bin_27(RankList_Item) || RankList_Item <- RankList
    ], 

    RankList_Len = length(RankList), 
    Bin_RankList = list_to_binary(BinList_RankList),

    Data = <<
        Type:8,
        RankList_Len:16, Bin_RankList/binary,
        MyRank:16,
        MyScore:32,
        MyScoreLv:8,
        MyScoreWave:8
    >>,
    {ok, pt:encode(61075, Data, Src_Data)};

write (61076,[
    MyRank,
    MyScore,
    MyScoreLv,
    MyScoreWave,
    MyName,
    MyPhotoId,
    OtherRank
] = Src_Data) ->
    Bin_MyName = pt:write_string(MyName), 

    BinList_OtherRank = [
        item_to_bin_28(OtherRank_Item) || OtherRank_Item <- OtherRank
    ], 

    OtherRank_Len = length(OtherRank), 
    Bin_OtherRank = list_to_binary(BinList_OtherRank),

    Data = <<
        MyRank:16,
        MyScore:32,
        MyScoreLv:8,
        MyScoreWave:8,
        Bin_MyName/binary,
        MyPhotoId:32,
        OtherRank_Len:16, Bin_OtherRank/binary
    >>,
    {ok, pt:encode(61076, Data, Src_Data)};

write (61077,[
    BuffList
] = Src_Data) ->
    BinList_BuffList = [
        item_to_bin_29(BuffList_Item) || BuffList_Item <- BuffList
    ], 

    BuffList_Len = length(BuffList), 
    Bin_BuffList = list_to_binary(BinList_BuffList),

    Data = <<
        BuffList_Len:16, Bin_BuffList/binary
    >>,
    {ok, pt:encode(61077, Data, Src_Data)};

write (61078,[
    Res,
    BuffId,
    X,
    Y
] = Src_Data) ->
    Data = <<
        Res:32,
        BuffId:8,
        X:16,
        Y:16
    >>,
    {ok, pt:encode(61078, Data, Src_Data)};

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

write (61080,[
    TowerHp
] = Src_Data) ->
    BinList_TowerHp = [
        item_to_bin_30(TowerHp_Item) || TowerHp_Item <- TowerHp
    ], 

    TowerHp_Len = length(TowerHp), 
    Bin_TowerHp = list_to_binary(BinList_TowerHp),

    Data = <<
        TowerHp_Len:16, Bin_TowerHp/binary
    >>,
    {ok, pt:encode(61080, Data, Src_Data)};

write (61081,[
    DunArray
] = Src_Data) ->
    BinList_DunArray = [
        item_to_bin_31(DunArray_Item) || DunArray_Item <- DunArray
    ], 

    DunArray_Len = length(DunArray), 
    Bin_DunArray = list_to_binary(BinList_DunArray),

    Data = <<
        DunArray_Len:16, Bin_DunArray/binary
    >>,
    {ok, pt:encode(61081, Data, Src_Data)};

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

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

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

write (61085,[
    BuffId,
    X,
    Y
] = Src_Data) ->
    Data = <<
        BuffId:8,
        X:16,
        Y:16
    >>,
    {ok, pt:encode(61085, Data, Src_Data)};

write (61086,[
    Rank,
    Score,
    ScoreLv,
    ScoreWave
] = Src_Data) ->
    Data = <<
        Rank:16,
        Score:32,
        ScoreLv:8,
        ScoreWave:8
    >>,
    {ok, pt:encode(61086, Data, Src_Data)};

write (61087,[
    Res,
    DunId,
    RewardStatus
] = Src_Data) ->
    Data = <<
        Res:32,
        DunId:32,
        RewardStatus:8
    >>,
    {ok, pt:encode(61087, Data, Src_Data)};

write (61088,[
    Type,
    RankList,
    RankType,
    MyRankMin,
    MyRankMax,
    MyGrade
] = Src_Data) ->
    BinList_RankList = [
        item_to_bin_32(RankList_Item) || RankList_Item <- RankList
    ], 

    RankList_Len = length(RankList), 
    Bin_RankList = list_to_binary(BinList_RankList),

    Data = <<
        Type:8,
        RankList_Len:16, Bin_RankList/binary,
        RankType:8,
        MyRankMin:16,
        MyRankMax:16,
        MyGrade:32
    >>,
    {ok, pt:encode(61088, Data, Src_Data)};

write (61090,[
    GoodsList
] = Src_Data) ->
    BinList_GoodsList = [
        item_to_bin_33(GoodsList_Item) || GoodsList_Item <- GoodsList
    ], 

    GoodsList_Len = length(GoodsList), 
    Bin_GoodsList = list_to_binary(BinList_GoodsList),

    Data = <<
        GoodsList_Len:16, Bin_GoodsList/binary
    >>,
    {ok, pt:encode(61090, Data, Src_Data)};

write (61091,[
    Res,
    Id,
    LeftCount
] = Src_Data) ->
    Data = <<
        Res:32,
        Id:16,
        LeftCount:8
    >>,
    {ok, pt:encode(61091, Data, Src_Data)};

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

write (61093,[
    RankList
] = Src_Data) ->
    BinList_RankList = [
        item_to_bin_34(RankList_Item) || RankList_Item <- RankList
    ], 

    RankList_Len = length(RankList), 
    Bin_RankList = list_to_binary(BinList_RankList),

    Data = <<
        RankList_Len:16, Bin_RankList/binary
    >>,
    {ok, pt:encode(61093, Data, Src_Data)};

write (61094,[
    Res,
    MonId,
    Time
] = Src_Data) ->
    Data = <<
        Res:32,
        MonId:32,
        Time:32
    >>,
    {ok, pt:encode(61094, Data, Src_Data)};

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

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

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

write (61098,[
    Type,
    Status,
    Res
] = Src_Data) ->
    Data = <<
        Type:8,
        Status:8,
        Res:32
    >>,
    {ok, pt:encode(61098, Data, Src_Data)};

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

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


item_to_bin_0 ({
    Key,
    Val
}) ->
    Data = <<
        Key:16,
        Val:32
    >>,
    Data.
item_to_bin_1 ({
    DunId,
    VipCount,
    DayPassCount,
    IsPass,
    DayIsPass,
    Star,
    PassLv,
    RecData
}) ->
    BinList_RecData = [
        item_to_bin_2(RecData_Item) || RecData_Item <- RecData
    ], 

    RecData_Len = length(RecData), 
    Bin_RecData = list_to_binary(BinList_RecData),

    Data = <<
        DunId:32,
        VipCount:16,
        DayPassCount:16,
        IsPass:8,
        DayIsPass:8,
        Star:8,
        PassLv:16,
        RecData_Len:16, Bin_RecData/binary
    >>,
    Data.
item_to_bin_2 ({
    Key,
    Val
}) ->
    Data = <<
        Key:16,
        Val:32
    >>,
    Data.
item_to_bin_3 ({
    Key,
    Val
}) ->
    Data = <<
        Key:16,
        Val:32
    >>,
    Data.
item_to_bin_4 ({
    DunType,
    LeftCount
}) ->
    Data = <<
        DunType:8,
        LeftCount:16
    >>,
    Data.
item_to_bin_5 (
    DunId
) ->
    Data = <<
        DunId:16
    >>,
    Data.
item_to_bin_6 ({
    ServerId,
    Picture,
    MonHurt
}) ->
    Bin_Picture = pt:write_picture(Picture), 

    Data = <<
        ServerId:64,
        Bin_Picture/binary,
        MonHurt:64
    >>,
    Data.
item_to_bin_7 ({
    ServerId,
    Picture,
    MonHurt
}) ->
    Bin_Picture = pt:write_picture(Picture), 

    Data = <<
        ServerId:64,
        Bin_Picture/binary,
        MonHurt:64
    >>,
    Data.
item_to_bin_8 ({
    ServerId,
    Picture,
    MonHurt
}) ->
    Bin_Picture = pt:write_picture(Picture), 

    Data = <<
        ServerId:64,
        Bin_Picture/binary,
        MonHurt:64
    >>,
    Data.
item_to_bin_9 ({
    Type,
    ReviveCount,
    NextTime
}) ->
    Data = <<
        Type:8,
        ReviveCount:8,
        NextTime:32
    >>,
    Data.
item_to_bin_10 ({
    StarNum,
    State
}) ->
    Data = <<
        StarNum:8,
        State:8
    >>,
    Data.
item_to_bin_11 ({
    WaveId,
    Status
}) ->
    Data = <<
        WaveId:16,
        Status:8
    >>,
    Data.
item_to_bin_12 ({
    Index,
    State,
    RewardList
}) ->
    BinList_RewardList = [
        item_to_bin_13(RewardList_Item) || RewardList_Item <- RewardList
    ], 

    RewardList_Len = length(RewardList), 
    Bin_RewardList = list_to_binary(BinList_RewardList),

    Data = <<
        Index:8,
        State:8,
        RewardList_Len:16, Bin_RewardList/binary
    >>,
    Data.
item_to_bin_13 ({
    Times,
    Style,
    TypeId,
    Count
}) ->
    Data = <<
        Times:8,
        Style:32,
        TypeId:32,
        Count:16
    >>,
    Data.
item_to_bin_14 ({
    Style,
    TypeId,
    Count
}) ->
    Data = <<
        Style:32,
        TypeId:32,
        Count:16
    >>,
    Data.
item_to_bin_15 ({
    WaveId,
    Status
}) ->
    Data = <<
        WaveId:16,
        Status:8
    >>,
    Data.
item_to_bin_16 ({
    SpType,
    GoodsType,
    GoodsId,
    Num
}) ->
    Data = <<
        SpType:8,
        GoodsType:32,
        GoodsId:32,
        Num:64
    >>,
    Data.
item_to_bin_17 ({
    Wave,
    Rank,
    RoleId,
    RoleName,
    Lv,
    Svip,
    Vip,
    Sex,
    GuildName
}) ->
    Bin_RoleName = pt:write_string(RoleName), 

    Bin_GuildName = pt:write_string(GuildName), 

    Data = <<
        Wave:16,
        Rank:16,
        RoleId:64,
        Bin_RoleName/binary,
        Lv:16,
        Svip:8,
        Vip:8,
        Sex:8,
        Bin_GuildName/binary
    >>,
    Data.
item_to_bin_18 ({
    Rank,
    RoleInfo
}) ->
    Bin_RoleInfo = pt:write_picture(RoleInfo), 

    Data = <<
        Rank:16,
        Bin_RoleInfo/binary
    >>,
    Data.
item_to_bin_19 ({
    Id,
    State
}) ->
    Data = <<
        Id:8,
        State:8
    >>,
    Data.
item_to_bin_20 ({
    SweepType,
    RewardList,
    CustomActRewardList,
    DunTime,
    Price
}) ->
    Bin_RewardList = pt:write_object_list(RewardList), 

    Bin_CustomActRewardList = pt:write_object_list(CustomActRewardList), 

    Data = <<
        SweepType:8,
        Bin_RewardList/binary,
        Bin_CustomActRewardList/binary,
        DunTime:16,
        Price:32
    >>,
    Data.
item_to_bin_21 ({
    Times,
    Style,
    TypeId,
    Count
}) ->
    Data = <<
        Times:8,
        Style:32,
        TypeId:32,
        Count:64
    >>,
    Data.
item_to_bin_22 ({
    MonId,
    DieNum
}) ->
    Data = <<
        MonId:32,
        DieNum:16
    >>,
    Data.
item_to_bin_23 ({
    DunId,
    PassWave,
    RewardStatus,
    SweepList
}) ->
    BinList_SweepList = [
        item_to_bin_24(SweepList_Item) || SweepList_Item <- SweepList
    ], 

    SweepList_Len = length(SweepList), 
    Bin_SweepList = list_to_binary(BinList_SweepList),

    Data = <<
        DunId:32,
        PassWave:16,
        RewardStatus:8,
        SweepList_Len:16, Bin_SweepList/binary
    >>,
    Data.
item_to_bin_24 (
    Wave
) ->
    Data = <<
        Wave:16
    >>,
    Data.
item_to_bin_25 ({
    Style,
    TypeId,
    Count
}) ->
    Data = <<
        Style:32,
        TypeId:32,
        Count:64
    >>,
    Data.
item_to_bin_26 ({
    DunId,
    RewardStatus
}) ->
    Data = <<
        DunId:32,
        RewardStatus:8
    >>,
    Data.
item_to_bin_27 ({
    Rank,
    RoleId,
    RoleName,
    Score,
    ScoreLv,
    ScoreWave,
    VipFlag,
    SupVipType,
    Sex,
    FrameId,
    PhotoId,
    RoleLv
}) ->
    Bin_RoleName = pt:write_string(RoleName), 

    Data = <<
        Rank:16,
        RoleId:64,
        Bin_RoleName/binary,
        Score:32,
        ScoreLv:8,
        ScoreWave:8,
        VipFlag:8,
        SupVipType:8,
        Sex:8,
        FrameId:32,
        PhotoId:32,
        RoleLv:16
    >>,
    Data.
item_to_bin_28 ({
    Rank,
    Score,
    ScoreLv,
    ScoreWave,
    Name,
    PhotoId
}) ->
    Bin_Name = pt:write_string(Name), 

    Data = <<
        Rank:16,
        Score:32,
        ScoreLv:8,
        ScoreWave:8,
        Bin_Name/binary,
        PhotoId:32
    >>,
    Data.
item_to_bin_29 ({
    BuffId,
    X,
    Y,
    Num
}) ->
    Data = <<
        BuffId:8,
        X:16,
        Y:16,
        Num:8
    >>,
    Data.
item_to_bin_30 ({
    MonId,
    Hp
}) ->
    Data = <<
        MonId:32,
        Hp:32
    >>,
    Data.
item_to_bin_31 ({
    DunId,
    Wave,
    State
}) ->
    Data = <<
        DunId:32,
        Wave:16,
        State:8
    >>,
    Data.
item_to_bin_32 ({
    ServerNum,
    Rank,
    Picture,
    Grade
}) ->
    Bin_Picture = pt:write_picture(Picture), 

    Data = <<
        ServerNum:32,
        Rank:16,
        Bin_Picture/binary,
        Grade:32
    >>,
    Data.
item_to_bin_33 ({
    Id,
    Type,
    MaxCount,
    LeftCount
}) ->
    Data = <<
        Id:16,
        Type:8,
        MaxCount:8,
        LeftCount:8
    >>,
    Data.
item_to_bin_34 ({
    ServerNum,
    RoleId,
    Rank,
    Grade,
    Name,
    PhotoId
}) ->
    Bin_Name = pt:write_string(Name), 

    Data = <<
        ServerNum:32,
        RoleId:64,
        Rank:16,
        Grade:32,
        Bin_Name/binary,
        PhotoId:32
    >>,
    Data.
