//------------------------------------------------------------------------------
// <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 GameDispatch_BattleData struct {
    Id int32
    Model string
    IdleAni string
    Weight int32
    Startstory int32
    Rejectstory int32
    Endstory int32
    Battlename string
    Battletxt string
    BattleReadyID int32
    MonsterformatId int32
    EventList []int32
    Award []*Gameatn
    Onlookers []string
    ChallengeOnlookers []string
    Onlookersstory []int32
}

const TypeId_GameDispatch_BattleData = 5907851

func (*GameDispatch_BattleData) GetTypeId() int32 {
    return 5907851
}

func (_v *GameDispatch_BattleData)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; if _v.Model, _ok_ = _buf["model"].(string); !_ok_ { err = errors.New("model error"); return } }
    { var _ok_ bool; if _v.IdleAni, _ok_ = _buf["idleAni"].(string); !_ok_ { err = errors.New("idleAni error"); return } }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["weight"].(float64); !_ok_ { err = errors.New("weight error"); return }; _v.Weight = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["startstory"].(float64); !_ok_ { err = errors.New("startstory error"); return }; _v.Startstory = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["rejectstory"].(float64); !_ok_ { err = errors.New("rejectstory error"); return }; _v.Rejectstory = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["endstory"].(float64); !_ok_ { err = errors.New("endstory error"); return }; _v.Endstory = int32(_tempNum_) }
    {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["battlename"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Battlename error"); return };  { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Battlename, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
    {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["battletxt"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Battletxt error"); return };  { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Battletxt, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["BattleReadyID"].(float64); !_ok_ { err = errors.New("BattleReadyID error"); return }; _v.BattleReadyID = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["monsterformat_id"].(float64); !_ok_ { err = errors.New("monsterformat_id error"); return }; _v.MonsterformatId = int32(_tempNum_) }
     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["EventList"].([]interface{}); !_ok_ { err = errors.New("EventList error"); return }

                _v.EventList = 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.EventList = append(_v.EventList, _list_v_)
                }
            }

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

                _v.Award = 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.Award = append(_v.Award, _list_v_)
                }
            }

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

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

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

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

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

                _v.Onlookersstory = 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.Onlookersstory = append(_v.Onlookersstory, _list_v_)
                }
            }

    return
}

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