Beispiel #1
0
        public void TestGetPivotLocation3()
        {
            var game = new Game(Board.CreateEmpty(5, 7), null, null, 0, 0, 0, -1, -1, string.Empty, 0);
            var unit = Unit.Create(new Point(2, 4), new[]
            {
                new Point(2, 1), new Point(5, 1), new Point(1, 2), new Point(3, 2), new Point(4, 2), new Point(6, 2), new Point(7, 2), new Point(4, 3), new Point(5, 3),
            });

            var actual = game.GetPivotLocation(unit);
            Assert.AreEqual(1, actual.Col);
            Assert.AreEqual(3, actual.Row);

            var gameUnit = new GameUnit(unit, new UnitPosition(actual, 0));
            Assert.IsTrue(game.IsValid(gameUnit));
            Console.WriteLine(game.Board.Place(gameUnit.GetAbsolutePoints()).ToString());
        }
Beispiel #2
0
 public bool IsValid(GameUnit gameUnit)
 {
     foreach (var point in gameUnit.GetAbsolutePoints())
     {
         if (!InField(point))
         {
             return false;
         }
         if (Field[point.Row][point.Col] == CellState.Busy)
         {
             return false;
         }
     }
     return true;
 }