//------------------------------------------------------------------------------
// <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 GameShopitemData struct {
    Key int32
    Id int32
    Iteminfo []*Gameatn
    Preview bool
    Probability int32
    Need []*Gameatn
    Sale int32
    Salelist []int32
    Buyminnum int32
    Buymaxnum int32
    Vip int32
    Lvmin int32
    Lvmax int32
    Mapidmin int32
    Mapidmax int32
}

const TypeId_GameShopitemData = 491491023

func (*GameShopitemData) GetTypeId() int32 {
    return 491491023
}

func (_v *GameShopitemData)Deserialize(_buf map[string]interface{}) (err error) {
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["key"].(float64); !_ok_ { err = errors.New("key error"); return }; _v.Key = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["iteminfo"].([]interface{}); !_ok_ { err = errors.New("iteminfo error"); return }

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

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

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

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

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

    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["buyminnum"].(float64); !_ok_ { err = errors.New("buyminnum error"); return }; _v.Buyminnum = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["buymaxnum"].(float64); !_ok_ { err = errors.New("buymaxnum error"); return }; _v.Buymaxnum = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["vip"].(float64); !_ok_ { err = errors.New("vip error"); return }; _v.Vip = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["lvmin"].(float64); !_ok_ { err = errors.New("lvmin error"); return }; _v.Lvmin = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["lvmax"].(float64); !_ok_ { err = errors.New("lvmax error"); return }; _v.Lvmax = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["mapidmin"].(float64); !_ok_ { err = errors.New("mapidmin error"); return }; _v.Mapidmin = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["mapidmax"].(float64); !_ok_ { err = errors.New("mapidmax error"); return }; _v.Mapidmax = int32(_tempNum_) }
    return
}

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