コード例 #1
0
ファイル: Program.cs プロジェクト: Xret/Chess
        public bool move_checker(pair<int, int> figure_position, pair<int, int> where_to_move)
        {
            bool is_some_errors = false;
            if (_board[figure_position.First, figure_position.Second].figure_color == "white")
            {
                switch (_board[figure_position.First, figure_position.Second].figure_name)
                {
                    case "p":
                        if (where_to_move.Second == figure_position.Second && figure_position.First - where_to_move.First == 1)
                        {
                            if (_board[where_to_move.First, where_to_move.Second].figure_color == "empty_color")
                                figure.swap(ref _board[figure_position.First, figure_position.Second], ref _board[where_to_move.First, where_to_move.Second]);
                            else
                                is_some_errors = true;
                        }
                        else if (figure_position.First - where_to_move.First == 1 && Math.Abs(where_to_move.Second - figure_position.Second) == 1)
                        {
                            if (_board[where_to_move.First, where_to_move.Second].figure_color == "black")
                            {
                                felled_black_figures.Add(_board[where_to_move.First, where_to_move.Second]);
                                _board[where_to_move.First, where_to_move.Second] = _board[figure_position.First, figure_position.Second];
                                _board[figure_position.First, figure_position.Second] = new figure();
                            }
                            else
                                is_some_errors = true;
                            int i = 0;

                        }
                        else
                            is_some_errors = true;

                        if (_board[figure_position.First, figure_position.Second].figure_color == "white")
                            i = 1;
                        else if (_board[figure_position.First, figure_position.Second].figure_color == "black")
                            i = -1;

                        break;
                }
            }
            else if (_board[figure_position.First, figure_position.Second].figure_color == "black")
                switch (_board[figure_position.First, figure_position.Second].figure_name)
                {
                switch (_board[figure_position.First, figure_position.Second].figure_name)
            {
                case "p":
                    if (where_to_move.Second == figure_position.Second && figure_position.First - where_to_move.First == -1)
                    {
                        if (_board[where_to_move.First, where_to_move.Second].figure_color == "empty_color")
                            figure.swap(ref _board[figure_position.First, figure_position.Second], ref _board[where_to_move.First, where_to_move.Second]);
                        else
                            is_some_errors = true;
                    }
                    else if (figure_position.First - where_to_move.First == -1 && Math.Abs(where_to_move.Second - figure_position.Second) == -1)
                case "p":
                    if (where_to_move.Second == figure_position.Second && figure_position.First - where_to_move.First == 1 * i)
                    {
                        if (_board[where_to_move.First, where_to_move.Second].figure_color == "empty_color")
                            figure.swap(ref _board[figure_position.First, figure_position.Second], ref _board[where_to_move.First, where_to_move.Second]);
                        else
                            is_some_errors = true;
                    }
                    else if (figure_position.First - where_to_move.First == 1 * i && Math.Abs(where_to_move.Second - figure_position.Second) == 1 * i)
                    {
                        if (_board[where_to_move.First, where_to_move.Second].figure_color == "black")
                        {
                            if (_board[where_to_move.First, where_to_move.Second].figure_color == "white")
                            {
                                felled_white_figures.Add(_board[where_to_move.First, where_to_move.Second]);
                                _board[where_to_move.First, where_to_move.Second] = _board[figure_position.First, figure_position.Second];
                                _board[figure_position.First, figure_position.Second] = new figure();
                            }
                            else
                                is_some_errors = true;


                            felled_figures.Add(_board[where_to_move.First, where_to_move.Second]);
                            _board[where_to_move.First, where_to_move.Second] = _board[figure_position.First, figure_position.Second];
                            _board[figure_position.First, figure_position.Second] = new figure();
                        }
                        else
                            is_some_errors = true;

                    }
                    else
                        is_some_errors = true;
                    break;
            }

            break;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Xret/Chess
 public figure(string name, string color, int pos_x, int pos_y)
 {
     this.position = new pair<int, int>(pos_x, pos_y);
     this.figure_name = name;
     this.figure_color = color;
 }