Exemple #1
0
        public void testMulti()
        {
            List <Detected> detected = new List <Detected>();

            TileEstimate estimate = new TileEstimate();

            detected.Add(new Detected(TileType.Iron, Quality.Unknown));
            estimate.Add(detected);

            Assert.AreEqual(1, estimate.Estimates.Count, "Expected 1 estimates");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Unknown)), "Expected estimates to contain iron");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Good)), "Expected estimates to contain good iron");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.VeryGood)), "Expected estimates to contain very good iron");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Utmost)), "Expected estimates to contain utmost iron");

            detected.Clear();
            detected.Add(new Detected(TileType.Iron, Quality.Good));
            detected.Add(new Detected(TileType.Iron, Quality.VeryGood));
            estimate.Add(detected);

            Assert.AreEqual(2, estimate.Estimates.Count, "Expected 1 estimates");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Unknown)), "Expected estimates to contain iron");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Good)), "Expected estimates to contain good iron");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.VeryGood)), "Expected estimates to contain very good iron");
            Assert.False(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Utmost)), "Expected estimates not to contain utmost iron");
        }
Exemple #2
0
 public void Reset()
 {
     this.Result       = null;
     this.Found        = null;
     this.TileEstimate = null;
     this.specialTypes = null;
 }
Exemple #3
0
        public void testSomething()
        {
            List <Detected> detected = new List <Detected>();

            TileEstimate estimate = new TileEstimate();

            detected.Add(new Detected(TileType.Something, Quality.Unknown));
            estimate.Add(detected);

            Assert.AreEqual(11, estimate.Estimates.Count, "Expected 11 estimates");

            detected.Clear();
            detected.Add(new Detected(TileType.Iron, Quality.Unknown));
            detected.Add(new Detected(TileType.Flint, Quality.Unknown));
            estimate.Add(detected);

            Assert.AreEqual(2, estimate.Estimates.Count, "Expected 2 estimates");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Unknown)), "Expected estimates to contain iron");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Good)), "Expected estimates to contain good iron");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Flint, Quality.Unknown)), "Expected estimates to contain flint");

            detected.Clear();
            detected.Add(new Detected(TileType.Iron, Quality.VeryGood));
            estimate.Add(detected);

            Assert.AreEqual(1, estimate.Estimates.Count, "Expected 1 estimates");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Unknown)), "Expected estimates to contain iron");
            Assert.False(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Good)), "Expected estimates not to contain good iron");
        }
Exemple #4
0
 public TileStatus()
 {
     this.type         = TileType.Unknown;
     this.quality      = Quality.Unknown;
     this.Result       = null;
     this.Found        = null;
     this.TileEstimate = null;
 }
Exemple #5
0
 public void RemoveSpecial(TileType tileType)
 {
     if (specialTypes != null)
     {
         specialTypes.Remove(tileType);
     }
     if (TileEstimate != null)
     {
         TileEstimate.Estimates.Remove(new Detected(tileType, Quality.Unknown));
         if (TileEstimate.Estimates.Count == 0)
         {
             TileEstimate = null;
         }
     }
 }
Exemple #6
0
 public void AddSpecial(TileType tileType)
 {
     if (specialTypes == null)
     {
         specialTypes = new HashSet <TileType>();
     }
     specialTypes.Add(tileType);
     if (TileEstimate != null)
     {
         TileEstimate.Estimates.Remove(new Detected(tileType, Quality.Unknown));
         if (TileEstimate.Estimates.Count == 0)
         {
             TileEstimate = null;
         }
     }
 }
Exemple #7
0
        /**
         * Add a list of detected ores to the tile.
         * # It checks if nothing has been detected so the tile can be marked empty.
         * # If the tile already has an ore set which matches any of the detected ores the quality is updated
         * # If the tile already has some results the results are merged.
         * # Otherwise the list is set.
         */
        public int Add(List <Detected> detected)
        {
            foreach (Detected d in detected)
            {
                if (d.Type == TileType.Nothing)
                {
                    // Nothing has been detected. Mark the tile as empty.
                    Set(d);
                    return(0);
                }
                else if (Found != null)
                {
                    // The detected ore matches what's already there
                    if (Found.Matches(d))
                    {
                        // Update the quality
                        if (Quality == Quality.Unknown && d.Quality != Quality.Unknown)
                        {
                            Found.Quality = d.Quality;
                        }
                        return(1);
                    }
                }
            }

            // We already have something set for this tile but none of the detected ores matched it.
            // This should not happen so we just bail out here.
            if (Found != null)
            {
                return(0);
            }

            if (TileEstimate == null)
            {
                TileEstimate = new TileEstimate();
            }

            TileEstimate.Add(detected);
            if (TileEstimate.Estimates.Count == 0)
            {
                return(0);
            }
            else
            {
                return(1);
            }
        }
Exemple #8
0
        public void testNothing()
        {
            List <Detected> detected = new List <Detected>();

            TileEstimate estimate = new TileEstimate();

            detected.Add(new Detected(TileType.Nothing, Quality.Unknown));
            estimate.Add(detected);

            Assert.AreEqual(0, estimate.Estimates.Count, "Expected 0 estimates");
            Assert.False(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Unknown)), "Expected estimates not to contain iron");

            detected.Clear();
            detected.Add(new Detected(TileType.Iron, Quality.Good));
            detected.Add(new Detected(TileType.Iron, Quality.VeryGood));
            estimate.Add(detected);

            Assert.AreEqual(0, estimate.Estimates.Count, "Expected 1 estimates");
            Assert.False(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Unknown)), "Expected estimates not to contain iron");
        }
Exemple #9
0
        public void testSimilar()
        {
            List <Detected> detected = new List <Detected>();
            TileEstimate    estimate = new TileEstimate();

            detected.Add(new Detected(TileType.Iron, Quality.Unknown));
            detected.Add(new Detected(TileType.Iron, Quality.Poor));
            estimate.Add(detected);

            Assert.AreEqual(1, estimate.Estimates.Count, "Expected 1 estimates");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Unknown)), "Expected estimates to contain iron");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Poor)), "Expected estimates to contain poor iron");
            Assert.False(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Good)), "Expected estimates not to contain goor iron");

            detected.Reverse();
            estimate = new TileEstimate();
            estimate.Add(detected);

            Assert.AreEqual(1, estimate.Estimates.Count, "Expected 1 estimates");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Unknown)), "Expected estimates to contain iron");
            Assert.True(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Poor)), "Expected estimates to contain poor iron");
            Assert.False(estimate.Estimates.Contains(new Detected(TileType.Iron, Quality.Good)), "Expected estimates not to contain goor iron");
        }
Exemple #10
0
 public void Set(Detected detected)
 {
     Found = new Detected(detected.Type, detected.Quality);
     if (TileEstimate != null)
     {
         List <Detected> list = new List <Detected>();
         foreach (Detected d in TileEstimate.Estimates)
         {
             if (Detected.isSpecialType(d.Type))
             {
                 list.Add(d);
             }
         }
         TileEstimate.Add(list);
         if (TileEstimate.Estimates.Count == 0)
         {
             TileEstimate = null;
         }
     }
     if (Found.Type != TileType.Nothing)
     {
         type = Found.Type;
     }
 }