Exemplo n.º 1
0
        public void Constructor_Can_Drop_Reference()
        {
            var map = new Pillar[4, 4]
            {
                { new Pillar(0, 0, 100), new Pillar(1, 0, 100), new Pillar(2, 0, 1), new Pillar(3, 0, 100) },
                { new Pillar(0, 1, 100), new Pillar(1, 1, 100), new Pillar(2, 1, 2), new Pillar(3, 1, 100) },
                { new Pillar(0, 2, 100), new Pillar(1, 2, 100), new Pillar(2, 2, 3), new Pillar(3, 2, 100) },
                { new Pillar(0, 3, 100), new Pillar(1, 3, 100), new Pillar(2, 3, 4), new Pillar(3, 3, 100) },
            };
            var oldFrame = new BoardFrame(new Map(map));
            var actual   = new BoardFrame(oldFrame);
            int x        = 1;
            int y        = 2;

            var oldColoredPillar = new ColoredPillar(x, y, 4, ConsoleColor.Magenta, ConsoleColor.Black);

            oldFrame.SetInPosition(oldColoredPillar);

            Assert.IsFalse(ReferenceEquals(
                               oldFrame.GetFrom(x, y),
                               actual.GetFrom(x, y)),
                           $"oldframe[{x}, {y}] should not reference actual[{x}, {y}]");

            var oldFramePillar = oldFrame.GetFrom(x, y);

            Assert.That(oldFramePillar.X, Is.EqualTo(x), "oldFramePillar.X");
            Assert.That(oldFramePillar.Y, Is.EqualTo(y), "oldFramePillar.Y");
            Assert.That(oldFramePillar.Height, Is.EqualTo(4), "oldFramePillar.Height");

            var actualFramePillar = actual.GetFrom(x, y);

            Assert.That(actualFramePillar.X, Is.EqualTo(x), "actualFramePillar.X");
            Assert.That(actualFramePillar.Y, Is.EqualTo(y), "actualFramePillar.Y");
            Assert.That(actualFramePillar.Height, Is.EqualTo(100), "actualFramePillar.Height");
        }
Exemplo n.º 2
0
 private void RouteRewalk(Builder model, BuilderView view, int maxIndex)
 {
     for (int i = 0; i <= maxIndex; i++)
     {
         ColoredPillar oldStep = view.RouteReWalk(model.Path.GetByIndex(i));
         SetInCurrentFrame(oldStep, "REWALK");
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Generate a collection of <see cref="BoardFrame"/>
        /// to display it on the <see cref="Console"/>.
        /// </summary>
        /// <param name="model">Object with a Path property.</param>
        /// <param name="view">View for the model.</param>
        public void GenerateFrames(Builder model, BuilderView view)
        {
            for (int i = 0; i < model.Path.Length - 1; i++)
            {
                ColoredPillar newStep = view.NewStep(model.Path.GetByIndex(i));
                SetInCurrentFrame(newStep, "STEP");

                SwitchToNextFrame();

                RouteRewalk(model, view, i);
            }

            if (0 < model.Path.Length)
            {
                ColoredPillar position = view.Build(_map.GetField(model.Path.Last()));

                SetInCurrentFrame(position, "BUILD");
            }
        }
Exemplo n.º 4
0
        public void Display(BoardFrame frame)
        {
            for (int y = 0; y < frame.Height; y++)
            {
                for (int x = 0; x < frame.Width; x++)
                {
                    ColoredPillar position = frame.GetFrom(x, y);

                    Console.Write(" ");
                    Console.BackgroundColor = position.BackGroundColor;
                    Console.ForegroundColor = position.FontColor;
                    Console.Write("{0, 3}", position.Height);
                    Console.ResetColor();
                    Console.Write(" |");
                }

                Console.WriteLine();
            }

            Console.WriteLine();
        }
Exemplo n.º 5
0
        private void SetInCurrentFrame(ColoredPillar position, string msg)
        {
            Log.Debug($"SetInCurrentFrame #{_setterIndex} {msg} : ({position.X}; {position.Y}) Height: {position.Height}", 1);

            _frames[_setterIndex].SetInPosition(position);
        }
Exemplo n.º 6
0
 public ColoredPillar DrawPillar(Pillar position)
 {
     return(ColoredPillar.Parse(position));
 }