//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

package cfg

import "errors"

type GameCaravanEventData struct {
    Id int32
    Eventtype int32
    Mustdo int32
    Citystory int32
    Citynormal int32
    Cityabnormal int32
    Worldtask int32
    Traintips string
    Trainstory int32
    Trainstorybad int32
    Trainstorygood int32
    Reword []*Gameatn
    Exreword []int32
    Unreword []int32
    Eventtime int32
}

const TypeId_GameCaravanEventData = 1366968202

func (*GameCaravanEventData) GetTypeId() int32 {
    return 1366968202
}

func (_v *GameCaravanEventData)Deserialize(_buf map[string]interface{}) (err error) {
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["eventtype"].(float64); !_ok_ { err = errors.New("eventtype error"); return }; _v.Eventtype = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["mustdo"].(float64); !_ok_ { err = errors.New("mustdo error"); return }; _v.Mustdo = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["citystory"].(float64); !_ok_ { err = errors.New("citystory error"); return }; _v.Citystory = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["citynormal"].(float64); !_ok_ { err = errors.New("citynormal error"); return }; _v.Citynormal = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["cityabnormal"].(float64); !_ok_ { err = errors.New("cityabnormal error"); return }; _v.Cityabnormal = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["worldtask"].(float64); !_ok_ { err = errors.New("worldtask error"); return }; _v.Worldtask = int32(_tempNum_) }
    {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["traintips"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Traintips error"); return };  { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Traintips, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["trainstory"].(float64); !_ok_ { err = errors.New("trainstory error"); return }; _v.Trainstory = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["trainstorybad"].(float64); !_ok_ { err = errors.New("trainstorybad error"); return }; _v.Trainstorybad = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["trainstorygood"].(float64); !_ok_ { err = errors.New("trainstorygood error"); return }; _v.Trainstorygood = int32(_tempNum_) }
     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["reword"].([]interface{}); !_ok_ { err = errors.New("reword error"); return }

                _v.Reword = make([]*Gameatn, 0, len(_arr_))
                
                for _, _e_ := range _arr_ {
                    var _list_v_ *Gameatn
                    { var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } }
                    _v.Reword = append(_v.Reword, _list_v_)
                }
            }

     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["exreword"].([]interface{}); !_ok_ { err = errors.New("exreword error"); return }

                _v.Exreword = make([]int32, 0, len(_arr_))
                
                for _, _e_ := range _arr_ {
                    var _list_v_ int32
                    { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
                    _v.Exreword = append(_v.Exreword, _list_v_)
                }
            }

     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["unreword"].([]interface{}); !_ok_ { err = errors.New("unreword error"); return }

                _v.Unreword = make([]int32, 0, len(_arr_))
                
                for _, _e_ := range _arr_ {
                    var _list_v_ int32
                    { var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
                    _v.Unreword = append(_v.Unreword, _list_v_)
                }
            }

    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["eventtime"].(float64); !_ok_ { err = errors.New("eventtime error"); return }; _v.Eventtime = int32(_tempNum_) }
    return
}

func DeserializeGameCaravanEventData(_buf map[string]interface{}) (*GameCaravanEventData, error) {
    v := &GameCaravanEventData{}
    if err := v.Deserialize(_buf); err == nil {
        return v, nil
    } else {
        return nil, err
    }
}
