static public void ResetFigures()
 {
     FiguresArray[0] = new FigureI(6, FieldX, FieldY);
     FiguresArray[1] = new FigureL(6, FieldX, FieldY);
     FiguresArray[2] = new FigureJ(6, FieldX, FieldY);
     FiguresArray[3] = new FigureT(6, FieldX, FieldY);
     FiguresArray[4] = new FigureB(6, FieldX, FieldY);
     FiguresArray[5] = new FigureS(6, FieldX, FieldY);
     FiguresArray[6] = new FigureZ(6, FieldX, FieldY);
 }
Exemple #2
0
        public void TestCanFit()
        {
            var arr = new []{
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0},
                                    new[]{0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,1}
                                };

            Assert.IsTrue ( arr.Length == 10 );
            Assert.IsTrue ( arr[0].Length == 20);

            var glass = Glass.createTestGlass (arr);

            AbstractFigure fig = new FigureL();

            // #.
            // #.
            // ##
            Assert.IsTrue(glass.checkFit(fig, 7, 17));
            Assert.IsTrue(glass.checkFit(fig, 1, 11));
            Assert.IsTrue(glass.checkFit(fig, 6, 13));
            Assert.IsFalse(glass.checkFit(fig, 6, 17));
            Assert.IsFalse(glass.checkFit(fig, 9, 11));
            Assert.IsFalse(glass.checkFit(fig, 2, 18));

            fig.Rotate();

            // ###
            // #..
            Assert.IsTrue(glass.checkFit(fig, 3, 15));
            Assert.IsTrue(glass.checkFit(fig, 1, 17));
            Assert.IsTrue(glass.checkFit(fig, 5, 11));
            Assert.IsFalse(glass.checkFit(fig, 3, 16));
            Assert.IsFalse(glass.checkFit(fig, 1, 18));
            Assert.IsFalse(glass.checkFit(fig, 5, 12));

            fig = new FigureI();

            // #
            // #
            // #
            // #
            Assert.IsTrue(glass.checkFit(fig, 2, 16));
            Assert.IsTrue(glass.checkFit(fig, 7, 16));
            Assert.IsTrue(glass.checkFit(fig, 0, 13));
            Assert.IsFalse(glass.checkFit(fig, 2, 17));
            Assert.IsFalse(glass.checkFit(fig, 6, 16));
            Assert.IsFalse(glass.checkFit(fig, 0, 14));

            fig = new FigureZ();

            // ".#"
            // "##"
            // "#."
            Assert.IsTrue(glass.checkFit(fig, 2, 17));
            Assert.IsTrue(glass.checkFit(fig, 1, 16));
            Assert.IsTrue(glass.checkFit(fig, 5, 10));
            Assert.IsFalse(glass.checkFit(fig, 7, 17));
            Assert.IsFalse(glass.checkFit(fig, 3, 15));
            Assert.IsFalse(glass.checkFit(fig, 1, 17));

            fig.Rotate();

            // "##."
            // ".##"
            Assert.IsTrue(glass.checkFit(fig, 1, 18));
            Assert.IsTrue(glass.checkFit(fig, 0, 16));
            Assert.IsTrue(glass.checkFit(fig, 4, 15));
            Assert.IsFalse(glass.checkFit(fig, 0, 18));
            Assert.IsFalse(glass.checkFit(fig, 0, 19));
            Assert.IsFalse(glass.checkFit(fig, 5, 17));
        }