Esempio n. 1
0
        private Board(Board prevBoard, Figure newFigure, Point newFigurePlacementPoint)
        {
            if (!prevBoard.IsValidPlacement(newFigure, newFigurePlacementPoint))
            {
                throw new ArgumentException("Invalid or impossible placement");
            }

            var newPlacement = new Placement(newFigure, newFigurePlacementPoint, prevBoard.Figures.Count + 1);

            var figures = new List <Placement>(prevBoard.Figures)
            {
                newPlacement
            };

            Figures = figures;

            OddCellsColor = prevBoard.OddCellsColor ?? CalcOddCellsColor();

            PointsMap = new BitArray(prevBoard.PointsMap);
            foreach (var point in newPlacement.GetCellPoints())
            {
                PointsMap.Set(GetPointMapIndex(point), true);
            }
        }