Example #1
0
        public static IEnumerable <string> GetBattleIdsWhereFieldIsLikeValue(IDataOptions tbl, string field, string val)
        {
            var results         = tbl.dataList.Where(x => x.GetPropertyValueFromName(field).Contains(val));
            var battleIdStrings = results.Select(x => x.GetPropertyValueFromName("battle_id")).Distinct();

            return(battleIdStrings);
        }
Example #2
0
        public DataTbls()
        {
            dataOptions      = new List <IDataOptions>();
            selectedFighters = new List <Fighter>();
            selectedBattle   = new Battle();
            config           = new Config();
            tabStorage       = new Stack <TabPage>();

            // If there is no labels file, ask the user if they would like one.
            if (!FileHelper.FileExists(config.labels_file_location) && UiHelper.PopUpQuestion("No Labels file found.  Would you like to download now?"))
            {
                NetworkHelper.DownloadParamLabels(config.labels_file_location);
            }

            var results = XmlHelper.ReadXML(config.file_location, config.labels_file_location);

            foreach (Type child in DataTbl.GetChildrenTypes())
            {
                IDataOptions opt = results.GetDataOptionsFromUnderlyingType(child);

                if (opt != null)
                {
                    dataOptions.Add(opt);
                }
            }
        }
Example #3
0
        public static void GetNumericStatsForField(IDataOptions tbl, string field)
        {
            var results = tbl.dataList.GroupBy(x => x.GetPropertyValueFromName(field))
                          .Select(g => new
            {
                Field = Convert.ToInt32(g.Key),
                Count = g.Select(l => l.GetPropertyValueFromName(field)).Count()
            }).OrderBy(x => x.Count);

            var leastCommon = results.Where(x => x.Field > 1).First();
            var midCommon   = results.ElementAt(results.Count() / 2);
            var mostCommon  = results.Last();

            results = results.OrderBy(x => x.Field);

            var min = results.Where(x => x.Field > 1).First();
            var avg = results.Average(x => x.Field);
            var max = results.Last();

            var vals = new List <int>()
            {
                leastCommon.Field, midCommon.Field, mostCommon.Field, min.Field, max.Field
            };

            var examples = new List <IDataTbl>();

            examples.AddRange(GetTblsWhereFieldIsValue(tbl, field, vals));
        }
Example #4
0
 public static void GetCountPerField(IDataOptions tbl, string field)
 {
     var results = tbl.dataList.GroupBy(x => x.GetPropertyValueFromName(field))
                   .Select(g => new
     {
         Field = g.Key,
         Count = g.Select(l => l.GetPropertyValueFromName(field)).Count()
     }).OrderByDescending(x => x.Count);
 }
Example #5
0
        public static IEnumerable <IDataTbl> GetTblsWhereFieldIsValue(IDataOptions tbl, string field, IEnumerable <int> vals)
        {
            var results = new List <IDataTbl>();

            foreach (var val in vals)
            {
                results.Add(tbl.dataList.Where(x => x.GetPropertyValueFromName(field) == val.ToString()).FirstOrDefault());
            }

            return(results);
        }
Example #6
0
        public void ReplaceBattles(IDataOptions replacement)
        {
            foreach (Battle replBattle in replacement.dataList)
            {
                var ogBattleSpiritTitle = GetBattle(replBattle.battle_id).combinedMsbtTitle;

                _dataList[GetBattleIndex(replBattle.battle_id)] = replBattle;

                if (String.IsNullOrWhiteSpace(replBattle.combinedMsbtTitle))
                {
                    _dataList[GetBattleIndex(replBattle.battle_id)].SetSpiritTitleParameters(ogBattleSpiritTitle);
                }
            }
        }
Example #7
0
 public void UpdateDataOptions(IDataOptions options)
 {
     RemoveDataOptions(options);
     dataOptions.Add(options);
 }
Example #8
0
        public void RemoveDataOptions(IDataOptions options)
        {
            IDataOptions oldOptions = GetOptionsOfType(options.GetType());

            dataOptions.Remove(oldOptions);
        }
Example #9
0
 public IDataOptions GetDataOptions(IDataOptions options)
 {
     return(GetOptionsOfType(options.GetType()));
 }
Example #10
0
 public void AddDataOptions(IDataOptions options)
 {
     dataOptions.Add(options);
 }
Example #11
0
            public ICondition Resolve(string method, string keyword, string filter = null, IDataOptions options = null)
            {
                if (string.IsNullOrWhiteSpace(keyword))
                {
                    return(null);
                }

                var index = keyword.IndexOf(':');

                if (!_mapping.TryGetValue(index < 0 ? string.Empty : keyword.Substring(0, index).Trim(), out var token))
                {
                    return(null);
                }

                if (token.Members.Length == 1)
                {
                    return(GetCondition(token.Members[0], keyword.Substring(index + 1).Trim()));
                }

                var conditions = new ConditionCollection(token.Combination);

                foreach (var member in token.Members)
                {
                    conditions.Add(GetCondition(member, keyword.Substring(index + 1).Trim()));
                }

                return(conditions);