Exemplo n.º 1
0
        private void ParseSeriesBonus(JsonReader r, SeriesBonus bonus)
        {
            if (!r.Read() || r.TokenType != JsonToken.StartArray)
            {
                throw new InvalidOperationException();
            }

            while (r.Read() && r.TokenType != JsonToken.EndArray)
            {
                if (r.TokenType != JsonToken.StartObject)
                {
                    throw new InvalidOperationException();
                }

                if (!r.Read() || r.TokenType != JsonToken.PropertyName)
                {
                    throw new InvalidOperationException();
                }

                var bonusKey = r.Value.ToString();

                if (!r.Read() || r.TokenType != JsonToken.StartObject)
                {
                    throw new InvalidOperationException();
                }
                if (!r.Read() || r.TokenType != JsonToken.PropertyName)
                {
                    throw new InvalidOperationException();
                }

                var paramKey = Convert.ToInt32(r.Value);
                var value    = r.ReadInt32();

                bonus.Bonuses.Add(new KeyValuePair <string, Bonus>(bonusKey, new Bonus {
                    BaseParam = paramKey, Value = value
                }));

                if (!r.Read() || r.TokenType != JsonToken.EndObject)
                {
                    throw new InvalidOperationException();
                }
                if (!r.Read() || r.TokenType != JsonToken.EndObject)
                {
                    throw new InvalidOperationException();
                }
            }
        }
Exemplo n.º 2
0
        private SeriesBonus ParseSeriesBonuses(JsonReader r)
        {
            if (!r.Read() || r.TokenType != JsonToken.StartObject)
            {
                throw new InvalidOperationException();
            }

            var bonus = new SeriesBonus();

            while (r.Read() && r.TokenType != JsonToken.EndObject)
            {
                if (r.TokenType != JsonToken.PropertyName)
                {
                    throw new InvalidOperationException();
                }

                switch (r.Value.ToString())
                {
                case "SpecialBonus":
                    bonus.SpecialBonus = r.ReadAsString();
                    break;

                case "Series":
                    bonus.Series = r.ReadAsString();
                    break;

                case "bonus":
                    ParseSeriesBonus(r, bonus);
                    break;

                default:
                    Console.Error.WriteLine("Unknown 'Item'.'series_bonus' data key: {0}", r.Value);
                    throw new NotSupportedException();
                }
            }
            return(bonus);
        }
Exemplo n.º 3
0
        public void Parse()
        {
            if (_IsParsed)
            {
                return;
            }

            var json = Encoding.UTF8.GetString(this.data);

            using (var strReader = new System.IO.StringReader(json)) {
                using (var r = new JsonTextReader(strReader)) {
                    while (r.Read())
                    {
                        if (r.TokenType == JsonToken.PropertyName)
                        {
                            switch (r.Value.ToString())
                            {
                                #region Boolean
                            case "OnlyOne":
                                _OnlyOne = r.ReadInt32() != 0;
                                break;

                            case "DisablePassedOthers":
                                _DisablePassedOthers = r.ReadInt32() != 0;
                                break;

                            case "Crest":
                                _Crest = r.ReadInt32() != 0;
                                break;
                                #endregion

                                #region Int64[]
                            case "bnpc":
                                _BNpcs = r.ReadInt64Array();
                                break;
                                #endregion

                                #region Int32[]
                            case "shopnpc":
                                _ShopENpcs = r.ReadInt32Array();
                                break;

                            case "instance_content":
                                _InstanceContents = r.ReadInt32Array();
                                break;

                            case "recipe":
                                _Recipes = r.ReadInt32Array();
                                break;

                            case "quest":
                                _Quests = r.ReadInt32Array();
                                break;

                            case "classjob":
                                _ClassJobs = r.ReadInt32Array();
                                break;

                            case "achievement":
                                _Achievements = r.ReadInt32Array();
                                break;
                                #endregion

                                #region Int32
                            case "sell_price":
                                _SellPrice = r.ReadInt32();
                                break;

                            case "Repair":
                                _RepairClassJob = r.ReadInt32();
                                break;

                            case "RepairItem":
                                _RepairItem = r.ReadInt32();
                                break;

                            case "repair_price":
                                _RepairPrice = r.ReadInt32();
                                break;

                            case "MateriaSocket":
                                _MateriaSocket = r.ReadInt32();
                                break;

                            case "MaterializeType":
                                _MaterializeType = r.ReadInt32();
                                break;

                            case "Stain":
                                _Stain = r.ReadInt32();
                                break;

                            case "CondClassJob":
                                _CondClassJob = r.ReadInt32();
                                break;

                            case "Series":
                                _Series = r.ReadInt32();
                                break;

                            case "RecastTime":
                                _RecastTime = r.ReadInt32();
                                break;
                                #endregion

                                #region Obj
                            case "basic_param":
                                _BasicParams = ParseBasicParam(r);
                                break;

                            case "basic_param_hq":
                                _BasicParamsHq = ParseBasicParam(r);
                                break;

                            case "action":
                                _Actions = ParseActions(r);
                                break;

                            case "action_hq":
                                _ActionsHq = ParseActions(r);
                                break;

                            case "bonus":
                                _Bonuses = ParseBonuses(r);
                                break;

                            case "bonus_hq":
                                _BonusesHq = ParseBonuses(r);
                                break;

                            case "series_bonus":
                                _SeriesBonuses = ParseSeriesBonuses(r);
                                break;

                            case "effect":
                                if (!r.Read())
                                {
                                    throw new InvalidOperationException();
                                }
                                _Effect = ParseBonus(r);
                                break;

                            case "color":
                                _Color = ParseColor(r);
                                break;
                                #endregion

                            default:
                                Console.Error.WriteLine("Unknown 'Item' data key: {0}", r.Value);
                                throw new NotSupportedException();
                            }
                        }
                    }
                }
            }

            _IsParsed = true;
        }
Exemplo n.º 4
0
        private SeriesBonus ParseSeriesBonuses(JsonReader r)
        {
            if (!r.Read() || r.TokenType != JsonToken.StartObject) throw new InvalidOperationException();

            var bonus = new SeriesBonus();
            while (r.Read() && r.TokenType != JsonToken.EndObject) {
                if (r.TokenType != JsonToken.PropertyName) throw new InvalidOperationException();

                switch (r.Value.ToString()) {
                    case "SpecialBonus":
                        bonus.SpecialBonus = r.ReadAsString();
                        break;
                    case "Series":
                        bonus.Series = r.ReadAsString();
                        break;
                    case "bonus":
                        ParseSeriesBonus(r, bonus);
                        break;
                    default:
                        Console.Error.WriteLine("Unknown 'Item'.'series_bonus' data key: {0}", r.Value);
                        throw new NotSupportedException();
                }
            }
            return bonus;
        }
Exemplo n.º 5
0
        private void ParseSeriesBonus(JsonReader r, SeriesBonus bonus)
        {
            if (!r.Read() || r.TokenType != JsonToken.StartArray) throw new InvalidOperationException();

            while (r.Read() && r.TokenType != JsonToken.EndArray) {
                if (r.TokenType != JsonToken.StartObject) throw new InvalidOperationException();

                if (!r.Read() || r.TokenType != JsonToken.PropertyName) throw new InvalidOperationException();

                var bonusKey = r.Value.ToString();

                if (!r.Read() || r.TokenType != JsonToken.StartObject) throw new InvalidOperationException();
                if (!r.Read() || r.TokenType != JsonToken.PropertyName) throw new InvalidOperationException();

                var paramKey = Convert.ToInt32(r.Value);
                var value = r.ReadInt32();

                bonus.Bonuses.Add(new KeyValuePair<string, Bonus>(bonusKey, new Bonus { BaseParam = paramKey, Value = value }));

                if (!r.Read() || r.TokenType != JsonToken.EndObject) throw new InvalidOperationException();
                if (!r.Read() || r.TokenType != JsonToken.EndObject) throw new InvalidOperationException();
            }
        }
Exemplo n.º 6
0
        public void Parse()
        {
            if (_IsParsed) return;

            var json = Encoding.UTF8.GetString(this.data);
            using (var strReader = new System.IO.StringReader(json)) {
                using (var r = new JsonTextReader(strReader)) {
                    while (r.Read()) {
                        if (r.TokenType == JsonToken.PropertyName) {
                            switch (r.Value.ToString()) {
                                #region Boolean
                                case "OnlyOne":
                                    _OnlyOne = r.ReadInt32() != 0;
                                    break;
                                case "DisablePassedOthers":
                                    _DisablePassedOthers = r.ReadInt32() != 0;
                                    break;
                                case "Crest":
                                    _Crest = r.ReadInt32() != 0;
                                    break;
                                #endregion

                                #region Int64[]
                                case "bnpc":
                                    _BNpcs = r.ReadInt64Array();
                                    break;
                                #endregion

                                #region Int32[]
                                case "shopnpc":
                                    _ShopENpcs = r.ReadInt32Array();
                                    break;
                                case "instance_content":
                                    _InstanceContents = r.ReadInt32Array();
                                    break;
                                case "recipe":
                                    _Recipes = r.ReadInt32Array();
                                    break;
                                case "quest":
                                    _Quests = r.ReadInt32Array();
                                    break;
                                case "classjob":
                                    _ClassJobs = r.ReadInt32Array();
                                    break;
                                case "achievement":
                                    _Achievements = r.ReadInt32Array();
                                    break;
                                #endregion

                                #region Int32
                                case "sell_price":
                                    _SellPrice = r.ReadInt32();
                                    break;
                                case "Repair":
                                    _RepairClassJob = r.ReadInt32();
                                    break;
                                case "RepairItem":
                                    _RepairItem = r.ReadInt32();
                                    break;
                                case "repair_price":
                                    _RepairPrice = r.ReadInt32();
                                    break;
                                case "MateriaSocket":
                                    _MateriaSocket = r.ReadInt32();
                                    break;
                                case "MaterializeType":
                                    _MaterializeType = r.ReadInt32();
                                    break;
                                case "Stain":
                                    _Stain = r.ReadInt32();
                                    break;
                                case "CondClassJob":
                                    _CondClassJob = r.ReadInt32();
                                    break;
                                case "Series":
                                    _Series = r.ReadInt32();
                                    break;
                                case "RecastTime":
                                    _RecastTime = r.ReadInt32();
                                    break;
                                #endregion

                                #region Obj
                                case "basic_param":
                                    _BasicParams = ParseBasicParam(r);
                                    break;
                                case "basic_param_hq":
                                    _BasicParamsHq = ParseBasicParam(r);
                                    break;
                                case "action":
                                    _Actions = ParseActions(r);
                                    break;
                                case "action_hq":
                                    _ActionsHq = ParseActions(r);
                                    break;
                                case "bonus":
                                    _Bonuses = ParseBonuses(r);
                                    break;
                                case "bonus_hq":
                                    _BonusesHq = ParseBonuses(r);
                                    break;
                                case "series_bonus":
                                    _SeriesBonuses = ParseSeriesBonuses(r);
                                    break;
                                case "effect":
                                    if (!r.Read()) throw new InvalidOperationException();
                                    _Effect = ParseBonus(r);
                                    break;
                                case "color":
                                    _Color = ParseColor(r);
                                    break;
                                #endregion

                                default:
                                    Console.Error.WriteLine("Unknown 'Item' data key: {0}", r.Value);
                                    throw new NotSupportedException();
                            }
                        }
                    }
                }
            }

            _IsParsed = true;
        }