//------------------------------------------------------------------------------
// <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"
import "bright/serialization"

type GameMainStageData struct {
    Id int32
    Chapterid int32
    Previoustage int32
    Episodetype int32
    Openlevel int32
    Episodelocation serialization.Vector3
    EditorStage int32
    Detailwindow string
    Frontstoryid int32
    Afterstoryid int32
    MainlineName string
    Title string
    Desc string
    Exp int32
    HeroExp int32
    PsConsume []*Gameatn
    PsMg []*Gameatn
    Firstaward []*Gameatn
    Commonaward []*Gameatn
    BattleReadyID int32
    FormatList []int32
    CaptainId int32
    Star []int32
    StarType []int32
    StarValue []int32
}

const TypeId_GameMainStageData = -1084910317

func (*GameMainStageData) GetTypeId() int32 {
    return -1084910317
}

func (_v *GameMainStageData)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["chapterid"].(float64); !_ok_ { err = errors.New("chapterid error"); return }; _v.Chapterid = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["previoustage"].(float64); !_ok_ { err = errors.New("previoustage error"); return }; _v.Previoustage = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["Episodetype"].(float64); !_ok_ { err = errors.New("Episodetype error"); return }; _v.Episodetype = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["openlevel"].(float64); !_ok_ { err = errors.New("openlevel error"); return }; _v.Openlevel = int32(_tempNum_) }
    { var _ok_ bool; var _v_ map[string]interface{}; if _v_, _ok_ = _buf["Episodelocation"].(map[string]interface{}); !_ok_ { err = errors.New("Episodelocation error"); return }
            var _x_, _y_, _z_ float32;
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["x"].(float64); !_ok_ { err = errors.New("x error"); return }; _x_ = float32(_tempNum_) }
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["y"].(float64); !_ok_ { err = errors.New("y error"); return }; _y_ = float32(_tempNum_) }
            { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _v_["z"].(float64); !_ok_ { err = errors.New("z error"); return }; _z_ = float32(_tempNum_) }
            _v.Episodelocation = serialization.NewVector3(_x_, _y_, _z_)
            }

    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["EditorStage"].(float64); !_ok_ { err = errors.New("EditorStage error"); return }; _v.EditorStage = int32(_tempNum_) }
    { var _ok_ bool; if _v.Detailwindow, _ok_ = _buf["detailwindow"].(string); !_ok_ { err = errors.New("detailwindow error"); return } }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["frontstoryid"].(float64); !_ok_ { err = errors.New("frontstoryid error"); return }; _v.Frontstoryid = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["afterstoryid"].(float64); !_ok_ { err = errors.New("afterstoryid error"); return }; _v.Afterstoryid = int32(_tempNum_) }
    {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["mainlineName"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.MainlineName error"); return };  { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.MainlineName, _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["title"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Title error"); return };  { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Title, _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["desc"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Desc error"); return };  { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Desc, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["exp"].(float64); !_ok_ { err = errors.New("exp error"); return }; _v.Exp = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["hero_exp"].(float64); !_ok_ { err = errors.New("hero_exp error"); return }; _v.HeroExp = int32(_tempNum_) }
     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["ps_consume"].([]interface{}); !_ok_ { err = errors.New("ps_consume error"); return }

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

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

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

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

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

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

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

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

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

    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["captainId"].(float64); !_ok_ { err = errors.New("captainId error"); return }; _v.CaptainId = int32(_tempNum_) }
     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["star"].([]interface{}); !_ok_ { err = errors.New("star error"); return }

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

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

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

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

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

    return
}

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