Beispiel #1
0
        public void testAddUnknown()
        {
            // If nothing has been detected on the tile mark this as result. Estimates is empty and found is set
            AnalyzeMap map = new AnalyzeMap(1, 1);
            Tile tile = new Tile(0, 0);
            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Nothing, Quality.Unknown) }));

            Assert.IsNull(map[tile].Estimates);
            Assert.IsNotNull(map[tile].Found);
            Assert.AreEqual(TileType.Nothing, map[tile].Found.Type);
        }
Beispiel #2
0
        public void testAdd()
        {
            // Setting a list of detected ores should set the estimates of the tile to exactly this list
            AnalyzeMap map = new AnalyzeMap(1, 1);
            Tile tile = new Tile(0, 0);
            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Iron, Quality.Unknown), new Detected(TileType.Silver, Quality.Unknown) }));

            Assert.IsNotNull(map[tile].Estimates);
            Assert.AreEqual(2, map[tile].Estimates.Count);
            Assert.IsTrue(map[tile].Estimates.Contains(new Detected(TileType.Iron, Quality.Unknown)));
            Assert.IsTrue(map[tile].Estimates.Contains(new Detected(TileType.Silver, Quality.Unknown)));
        }
Beispiel #3
0
 private void gridControl1_CellClick(object sender, GridControl.Cell cell, MouseEventArgs eventArgs)
 {
     if (eventArgs.Button == MouseButtons.Left && (Control.ModifierKeys & Keys.Control) != 0)
     {
         map[cell.X, cell.Y].SetEmpty();
         Recalculate();
     }
     else if (eventArgs.Button == MouseButtons.Left)
     {
         if (activeTool != null)
         {
             if (activeTool.UseTool(map, CellToTile(cell)))
             {
                 gridControl1.PaintCell(cell.X, cell.Y);
             }
         }
     }
     else if (eventArgs.Button == MouseButtons.Right)
     {
         PopupTile = CellToTile(cell);
         Rectangle rect = gridControl1.RectFromCell(cell.X, cell.Y);
         gridContextMenu.Show(gridControl1, new Point(eventArgs.Location.X + rect.Left, eventArgs.Y + rect.Top));
     }
 }
Beispiel #4
0
 private Bitmap GetTileQualityTexture(Tile tile)
 {
     Quality quality = map[tile.X, tile.Y].Quality;
     switch (quality)
     {
         case Quality.Poor:
         case Quality.Acceptable:
             return AnalyzeTool.Properties.Resources.qualitypoor;
         case Quality.Normal:
             return AnalyzeTool.Properties.Resources.qualitynormal;
         case Quality.Good:
             return AnalyzeTool.Properties.Resources.qualitygood;
         case Quality.VeryGood:
             return AnalyzeTool.Properties.Resources.qualityverygood;
         case Quality.Utmost:
             return AnalyzeTool.Properties.Resources.qualityutmost;
         default:
             return null;
     }
 }
Beispiel #5
0
 private Bitmap GetSaltTexture(Tile tile)
 {
     if (map[tile.X, tile.Y].HasSalt)
     {
         return AnalyzeTool.Properties.Resources.salt;
     }
     else
     {
         return null;
     }
 }
Beispiel #6
0
 public override bool UseTool(AnalyzeMap map, Tile tile)
 {
     if (map[tile].Type != tileType)
     {
         map[tile].Type = tileType;
         return true;
     }
     return false;
 }
Beispiel #7
0
 public abstract bool UseTool(AnalyzeMap map, Tile tile);
Beispiel #8
0
        public void testMergeComplex()
        {
            // Complex test
            // First "Something" is detected
            // Getting closer we detect "Iron, Zinc and something else
            // A 3rd analyze detects 2 iron of different quality and a zinc
            AnalyzeMap map = new AnalyzeMap(1, 1);
            Tile tile = new Tile(0, 0);
            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Something, Quality.Unknown) }));
            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Iron, Quality.Unknown), new Detected(TileType.Zinc, Quality.Unknown), new Detected(TileType.Something, Quality.Unknown) }));

            Assert.IsNotNull(map[tile].Estimates);
            Assert.AreEqual(11, map[tile].Estimates.Count);
            Assert.IsTrue(map[tile].Estimates.Contains(new Detected(TileType.Iron, Quality.Unknown)), "Does not contain Iron-Unknown");
            Assert.IsTrue(map[tile].Estimates.Contains(new Detected(TileType.Zinc, Quality.Unknown)), "Does not contain Zinc-Unknown");

            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Iron, Quality.Good), new Detected(TileType.Iron, Quality.Acceptable), new Detected(TileType.Zinc, Quality.Unknown) }));

            Assert.IsNotNull(map[tile].Estimates);
            Assert.AreEqual(3, map[tile].Estimates.Count);
            Assert.IsTrue(map[tile].Estimates.Contains(new Detected(TileType.Iron, Quality.Good)), "Does not contain Iron-Good");
            Assert.IsTrue(map[tile].Estimates.Contains(new Detected(TileType.Iron, Quality.Acceptable)), "Does not contain Iron-Acceptable");
            Assert.IsTrue(map[tile].Estimates.Contains(new Detected(TileType.Zinc, Quality.Unknown)), "Does not contain Zinc-Unknown");
        }
Beispiel #9
0
 private void SetTileType(Tile tile, TileType tileType)
 {
     if (map.IsValidTile(tile) && map[tile].Type != tileType)
     {
         map[tile].Type = tileType;
         RepaintTile(tile);
     }
 }
Beispiel #10
0
 public TileStatus this[Tile tile]
 {
     get { return tileStatus[tile.X, tile.Y]; }
 }
Beispiel #11
0
        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();
        }
Beispiel #12
0
        public void testMergeUpdate()
        {
            // Setting Iron and Something (eg iron and silver) and adding Iron later on should leave only Iron
            AnalyzeMap map = new AnalyzeMap(1, 1);
            Tile tile = new Tile(0, 0);
            map[tile].Set(new Detected(TileType.Zinc, Quality.Unknown));

            Assert.IsNull(map[tile].Estimates);
            Assert.IsNotNull(map[tile].Found);
            Assert.AreEqual(TileType.Zinc, map[tile].Found.Type);
            Assert.AreEqual(Quality.Unknown, map[tile].Found.Quality);

            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Iron, Quality.Good), new Detected(TileType.Zinc, Quality.Good) }));

            Assert.IsNull(map[tile].Estimates);
            Assert.IsNotNull(map[tile].Found);
            Assert.AreEqual(TileType.Zinc, map[tile].Found.Type);
            Assert.AreEqual(Quality.Good, map[tile].Found.Quality);
        }
Beispiel #13
0
        public void testMergeUnknown()
        {
            // Setting Nothing and adding another detected ore should leave the tile at Nothing.
            AnalyzeMap map = new AnalyzeMap(1, 1);
            Tile tile = new Tile(0, 0);
            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Nothing, Quality.Unknown) }));
            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Iron, Quality.Good) }));

            Assert.IsNull(map[tile].Estimates);
            Assert.IsNotNull(map[tile].Found);
            Assert.AreEqual(TileType.Nothing, map[tile].Found.Type);
        }
Beispiel #14
0
        public void testMergeSomething()
        {
            // Setting Iron and Something (eg iron and silver) and adding Iron later on should leave only Iron
            AnalyzeMap map = new AnalyzeMap(1, 1);
            Tile tile = new Tile(0, 0);
            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Iron, Quality.Unknown), new Detected(TileType.Something, Quality.Unknown) }));
            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Iron, Quality.Good) }));

            Assert.IsNotNull(map[tile].Estimates);
            Assert.AreEqual(1, map[tile].Estimates.Count);
            Assert.IsTrue(map[tile].Estimates.Contains(new Detected(TileType.Iron, Quality.Good)));
        }
Beispiel #15
0
 private void RepaintTile(Tile tile)
 {
     GridControl.Cell cell = TileToCell(tile);;
     gridControl1.PaintCell(cell.X, cell.Y);
 }
Beispiel #16
0
 public bool IsValidTile(Tile tile)
 {
     return IsValidTile(tile.X, tile.Y);
 }
Beispiel #17
0
 private void SetTileQuality(Tile tile, Quality quality)
 {
     if (map.IsValidTile(tile) && map[tile].Quality != quality)
     {
         map[tile].Quality = quality;
         RepaintTile(tile);
     }
 }
Beispiel #18
0
        private Direction GetTileDirection(Tile p, int x, int y)
        {
            int dx = p.X - x;
            int dy = p.Y - y;
            int dc = Math.Abs(dx) - Math.Abs(dy);

            if (dx == 0 && dy == 0)
                return Direction.Unknown;
            else if (dx == 0 && dy > 0)
                return Direction.S;
            else if (dx == 0 && dy < 0)
                return Direction.N;
            else if (dx > 0 && dy == 0)
                return Direction.E;
            else if (dx < 0 && dy == 0)
                return Direction.W;
            else if (dx < 0 && dy < 0)
            {
                if (dc == 0)
                    return Direction.NW;
                else if (dc < 0)
                    return Direction.NNW;
                else
                    return Direction.WNW;
            }
            else if (dx < 0 && dy > 0)
            {
                if (dc == 0)
                    return Direction.SW;
                else if (dc < 0)
                    return Direction.SSW;
                else
                    return Direction.WSW;
            }
            else if (dx > 0 && dy < 0)
            {
                if (dc == 0)
                    return Direction.NE;
                else if (dc < 0)
                    return Direction.NNE;
                else
                    return Direction.ENE;
            }
            else if (dx > 0 && dy > 0)
            {
                if (dc == 0)
                    return Direction.SE;
                else if (dc < 0)
                    return Direction.SSE;
                else
                    return Direction.ESE;
            }
            return Direction.Unknown;
        }
Beispiel #19
0
 private GridControl.Cell TileToCell(Tile tile)
 {
     return new GridControl.Cell(tile.X, tile.Y);
 }
Beispiel #20
0
        public void testMerge()
        {
            // Setting a list of detected ores and adding another list should leave the union of the two lists
            AnalyzeMap map = new AnalyzeMap(1, 1);
            Tile tile = new Tile(0, 0);
            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Iron, Quality.Unknown), new Detected(TileType.Silver, Quality.Unknown)}));
            map[tile].Add(new List<Detected>(new Detected[] { new Detected(TileType.Iron, Quality.Good) }));

            Assert.IsNotNull(map[tile].Estimates);
            Assert.AreEqual(1, map[tile].Estimates.Count);
            Assert.IsTrue(map[tile].Estimates.Contains(new Detected(TileType.Iron, Quality.Good)));
        }