Пример #1
0
        public Histogram2(MapStatistics ms, IFeatureLayer featurelayer)
        {
            InitializeComponent();
            _ms           = ms;
            _featurelayer = featurelayer;
            _ms._pm.Axes.Clear();
            _cs.FillColor        = OxyColors.BlueViolet;
            _cs.ColumnWidth      = 2;
            _cs.Selectable       = true;
            _cs.IsStacked        = true;
            _select_cs.IsStacked = true;


            _select_cs.FillColor   = OxyColors.Cyan;
            _select_cs.ColumnWidth = 2;

            _ms._pm.Axes.Add(_ms._CAxis);
            _ms._pm.Axes.Add(_ms._YAxis);


            _ms._pm.Series.Add(_select_cs);
            _ms._pm.Series.Add(_cs);
            _ms.plotView1.Model = _ms._pm;

            _ms._pm.MouseDown += PlotMouseDown;
            _ms._pm.MouseMove += PlotMouseMove;
            _ms._pm.MouseUp   += PlotMouseUp;

            _featurelayer.SelectionChanged += new EventHandler(_featureLayer_SelectionChanged);
            cmbInterval.Items.AddRange(new object[] { 3, 4, 5, 6, });

            if (flag == 2)
            {
                foreach (DataColumn col in _featurelayer.DataSet.DataTable.Columns)
                {
                    cmbStasticField.Items.Clear();
                    cmbStasticField.Items.Add(col.Caption);
                    //if (col.DataType != typeof(double) && col.DataType != typeof(Single) && col.DataType != typeof(float) && col.DataType != typeof(int))
                    //{
                    //    cmbStasticField.Items.Add(col.Caption);
                    //}
                }
            }

            else
            {
                foreach (DataColumn col in _featurelayer.DataSet.DataTable.Columns)
                {
                    // cmbStasticField.Items.Clear();
                    if (col.DataType == typeof(double) || col.DataType == typeof(Single) || col.DataType == typeof(float) || col.DataType == typeof(int))
                    {
                        cmbStasticField.Items.Add(col.Caption);
                    }
                }
            }
        }
Пример #2
0
 public void SetUp()
 {
     _stats = new MapStatistics()
     {
         TotalPlayed = 10,
         TotalWon    = 4,
         TotalLost   = 4,
         TotalDrawn  = 2,
         Map         = "Foo"
     };
 }
Пример #3
0
        public string MapStatisticsString()
        {
            string stats = string.Empty;

            stats += $"# of Rooms: {MapStatistics.NumberOfRooms}{Environment.NewLine}";
            stats += $"# of Dark Rooms: {MapStatistics.NumberOfDarkRooms}{Environment.NewLine}";
            stats += $"# of Unconnected Rooms: {MapStatistics.NumberOfFloatingRooms}{Environment.NewLine}";

            stats += $"{Environment.NewLine}";

            if (MapStatistics.NumberOfStartRooms == 1)
            {
                stats += $"Start room = {MapStatistics.StartRoomName}";
            }
            else if (MapStatistics.NumberOfStartRooms == 2)
            {
                stats += $"More than one start room.";
            }
            else
            {
                stats += $"No start room.";
            }
            stats += $"{Environment.NewLine}";

            stats += $"{Environment.NewLine}";
            stats += $"# of Connections: {MapStatistics.NumberOfConnections}{Environment.NewLine}";
            stats += $"# of Dangling Connections: {MapStatistics.NumberOfDanglingConnections}{Environment.NewLine}";
            stats += $"# of Self Looping Connections: {MapStatistics.NumberOfLoopingConnections}{Environment.NewLine}";

            stats += $"# of Dead Ends: {MapStatistics.NumberOfDeadEnds}{Environment.NewLine}";

            stats += $"{Environment.NewLine}";
            stats += $"# of Regions: {MapStatistics.NumberOfRegions}{Environment.NewLine}";
            stats += $"# of Rooms without a region: {MapStatistics.NumberOfRoomsWithoutRegion()}{Environment.NewLine}";

            if (MapStatistics.NumberOfRegions > 0)
            {
                stats += $"Regions:{Environment.NewLine}";
                foreach (var region in Settings.Regions.OrderBy(p => p.RegionName).Where(p => p.RegionName != Trizbort.Region.DefaultRegion))
                {
                    var numberOfRoomsInRegion = MapStatistics.NumberOfRoomsInRegion(region.RegionName);
                    stats += string.Format("{2} ({0} {3}){1}", numberOfRoomsInRegion, Environment.NewLine, region.RegionName, numberOfRoomsInRegion == 1 ? "room" : "rooms");
                }
            }

            stats += $"{Environment.NewLine}";
            stats += $"Total # Objects in All Rooms: {MapStatistics.NumberOfTotalObjectsInRooms}{Environment.NewLine}";
            stats += $"Total # Rooms with Objects: {MapStatistics.NumberOfRoomsWithObjects}{Environment.NewLine}";

            return(stats);
        }
Пример #4
0
        protected override void ExportContent(TextWriter writer)
        {
            var anyConditionalExits = false;

            if (MapStatistics.NumberOfRoomsWithoutRegion() > 0)
            {
                writer.WriteLine("book Regionless Rooms");
                writer.WriteLine();
            }

            foreach (var location in LocationsInExportOrder)
            {
                if (location.Room.Region != "NoRegion")
                {
                    continue;
                }
                anyConditionalExits |= printThisLoc(writer, location);
            }

            // export regions
            foreach (var region in RegionsInExportOrder)
            {
                writer.WriteLine("book {0}", getExportName(region.ExportName, null));
                writer.WriteLine();
                writer.WriteLine("There is a region called {0}.", getExportName(region.ExportName, null));
                writer.WriteLine();
                // export each location
                foreach (var location in LocationsInExportOrder)
                {
                    if (location.Room.Region != region.ExportName)
                    {
                        continue;
                    }
                    anyConditionalExits |= printThisLoc(writer, location);
                }
            }

            if (anyConditionalExits)
            {
                writer.WriteLine("book conditional exit warning");
                writer.WriteLine();
                writer.WriteLine("To block conditional exits:");
                writer.WriteLine(
                    "\tsay \"An export nymph appears on your keyboard. She says, 'You can't go that way, as that exit was marked as conditional, you know, a dotted line, in Trizbort. Obviously in your game you'll have a better rationale for this than, er, me.' She looks embarrassed. 'Bye!'\"");
                writer.WriteLine();
            }
        }
        public void OnCreation_CalculatesStatisticsPerMap_ForAllMaps_ExceptNA_WithCorrectValues()
        {
            // Arrange
            MapWinRatesViewModel vm = new MapWinRatesViewModel(_profileManager);

            // Act
            IEnumerable <MapStatistics> stats = vm.Stats;

            // Assert
            Assert.AreEqual(Maps.All.Length - 1, stats.Count());

            MapStatistics matchOneStats = stats.First(s => s.Map == Maps.All.ElementAt(1));

            Assert.AreEqual(2, matchOneStats.TotalWon);
            Assert.AreEqual(0, matchOneStats.TotalLost);
            Assert.AreEqual(0, matchOneStats.TotalDrawn);
        }
Пример #6
0
        protected override void EmitInternal(TextWriter tw, DataStore data)
        {
            var games = data.Records;
            var table = from g in games.GroupBy((g) => g.Map)
                        let total                                                                                                                                                                                                                                                                               = g.Count()
                                                                                                let TvZ                                                                                                                                                                                                         = g.CalcRaceStat(Race.Terran, Race.Zerg)
                                                                                                                                                            let ZvP                                                                                                                                             = g.CalcRaceStat(Race.Zerg, Race.Protoss)
                                                                                                                                                                                                              let PvT                                                                                           = g.CalcRaceStat(Race.Protoss, Race.Terran)
                                                                                                                                                                                                                                                      let TvT                                                   = g.Where(Predicates.Matchup(Race.Terran)).Count()
                                                                                                                                                                                                                                                                                    let ZvZ                     = g.Where(Predicates.Matchup(Race.Zerg)).Count()
                                                                                                                                                                                                                                                                                                        let PvP = g.Where(Predicates.Matchup(Race.Protoss)).Count()
                                                                                                                                                                                                                                                                                                                  orderby g.Key
                                                                                                                                                                                                                                                                                                                  select new { g.Key, total, TvZ, ZvP, PvT, TvT, ZvZ, PvP };

            var ov = new
            {
                total = games.Count(),
                TvZ   = games.CalcRaceStat(Race.Terran, Race.Zerg),
                ZvP   = games.CalcRaceStat(Race.Zerg, Race.Protoss),
                PvT   = games.CalcRaceStat(Race.Protoss, Race.Terran),
                TvT   = games.Where(Predicates.Matchup(Race.Terran)).Count(),
                ZvZ   = games.Where(Predicates.Matchup(Race.Zerg)).Count(),
                PvP   = games.Where(Predicates.Matchup(Race.Protoss)).Count(),
            };

            var template = new MapStatistics();

            template.Params = new Bag(
                "total", ov.total.ToString(),
                "TvT", ov.TvT != 0 ? ov.TvT.ToString() : "-",
                "ZvZ", ov.ZvZ != 0 ? ov.ZvZ.ToString() : "-",
                "PvP", ov.PvP != 0 ? ov.PvP.ToString() : "-")
                              .TotalWinLossPercentage("TvZ", ov.TvZ)
                              .TotalWinLossPercentage("ZvP", ov.ZvP)
                              .TotalWinLossPercentage("PvT", ov.PvT);
            template.Rows = table.Select((r) => new Bag(
                                             "map", string.IsNullOrWhiteSpace(r.Key) ? "Unknown" : ("[[" + r.Key + "]]"),
                                             "total", r.total.ToString(),
                                             "TvT", r.TvT != 0 ? r.TvT.ToString() : "-",
                                             "ZvZ", r.ZvZ != 0 ? r.ZvZ.ToString() : "-",
                                             "PvP", r.PvP != 0 ? r.PvP.ToString() : "-")
                                         .TotalWinLossPercentage("TvZ", r.TvZ)
                                         .TotalWinLossPercentage("ZvP", r.ZvP)
                                         .TotalWinLossPercentage("PvT", r.PvT));
            tw.Write(template.TransformText());
        }
Пример #7
0
 public GameData()
 {
     Animations         = new List <AnimationBase>();
     Textures           = new TextureContainer();
     MapStatistics      = new MapStatistics();
     Sprites            = new List <SpriteBase>();
     DeadSprites        = new List <SpriteBase>();
     Focus              = null; //Init the focus to null to not follow any creatures
     FocusIndex         = -1;
     HighlightSprite    = false;
     SpriteMarkers      = false;
     ShowChart          = true;
     ShowControls       = true;
     ShowDebugData      = false;
     ShowSettingsPanel  = false;
     ResetGame          = false;
     BuildSettingsPanel = false;
 }
Пример #8
0
        public string MapStatisticsString()
        {
            string stats = string.Empty;

            if (MapStatistics.NumberOfRooms == 0)
            {
                return("No rooms to take stats of.");
            }

            stats += $"# of Rooms: {MapStatistics.NumberOfRooms}{Environment.NewLine}";
            stats += $"# of Dark Rooms: {MapStatistics.NumberOfDarkRooms}{Environment.NewLine}";
            stats += $"# of Unconnected Rooms: {MapStatistics.NumberOfFloatingRooms}{Environment.NewLine}";

            stats += $"{Environment.NewLine}";

            if (MapStatistics.NumberOfStartRooms == 1)
            {
                stats += $"Start room = {MapStatistics.StartRoomName}";
            }
            else if (MapStatistics.NumberOfStartRooms > 1)
            {
                stats += $"More than one start room.";
            }
            else
            {
                stats += $"No start room.";
            }
            stats += $"{Environment.NewLine}";

            if (MapStatistics.NumberOfEndRooms == 1)
            {
                stats += $"End room = {MapStatistics.EndRoomName}";
            }
            else if (MapStatistics.NumberOfEndRooms > 1)
            {
                stats += $"End rooms = ({MapStatistics.EndRoomName})";
            }
            else
            {
                stats += $"No end room.";
            }
            stats += $"{Environment.NewLine}";

            var canvasBounds = Project.Current.Canvas.ComputeCanvasBounds(true);

            stats += $"{Environment.NewLine}Dimensions with margins: height {canvasBounds.Bottom - canvasBounds.Top}, width {canvasBounds.Right - canvasBounds.Left}{Environment.NewLine}";

            canvasBounds = Project.Current.Canvas.ComputeCanvasBounds(false);
            stats       += $"Dimensions without margins: height {canvasBounds.Bottom - canvasBounds.Top}, width {canvasBounds.Right - canvasBounds.Left}{Environment.NewLine}";

            stats += $"{Environment.NewLine}";
            stats += $"# of Connections: {MapStatistics.NumberOfConnections} total, {MapStatistics.UnlabeledConnections} unlabeled, " +
                     $"{MapStatistics.NumberOfOneWayConnections} one-way, {MapStatistics.NumberOfDottedConnections} dashed/dotted, " +
                     $"{MapStatistics.UpDown} up/down, {MapStatistics.InOut} in/out.{Environment.NewLine}";
            stats += $"# of Dangling Connections: {MapStatistics.NumberOfDanglingConnections}{Environment.NewLine}";
            stats += $"# of Self Looping Connections: {MapStatistics.NumberOfLoopingConnections}{Environment.NewLine}";

            stats += $"# of Dead Ends: {MapStatistics.NumberOfDeadEnds}{Environment.NewLine}";

            stats += $"{Environment.NewLine}";
            stats += string.Format("{0} door{1}, {2} locked, {3} lockable, {4} open, {5} openable{6}",
                                   MapStatistics.NumberOfDoors, plur(MapStatistics.NumberOfDoors),
                                   MapStatistics.NumberOfLockedDoors, MapStatistics.NumberOfLockableDoors, MapStatistics.NumberOfOpenDoors, MapStatistics.NumberOfOpenableDoors,
                                   Environment.NewLine);

            stats += $"{Environment.NewLine}";
            stats += $"# of Regions: {MapStatistics.NumberOfRegions}{Environment.NewLine}";
            stats += $"# of Rooms without a region: {MapStatistics.NumberOfRoomsWithoutRegion()}{Environment.NewLine}";

            if (MapStatistics.NumberOfRegions > 0)
            {
                stats += $"Regions:{Environment.NewLine}";
                foreach (var region in Settings.Regions.OrderBy(p => p.RegionName).Where(p => p.RegionName != Trizbort.Region.DefaultRegion))
                {
                    var numberOfRoomsInRegion = MapStatistics.NumberOfRoomsInRegion(region.RegionName);
                    stats += string.Format("{2} ({0} {3}){1}", numberOfRoomsInRegion, Environment.NewLine, region.RegionName, numberOfRoomsInRegion == 1 ? "room" : "rooms");
                }
            }

            stats += $"{Environment.NewLine}";
            stats += $"Total # Objects in All Rooms: {MapStatistics.NumberOfTotalObjectsInRooms}{Environment.NewLine}";
            stats += $"Total # Rooms with Objects: {MapStatistics.NumberOfRoomsWithObjects}, {MapStatistics.NumberOfRoomsWithXObjects(1, false)} with 1, " +
                     $"{MapStatistics.NumberOfRoomsWithXObjects(2, false)} with 2, {MapStatistics.NumberOfRoomsWithXObjects(3, true)} with 3+{Environment.NewLine}";

            stats += $"{Environment.NewLine}";
            stats += $"Total # of Rooms with subtitles: {MapStatistics.NumberOfRoomsWithSubtitles}{Environment.NewLine}";
            stats += $"Total # of Rooms with descriptions: {MapStatistics.NumberOfDescribedRooms}{Environment.NewLine}";

            stats += $"{Environment.NewLine}{new String('=', 30)}Odd stuff below here{Environment.NewLine}";

            stats += $"{Environment.NewLine}Duplicate rooms: {MapStatistics.DuplicateNamedRooms}.{Environment.NewLine}";

            stats += $"{Environment.NewLine}Room shapes: {MapStatistics.NumberOfRectangularRooms} rectangular, {MapStatistics.NumberOfEllipticalRooms} elliptical, " +
                     $"{MapStatistics.NumberOfRoundCornerRooms} round cornered, {MapStatistics.NumberOfOctagonalRooms} octagonal.{Environment.NewLine}";

            if (MapStatistics.NumberOfRegions > 0)
            {
                stats += $"{Environment.NewLine}";
                foreach (var region in Settings.Regions.OrderBy(p => p.RegionName).Where(p => p.RegionName != Trizbort.Region.DefaultRegion))
                {
                    if (MapStatistics.NumberOfRoomsInRegion(region.RegionName) == 0)
                    {
                        stats += $"{region.RegionName} has no rooms.";
                    }
                    else if (MapStatistics.NumberOfRoomsInRegion(region.RegionName) == 1)
                    {
                        stats += $"Only room in {region.RegionName}: ";
                    }
                    else
                    {
                        stats += $"List of rooms in {region.RegionName}: ";
                    }

                    var roomsInRegion = Project.Current.Elements.OfType <Room>().ToArray().OrderBy(p => p.Name).Where(p => p.Region == region.RegionName);
                    stats += string.Join(", ", roomsInRegion.Select(x => x.Name).ToArray()) + Environment.NewLine;
                }
                stats += $"{Environment.NewLine}";
            }
            else if (MapStatistics.NumberOfRegions > 1)
            {
                stats += $"{Environment.NewLine}Region Links:{Environment.NewLine}";
                var allRegions = Settings.Regions.OrderBy(p => p.RegionName).Where(p => p.RegionName != Trizbort.Region.DefaultRegion);
                foreach (var region1 in allRegions)
                {
                    var linkedRegions = string.Join(", ", Settings.Regions.OrderBy(p => p.RegionName).ToArray().Where(p => MapStatistics.RegionsLinked(region1, p)).Select(x => x.RegionName));

                    stats += $"{Environment.NewLine}";

                    if (linkedRegions == string.Empty)
                    {
                        stats += $"{region1.RegionName} is not linked to any other regions.";
                    }
                    else
                    {
                        stats += $"{region1.RegionName} is linked to {linkedRegions}.";
                    }
                }
                stats += $"{Environment.NewLine}";
            }
            else
            {
                stats += $"{Environment.NewLine}";
            }

            stats += string.Format("{0} up-down connection{1}{2}", MapStatistics.UpDown, plur(MapStatistics.UpDown), Environment.NewLine);
            stats += string.Format("{0} in-out connection{1}{2}", MapStatistics.InOut, plur(MapStatistics.InOut), Environment.NewLine);
            stats += string.Format("{0} custom {1}connection{2}", MapStatistics.CustomConnections, plur(MapStatistics.CustomConnections), Environment.NewLine);
            stats += string.Format("{0} diagonal connection{1} (2-way){2}", MapStatistics.DiagonalConnections(2),
                                   plur(MapStatistics.DiagonalConnections(2)), Environment.NewLine);
            stats += string.Format("{0} diagonal connection{1} (1-way){2}", MapStatistics.DiagonalConnections(1),
                                   plur(MapStatistics.DiagonalConnections(1)), Environment.NewLine);
            stats += string.Format("{0} connection{1} with middle text{2}", MapStatistics.HasMiddleText, plur(MapStatistics.HasMiddleText), Environment.NewLine);
            stats += string.Format("{0} bent connection{1}, {2} with no text{3}", MapStatistics.BentConnections(true), plur(MapStatistics.BentConnections(true)),
                                   MapStatistics.BentConnections(false), Environment.NewLine);
            stats += Environment.NewLine;

            stats += MapStatistics.DupConnectionList("in") + Environment.NewLine;
            stats += MapStatistics.DupConnectionList("out") + Environment.NewLine;
            stats += MapStatistics.DupConnectionList("up") + Environment.NewLine;
            stats += MapStatistics.DupConnectionList("down") + Environment.NewLine;

            return(stats);
        }