Ejemplo n.º 1
0
        public void MoveFigure(Figure figure, Position position)
        {
            if (!ValidatePosition(figure.FigurePosition))
            {
                throw new Exception("Position Invalid");
            }

            // ¬¬¬ Need to check if the figure can move there.
            Figure taken = GetFigureFromPosition(position);

            if (taken?.Color == figure.Color)
            {
                throw new Exception("You alredy have figure in that position");
            }
            else if (taken != null && taken.Color != figure.Color)
            {
                ClearFigure(figure);
            }

            figure.SetPosition(position);
            Figures[position.Row, position.Column] = figure;
        }
Ejemplo n.º 2
0
 private void SetPosition(Figure figure, int x, int y)
 {
     figure.SetPosition(x, y);
     Figures[x, y] = figure;
 }
Ejemplo n.º 3
0
 private void SetPosition(Figure figure, Position position)
 {
     figure.SetPosition(position.Row, position.Column);
     Figures[position.Row, position.Column] = figure;
 }