コード例 #1
0
ファイル: Tests.cs プロジェクト: lordliquid/WurmTools
        public void testTunnelFlint()
        {
            AnalyzeMap    map    = new AnalyzeMap(7, 7);
            AnalyzeResult result = new AnalyzeResult(new List <AnalyzeMatch>(new AnalyzeMatch[] { new AnalyzeMatch(3, "iron ore", "utmost", "west of north"), new AnalyzeMatch(3, "flint", null, "west of north"), new AnalyzeMatch(3, "salt", null, "west of north") }));

            map.SetResult(3, 3, result);

            Assert.IsNotNull(map[new Tile(1, 0)].Estimates);
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Iron, Quality.Utmost)));
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)));
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Salt, Quality.Unknown)));
            Assert.IsNotNull(map[new Tile(2, 0)].Estimates);
            Assert.IsTrue(map[new Tile(2, 0)].Estimates.Contains(new Detected(TileType.Iron, Quality.Utmost)));
            Assert.IsTrue(map[new Tile(2, 0)].Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)));
            Assert.IsTrue(map[new Tile(2, 0)].Estimates.Contains(new Detected(TileType.Salt, Quality.Unknown)));

            map[new Tile(1, 0)].Set(new Detected(TileType.Tunnel, Quality.Unknown));
            Assert.IsNotNull(map[new Tile(1, 0)].Estimates);
            Assert.AreEqual(TileType.Tunnel, map[new Tile(1, 0)].Type);
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)));
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Salt, Quality.Unknown)));

            map.Refresh();

            Assert.IsNotNull(map[new Tile(2, 0)].Estimates);
            Assert.AreEqual(TileType.Iron, map[new Tile(2, 0)].Type);
            Assert.AreEqual(Quality.Utmost, map[new Tile(2, 0)].Quality);
            Assert.IsTrue(map[new Tile(2, 0)].Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)));
            Assert.IsTrue(map[new Tile(2, 0)].Estimates.Contains(new Detected(TileType.Salt, Quality.Unknown)));
            Assert.IsNotNull(map[new Tile(1, 0)].Estimates);
            Assert.AreEqual(TileType.Tunnel, map[new Tile(1, 0)].Type);
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)));
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Salt, Quality.Unknown)));
        }
コード例 #2
0
        private void gridControl1_DragDrop(object sender, DragEventArgs e)
        {
            Point pt = gridControl1.PointToClient(new Point(e.X, e.Y));

            System.Diagnostics.Debug.Print("DragDrop {0},{1}", pt.X, pt.Y);
            AnalyzeResult result = e.Data.GetData(typeof(AnalyzeResult)) as AnalyzeResult;

            if (result != null)
            {
                GridControl.Cell cell = gridControl1.CellFromPoint(pt.X, pt.Y);
                if (cell != null)
                {
                    map.SetResult(cell.X, cell.Y, result);
                    gridControl1.Redraw();
                }
            }
        }
コード例 #3
0
ファイル: Tests.cs プロジェクト: lordliquid/WurmTools
        public void testSetSomething()
        {
            AnalyzeMap    map    = new AnalyzeMap(7, 7);
            AnalyzeResult result = new AnalyzeResult(new List <AnalyzeMatch>(new AnalyzeMatch[] { new AnalyzeMatch(3, "something", null, "northwest") }));

            map.SetResult(3, 3, result);

            Assert.IsNotNull(map[new Tile(0, 0)].Estimates);
            foreach (TileType tileType in resourceTypes)
            {
                Assert.IsTrue(map[new Tile(0, 0)].Estimates.Contains(new Detected(tileType, Quality.Unknown)), "Expected " + tileType);
            }
            foreach (TileType tileType in oreTypes)
            {
                Assert.IsTrue(map[new Tile(0, 0)].Estimates.Contains(new Detected(tileType, Quality.Unknown)), "Expected " + tileType);
            }
            Assert.IsNull(map[new Tile(0, 0)].Found);
        }
コード例 #4
0
ファイル: Tests.cs プロジェクト: lordliquid/WurmTools
        public void testSaltIronFlint()
        {
            AnalyzeMap    map    = new AnalyzeMap(3, 3);
            AnalyzeResult result = new AnalyzeResult(new List <AnalyzeMatch>(new AnalyzeMatch[] { new AnalyzeMatch(1, "iron ore", "utmost", "southeast"), new AnalyzeMatch(1, "salt", null, "southeast"), new AnalyzeMatch(1, "flint", null, "southeast") }));

            map.SetResult(1, 1, result);

            Tile tile = new Tile(2, 2);

            Assert.IsNull(map[tile].Estimates);
            Assert.IsNotNull(map[tile].Found);
            Assert.IsTrue(map[tile].HasSalt);
            Assert.IsTrue(map[tile].HasFlint);
            Assert.AreEqual(TileType.Iron, map[tile].Found.Type);
            Assert.AreEqual(Quality.Utmost, map[tile].Found.Quality);
            TileStatus status = map[tile];
            String     text   = status.ToString();
        }
コード例 #5
0
ファイル: AnalyzeMap.cs プロジェクト: ago1024/WurmTools
        public static AnalyzeMap Load_1_2(XPathNavigator nav)
        {
            IXmlNamespaceResolver resolver = new MyNamespaceResolver();
            XPathNavigator root = nav.SelectSingleNode("//atm:AnalyzeMap", resolver);
            Double w = (Double) root.Evaluate("number(@width)");
            Double h = (Double) root.Evaluate("number(@height)");

            AnalyzeMap map = new AnalyzeMap((int)w, (int)h);

            XPathNodeIterator iter;
            iter = root.Select("atm:Tile", resolver);
            while (iter.MoveNext())
            {
                int x = (int)(Double)iter.Current.Evaluate("number(@x)");
                int y = (int)(Double)iter.Current.Evaluate("number(@y)");
                String type = (String)iter.Current.Evaluate("string(@type)");
                String quality = (String)iter.Current.Evaluate("string(@quality)");
                Boolean hasSalt = (Boolean)iter.Current.Evaluate("@salt = 'true'");
                Boolean hasFlint = (Boolean)iter.Current.Evaluate("@flint = 'true'");
                if (map.IsValidTile(x, y))
                {
                    map[x, y].Type = (TileType)Enum.Parse(typeof(TileType), type);
                    int exactQL;
                    if (quality != null && quality.Length != 0)
                    {
                        if (Int32.TryParse(quality, out exactQL))
                        {
                            map[x, y].ExactQuality = exactQL;
                        }
                        else
                        {
                            map[x, y].Quality = (Quality)Enum.Parse(typeof(Quality), quality);
                        }
                    }
                    if (hasSalt)
                        map[x, y].HasSalt = true;
                    if (hasFlint)
                        map[x, y].HasFlint = true;
                }
                else
                {
                    throw new Exception(String.Format("Tile {0},{1} is not valid for the map", x, y));
                }
            }

            iter = root.Select("atm:Analyze", resolver);
            while (iter.MoveNext())
            {
                int x = (int)(Double)iter.Current.Evaluate("number(@x)");
                int y = (int)(Double)iter.Current.Evaluate("number(@y)");

                List<AnalyzeMatch> matches = new List<AnalyzeMatch>();
                XPathNodeIterator entry = iter.Current.Select("atm:Entry", resolver);
                while (entry.MoveNext())
                {
                    String type = (String)entry.Current.Evaluate("string(@type)");
                    String quality = (String)entry.Current.Evaluate("string(@quality)");
                    String direction = (String)entry.Current.Evaluate("string(@direction)");
                    int distance = (int)(Double)entry.Current.Evaluate("number(@distance)");

                    if (type != null && type.Length == 0)
                        type = null;
                    if (quality != null && quality.Length == 0)
                        quality = null;
                    if (direction != null && direction.Length == 0)
                        direction = null;

                    matches.Add(new AnalyzeMatch(distance, type, quality, direction));
                }

                AnalyzeResult result = new AnalyzeResult(matches);
                result.X = x;
                result.Y = y;
                map.SetResult(x, y, result);
            }

            return map;
        }
コード例 #6
0
ファイル: Tests.cs プロジェクト: ago1024/WurmTools
        public void testTunnelFlint()
        {
            AnalyzeMap map = new AnalyzeMap(7, 7);
            AnalyzeResult result = new AnalyzeResult(new List<AnalyzeMatch>(new AnalyzeMatch[] { new AnalyzeMatch(3, "iron ore", "utmost", "west of north"), new AnalyzeMatch(3, "flint", null, "west of north"), new AnalyzeMatch(3, "salt", null, "west of north") }));
            map.SetResult(3, 3, result);

            Assert.IsNotNull(map[new Tile(1, 0)].Estimates);
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Iron, Quality.Utmost)));
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)));
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Salt, Quality.Unknown)));
            Assert.IsNotNull(map[new Tile(2, 0)].Estimates);
            Assert.IsTrue(map[new Tile(2, 0)].Estimates.Contains(new Detected(TileType.Iron, Quality.Utmost)));
            Assert.IsTrue(map[new Tile(2, 0)].Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)));
            Assert.IsTrue(map[new Tile(2, 0)].Estimates.Contains(new Detected(TileType.Salt, Quality.Unknown)));

            map[new Tile(1, 0)].Set(new Detected(TileType.Tunnel, Quality.Unknown));
            Assert.IsNotNull(map[new Tile(1, 0)].Estimates);
            Assert.AreEqual(TileType.Tunnel, map[new Tile(1, 0)].Type);
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)));
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Salt, Quality.Unknown)));

            map.Refresh();

            Assert.IsNotNull(map[new Tile(2, 0)].Estimates);
            Assert.AreEqual(TileType.Iron, map[new Tile(2, 0)].Type);
            Assert.AreEqual(Quality.Utmost, map[new Tile(2, 0)].Quality);
            Assert.IsTrue(map[new Tile(2, 0)].Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)));
            Assert.IsTrue(map[new Tile(2, 0)].Estimates.Contains(new Detected(TileType.Salt, Quality.Unknown)));
            Assert.IsNotNull(map[new Tile(1, 0)].Estimates);
            Assert.AreEqual(TileType.Tunnel, map[new Tile(1, 0)].Type);
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)));
            Assert.IsTrue(map[new Tile(1, 0)].Estimates.Contains(new Detected(TileType.Salt, Quality.Unknown)));
        }
コード例 #7
0
ファイル: Tests.cs プロジェクト: ago1024/WurmTools
        public void testSetSomething()
        {
            AnalyzeMap map = new AnalyzeMap(7, 7);
            AnalyzeResult result = new AnalyzeResult(new List<AnalyzeMatch>(new AnalyzeMatch[] { new AnalyzeMatch(3, "something", null, "northwest") }));
            map.SetResult(3, 3, result);

            Assert.IsNotNull(map[new Tile(0, 0)].Estimates);
            foreach (TileType tileType in resourceTypes)
            {
                Assert.IsTrue(map[new Tile(0, 0)].Estimates.Contains(new Detected(tileType, Quality.Unknown)), "Expected " + tileType);
            }
            foreach (TileType tileType in oreTypes)
            {
                Assert.IsTrue(map[new Tile(0, 0)].Estimates.Contains(new Detected(tileType, Quality.Unknown)), "Expected " + tileType);
            }
            Assert.IsNull(map[new Tile(0, 0)].Found);
        }
コード例 #8
0
ファイル: Tests.cs プロジェクト: ago1024/WurmTools
        public void testSaltIronFlint()
        {
            AnalyzeMap map = new AnalyzeMap(3, 3);
            AnalyzeResult result = new AnalyzeResult(new List<AnalyzeMatch>(new AnalyzeMatch[] { new AnalyzeMatch(1, "iron ore", "utmost", "southeast"), new AnalyzeMatch(1, "salt", null, "southeast"), new AnalyzeMatch(1, "flint", null, "southeast") }));
            map.SetResult(1, 1, result);

            Tile tile = new Tile(2, 2);
            Assert.IsNull(map[tile].Estimates);
            Assert.IsNotNull(map[tile].Found);
            Assert.IsTrue(map[tile].HasSalt);
            Assert.IsTrue(map[tile].HasFlint);
            Assert.AreEqual(TileType.Iron, map[tile].Found.Type);
            Assert.AreEqual(Quality.Utmost, map[tile].Found.Quality);
            TileStatus status = map[tile];
            String text = status.ToString();
        }
コード例 #9
0
ファイル: AnalyzeMap.cs プロジェクト: lordliquid/WurmTools
        public static AnalyzeMap Load_1_2(XPathNavigator nav)
        {
            IXmlNamespaceResolver resolver = new MyNamespaceResolver();
            XPathNavigator        root     = nav.SelectSingleNode("//atm:AnalyzeMap", resolver);
            Double w = (Double)root.Evaluate("number(@width)");
            Double h = (Double)root.Evaluate("number(@height)");

            AnalyzeMap map = new AnalyzeMap((int)w, (int)h);

            XPathNodeIterator iter;

            iter = root.Select("atm:Tile", resolver);
            while (iter.MoveNext())
            {
                int     x        = (int)(Double)iter.Current.Evaluate("number(@x)");
                int     y        = (int)(Double)iter.Current.Evaluate("number(@y)");
                String  type     = (String)iter.Current.Evaluate("string(@type)");
                String  quality  = (String)iter.Current.Evaluate("string(@quality)");
                Boolean hasSalt  = (Boolean)iter.Current.Evaluate("@salt = 'true'");
                Boolean hasFlint = (Boolean)iter.Current.Evaluate("@flint = 'true'");
                if (map.IsValidTile(x, y))
                {
                    map[x, y].Type = (TileType)Enum.Parse(typeof(TileType), type);
                    int exactQL;
                    if (quality != null && quality.Length != 0)
                    {
                        if (Int32.TryParse(quality, out exactQL))
                        {
                            map[x, y].ExactQuality = exactQL;
                        }
                        else
                        {
                            map[x, y].Quality = (Quality)Enum.Parse(typeof(Quality), quality);
                        }
                    }
                    if (hasSalt)
                    {
                        map[x, y].HasSalt = true;
                    }
                    if (hasFlint)
                    {
                        map[x, y].HasFlint = true;
                    }
                }
                else
                {
                    throw new Exception(String.Format("Tile {0},{1} is not valid for the map", x, y));
                }
            }

            iter = root.Select("atm:Analyze", resolver);
            while (iter.MoveNext())
            {
                int x = (int)(Double)iter.Current.Evaluate("number(@x)");
                int y = (int)(Double)iter.Current.Evaluate("number(@y)");

                List <AnalyzeMatch> matches = new List <AnalyzeMatch>();
                XPathNodeIterator   entry   = iter.Current.Select("atm:Entry", resolver);
                while (entry.MoveNext())
                {
                    String type      = (String)entry.Current.Evaluate("string(@type)");
                    String quality   = (String)entry.Current.Evaluate("string(@quality)");
                    String direction = (String)entry.Current.Evaluate("string(@direction)");
                    int    distance  = (int)(Double)entry.Current.Evaluate("number(@distance)");

                    if (type != null && type.Length == 0)
                    {
                        type = null;
                    }
                    if (quality != null && quality.Length == 0)
                    {
                        quality = null;
                    }
                    if (direction != null && direction.Length == 0)
                    {
                        direction = null;
                    }

                    matches.Add(new AnalyzeMatch(distance, type, quality, direction));
                }

                AnalyzeResult result = new AnalyzeResult(matches);
                result.X = x;
                result.Y = y;
                map.SetResult(x, y, result);
            }

            return(map);
        }