//------------------------------------------------------------------------------
// <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 GameArenaChallengeNpcData struct {
    Id int32
    OpenCond int32
    OpenValue int32
    BattleReadyID int32
    MonsterformatId []int32
    StroyIdFront int32
    StroyIdAfter int32
    Name string
    ReviveCd int32
    NpcReward []*Gameatn
    NewNpcReward []*Gameatn
}

const TypeId_GameArenaChallengeNpcData = 362128499

func (*GameArenaChallengeNpcData) GetTypeId() int32 {
    return 362128499
}

func (_v *GameArenaChallengeNpcData)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["open_cond"].(float64); !_ok_ { err = errors.New("open_cond error"); return }; _v.OpenCond = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["open_value"].(float64); !_ok_ { err = errors.New("open_value error"); return }; _v.OpenValue = int32(_tempNum_) }
    { 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["monsterformat_id"].([]interface{}); !_ok_ { err = errors.New("monsterformat_id error"); return }

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

    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["stroy_id_front"].(float64); !_ok_ { err = errors.New("stroy_id_front error"); return }; _v.StroyIdFront = int32(_tempNum_) }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["stroy_id_after"].(float64); !_ok_ { err = errors.New("stroy_id_after error"); return }; _v.StroyIdAfter = int32(_tempNum_) }
    {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["name"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Name error"); return };  { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Name, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
    { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["revive_cd"].(float64); !_ok_ { err = errors.New("revive_cd error"); return }; _v.ReviveCd = int32(_tempNum_) }
     {
                var _arr_ []interface{}
                var _ok_ bool
                if _arr_, _ok_ = _buf["npc_reward"].([]interface{}); !_ok_ { err = errors.New("npc_reward error"); return }

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

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

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

    return
}

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