Example #1
0
 public static bool IsCombination(ref Combination combination)
 {
     var result = false;
       var three = new Three(combination);
       var center = three.Center;
       if(center.Up.IsNotNullOrEmpty() && center.Up.ChildItem.Type == three.Type && center.Down.IsNotNullOrEmpty() && center.Down.ChildItem.Type == three.Type) {
     three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center.Down, center, center.Up }, Orientation = Orientation.Vertical });
     result = true;
       }
       if(center.Left.IsNotNullOrEmpty() && center.Left.ChildItem.Type == three.Type && center.Right.IsNotNullOrEmpty() && center.Right.ChildItem.Type == three.Type) {
     three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center.Left, center, center.Right }, Orientation = Orientation.Horizontal });
     result = true;
       }
       if(center.Up.IsNotNullOrEmpty() && center.Up.ChildItem.Type == three.Type && center.Up.Up.IsNotNullOrEmpty() && center.Up.Up.ChildItem.Type == three.Type) {
     three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center, center.Up, center.Up.Up }, Orientation = Orientation.Vertical });
     result = true;
       }
       if(center.Down.IsNotNullOrEmpty() && center.Down.ChildItem.Type == three.Type && center.Down.Down.IsNotNullOrEmpty() && center.Down.Down.ChildItem.Type == three.Type) {
     three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center.Down.Down, center.Down, center }, Orientation = Orientation.Vertical });
     result = true;
       }
       if(center.Left.IsNotNullOrEmpty() && center.Left.ChildItem.Type == three.Type && center.Left.Left.IsNotNullOrEmpty() && center.Left.Left.ChildItem.Type == three.Type) {
     three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center.Left.Left, center.Left, center }, Orientation = Orientation.Horizontal });
     result = true;
       }
       if(center.Right.IsNotNullOrEmpty() && center.Right.ChildItem.Type == three.Type && center.Right.Right.IsNotNullOrEmpty() && center.Right.Right.ChildItem.Type == three.Type) {
     three.ThreeVariants.Add(new Variant() { Cells = new Cell[] { center, center.Right, center.Right.Right }, Orientation = Orientation.Horizontal });
     result = true;
       }
       if(result) {
     three.Cells = three.ThreeVariants.FirstOrDefault().Cells;
     combination = three;
       }
       return result;
 }
Example #2
0
 public static bool IsCombination(ref Three three)
 {
     var angle = new Angle(three);
       foreach(var variant1 in angle.ThreeVariants) {
     foreach(var variant2 in angle.ThreeVariants) {
       if(variant1.Orientation != variant2.Orientation) {
     HashSet<Cell> cells = new HashSet<Cell>();
     cells.UnionWith(variant1.Cells);
     cells.UnionWith(variant2.Cells);
     angle.Cells = cells.ToArray();
     three = angle;
     return true;
       }
     }
       }
       three = null;
       return false;
 }
Example #3
0
 public static bool IsCombination(ref Three three)
 {
     var result = false;
       var four = new Four(three);
       foreach(var variant in four.ThreeVariants) {
     if(variant.Orientation == Orientation.Horizontal && variant.Cells[2].Right.IsNotNullOrEmpty() && variant.Cells[2].Right.ChildItem.Type == four.Type) {
       four.FourVariants.Add(new Variant() { Cells = new Cell[] { variant.Cells[0], variant.Cells[1], variant.Cells[2], variant.Cells[2].Right }, Orientation = Orientation.Horizontal });
       result = true;
     }
     if(variant.Orientation == Orientation.Vertical && variant.Cells[2].Up.IsNotNullOrEmpty() && variant.Cells[2].Up.ChildItem.Type == four.Type) {
       four.FourVariants.Add(new Variant() { Cells = new Cell[] { variant.Cells[0], variant.Cells[1], variant.Cells[2], variant.Cells[2].Up }, Orientation = Orientation.Vertical });
       result = true;
     }
       }
       if(result) {
     four.Cells = four.FourVariants.FirstOrDefault().Cells;
     three = four;
       }
       return result;
 }
Example #4
0
 public Four(Three three)
     : base(three)
 {
 }
Example #5
0
 public Four(Three three)
     : base(three)
 {
 }
Example #6
0
 public Angle(Three three)
     : base(three)
 {
 }
Example #7
0
        public static bool IsCombination(ref Combination combination)
        {
            var result = false;
            var three  = new Three(combination);
            var center = three.Center;

            if (center.Up.IsNotNullOrEmpty() && center.Up.ChildItem.Type == three.Type && center.Down.IsNotNullOrEmpty() && center.Down.ChildItem.Type == three.Type)
            {
                three.ThreeVariants.Add(new Variant()
                {
                    Cells = new Cell[] { center.Down, center, center.Up }, Orientation = Orientation.Vertical
                });
                result = true;
            }
            if (center.Left.IsNotNullOrEmpty() && center.Left.ChildItem.Type == three.Type && center.Right.IsNotNullOrEmpty() && center.Right.ChildItem.Type == three.Type)
            {
                three.ThreeVariants.Add(new Variant()
                {
                    Cells = new Cell[] { center.Left, center, center.Right }, Orientation = Orientation.Horizontal
                });
                result = true;
            }
            if (center.Up.IsNotNullOrEmpty() && center.Up.ChildItem.Type == three.Type && center.Up.Up.IsNotNullOrEmpty() && center.Up.Up.ChildItem.Type == three.Type)
            {
                three.ThreeVariants.Add(new Variant()
                {
                    Cells = new Cell[] { center, center.Up, center.Up.Up }, Orientation = Orientation.Vertical
                });
                result = true;
            }
            if (center.Down.IsNotNullOrEmpty() && center.Down.ChildItem.Type == three.Type && center.Down.Down.IsNotNullOrEmpty() && center.Down.Down.ChildItem.Type == three.Type)
            {
                three.ThreeVariants.Add(new Variant()
                {
                    Cells = new Cell[] { center.Down.Down, center.Down, center }, Orientation = Orientation.Vertical
                });
                result = true;
            }
            if (center.Left.IsNotNullOrEmpty() && center.Left.ChildItem.Type == three.Type && center.Left.Left.IsNotNullOrEmpty() && center.Left.Left.ChildItem.Type == three.Type)
            {
                three.ThreeVariants.Add(new Variant()
                {
                    Cells = new Cell[] { center.Left.Left, center.Left, center }, Orientation = Orientation.Horizontal
                });
                result = true;
            }
            if (center.Right.IsNotNullOrEmpty() && center.Right.ChildItem.Type == three.Type && center.Right.Right.IsNotNullOrEmpty() && center.Right.Right.ChildItem.Type == three.Type)
            {
                three.ThreeVariants.Add(new Variant()
                {
                    Cells = new Cell[] { center, center.Right, center.Right.Right }, Orientation = Orientation.Horizontal
                });
                result = true;
            }
            if (result)
            {
                three.Cells = three.ThreeVariants.FirstOrDefault().Cells;
                combination = three;
            }
            return(result);
        }
Example #8
0
 public Three(Three combination)
     : base(combination)
 {
     ThreeVariants = combination.ThreeVariants;
 }
Example #9
0
 public Angle(Three three)
     : base(three)
 {
 }
Example #10
0
 public Three(Three combination)
     : base(combination)
 {
     ThreeVariants = combination.ThreeVariants;
 }