示例#1
0
        /// <summary>
        /// Allows <see cref="schema"/> upgrade after additional analysis of the stored <see cref="entries"/>. This should be called after <see cref="SetEntries(SourceTable)"/>.
        /// </summary>
        /// <param name="analyser">Content analyser to be used</param>
        public void RefineSchema(CellContentAnalysis analyser)
        {
            //  DataTable output = new DataTable("schemaTable");

            foreach (var property in properties.items)
            {
                var propData = entries.GetAllValuesForProperty(property);

                if (propData.Count == 0)
                {
                }
                else
                {
                    RefinedPropertyStats propertyStats = new RefinedPropertyStats();

                    foreach (var data in propData)
                    {
                        CellContentInfo info = analyser.DetermineContentType(data);

                        propertyStats.Assign(info);
                    }

                    propertyStats.Compute();

                    propertyStats.Deploy(property);

                    //  GetColumn(property, output, propertyStats);
                }
            }
        }
示例#2
0
 public IReadOnlyCollection <ICellContentInfo> ClearDeadCells()
 {
     return(this.battlefield.Cells
            .Where(cell => !cell.IsEmpty && !cell.Content.IsAlive)
            .Select(cell =>
     {
         var result = new CellContentInfo(cell);
         cell.Pop();
         return result;
     })
            .ToList());
 }
        /// <summary>
        /// Performs a test on
        /// </summary>
        /// <param name="sourceTable">The source table.</param>
        /// <param name="type">The type.</param>
        /// <param name="i">The i.</param>
        /// <returns></returns>
        public SourceTableSliceTest MakeSliceTest(SourceTable sourceTable, SourceTableSliceType type, Int32 i = 0)
        {
            SourceTableSliceTest output = new SourceTableSliceTest()
            {
                format = type
            };

            switch (type)
            {
            case SourceTableSliceType.row:
                output.Values = sourceTable.GetRow(i);
                break;

            default:
            case SourceTableSliceType.column:
                output.Values = sourceTable.GetColumn(i);
                break;
            }

            CellContentType contentType    = CellContentType.unknown;
            List <String>   DistinctValues = new List <string>();

            foreach (var v in output.Values)
            {
                CellContentInfo t = sourceContentAnalysis.DetermineContentType(v);
                if (contentType == CellContentType.unknown)
                {
                    contentType = t.type;
                }
                else if (contentType != t.type)
                {
                    if (!t.type.HasFlag(contentType))
                    {
                        output.IsUniformFormat = false;
                    }
                }

                if (v.IsNullOrEmpty())
                {
                    output.IsNoEmptyValue = false;
                }
                if (!DistinctValues.Contains(v))
                {
                    DistinctValues.Add(v);
                }
            }
            if (DistinctValues.Count < output.Values.Count)
            {
                output.IsDistinctValue = false;
            }
            return(output);
        }
示例#4
0
文件: Program.cs 项目: vblz/TankFight
        private static IMapInfo GenerateMapInfo()
        {
            var data = JsonConvert.DeserializeObject <JObject>(File.ReadAllText(@"d:/maps/1/objects.json"));
            var map  = new MapInfo
            {
                Height = data["Height"].Value <byte>(),
                Width  = data["Width"].Value <byte>(),
            };

            List <ICellContentInfo> objects = new List <ICellContentInfo>();

            foreach (var mapObject in data["MapObjects"].Children())
            {
                var x = mapObject["Coordinates"]["X"].Value <int>();
                var y = mapObject["Coordinates"]["Y"].Value <int>();

                switch (mapObject["CellContentType"].Value <string>())
                {
                case "Barrier":
                    byte health = mapObject["HealthCount"].Value <byte>();
                    objects.Add(CellContentInfo.Barrier(x, y, health));
                    break;

                case "NotDestroyable":
                    objects.Add(CellContentInfo.Mountain(x, y));
                    break;

                case "Spawn":
                    objects.Add(CellContentInfo.Spawn(x, y));
                    break;

                case "Water":
                    objects.Add(CellContentInfo.Water(x, y));
                    break;
                }
            }


            objects.Add(CellContentInfo.Spawn(1, 1));
            objects.Add(CellContentInfo.Spawn(1, 2));

            map.MapObjects = objects.AsReadOnly();
            return(map);
        }
示例#5
0
        private IMapInfo LoadMap(BattleInfo loadingBattleInfo)
        {
            // FIXME код из TestConsole. Отрефакторить.
            var data = JsonConvert.DeserializeObject <JObject>(File.ReadAllText(Path.Combine(loadingBattleInfo.Map, "objects.json")));
            var map  = new MapInfo
            {
                Height = data["Height"].Value <byte>(),
                Width  = data["Width"].Value <byte>(),
            };

            List <ICellContentInfo> objects = new List <ICellContentInfo>();

            foreach (var mapObject in data["MapObjects"].Children())
            {
                var x = mapObject["Coordinates"]["X"].Value <int>();
                var y = mapObject["Coordinates"]["Y"].Value <int>();

                switch (mapObject["CellContentType"].Value <string>())
                {
                case "Barrier":
                    byte health = mapObject["HealthCount"].Value <byte>();
                    objects.Add(CellContentInfo.Barrier(x, y, health));
                    break;

                case "NotDestroyable":
                    objects.Add(CellContentInfo.Mountain(x, y));
                    break;

                case "Spawn":
                    objects.Add(CellContentInfo.Spawn(x, y));
                    break;

                case "Water":
                    objects.Add(CellContentInfo.Water(x, y));
                    break;
                }
            }

            map.MapObjects = objects.AsReadOnly();
            return(map);
        }