Esempio n. 1
0
        public ItemViewModel(ViewModelFactory viewModelFactory, ItemModel model)
        {
            Model = model;

            ILevel          = model.Ilevel;
            Name            = model.Name;
            Quality         = model.Quality;
            Runeword        = model.Runeword;
            Set             = model.Set;
            Type            = model.Type;
            IsRuneword      = model.IsRuneword;
            Defense         = model.Defense;
            IsEthereal      = model.IsEthereal;
            NumberOfSockets = model.NumberOfSockets;

            for (var i = 0; i < model.Stats.Length; i++)
            {
                StatModel stat = model.Stats[i];

                if (_ignoredStats.Contains(stat.Name))
                {
                    continue;
                }

                var viewModel = viewModelFactory.CreateStat(stat);

                var index = viewModel.FormattedString.IndexOf('_');
                if (index != -1 && viewModel.FormattedString != stat.Name)
                {
                    var nextStat          = model.Stats[i + 1];
                    var nextStatViewModel = viewModelFactory.CreateStat(nextStat);

                    var stringValue = viewModel.FormattedString.Substring(0, index);

                    var index2 = nextStatViewModel.FormattedString.IndexOf('_');
                    stringValue += nextStatViewModel.FormattedString.Substring(index2 + 2, nextStatViewModel.FormattedString.Length - index2 - 2);
                    ++i;
                    Stats.Add(viewModelFactory.CreateMockStat(stringValue));
                }
                else
                {
                    Stats.Add(viewModelFactory.CreateStat(stat));
                }
            }
        }