Beispiel #1
0
        public override List <Pieces> Move(int x, int y, Chess c)
        {
            List <Pieces> possMove = new List <Pieces>();
            char          team     = c.pieces[x, y].Team;

            if (x == 7 && y == 3 && team == 'W')
            {
                if (y + 2 >= 0)
                {
                    if (c.pieces[x, y + 2] is null)
                    {
                        if (c.pieces[7, 7] is Rook)
                        {
                            if (!(c.pieces[7, 7] is null))
                            {
                                if ((c.pieces[7, 7] as Rook).Casting)
                                {
                                    possMove.Add(new King(x, y + 2, c.pieces[x, y].team));
                                }
                            }
                        }
                    }
                }
                if (y - 2 >= 0)
                {
                    if (c.pieces[x, y + 2] is null)
                    {
                        if (c.pieces[7, 7] is Rook)
                        {
                            if (!(c.pieces[7, 0] is null))
                            {
                                if ((c.pieces[7, 0] as Rook).Casting)
                                {
                                    possMove.Add(new King(x, y - 2, c.pieces[x, y].team));
                                }
                            }
                        }
                    }
                }
            }
            if (x - 1 >= 0)
            {
                if (c.pieces[x - 1, y] is null)
                {
                    possMove.Add(new King(x - 1, y, c.pieces[x, y].team));
                }
                else
                {
                    if (c.pieces[x, y].Team == 'W' && c.pieces[x - 1, y].Team == 'B')
                    {
                        possMove.Add(new King(x - 1, y, team));
                    }
                    else if (c.pieces[x, y].Team == 'B' && c.pieces[x - 1, y].Team == 'W')
                    {
                        possMove.Add(new King(x - 1, y, team));
                    }
                }
            }
            if (x + 1 < 8)
            {
                if (c.pieces[x + 1, y] is null)
                {
                    possMove.Add(new King(x + 1, y, c.pieces[x, y].team));
                }
                else
                {
                    if (c.pieces[x, y].Team == 'W' && c.pieces[x + 1, y].Team == 'B')
                    {
                        possMove.Add(new King(x + 1, y, team));
                    }
                    else if (c.pieces[x, y].Team == 'B' && c.pieces[x + 1, y].Team == 'W')
                    {
                        possMove.Add(new King(x + 1, y, team));
                    }
                }
            }
            if (y + 1 < 8)
            {
                if (c.pieces[x, y + 1] is null)
                {
                    possMove.Add(new King(x, y + 1, c.pieces[x, y].team));
                }
                else
                {
                    if (c.pieces[x, y].Team == 'W' && c.pieces[x, y + 1].Team == 'B')
                    {
                        possMove.Add(new King(x, y + 1, team));
                    }
                    else if (c.pieces[x, y].Team == 'B' && c.pieces[x, y + 1].Team == 'W')
                    {
                        possMove.Add(new King(x, y + 1, team));
                    }
                }
            }
            if (y - 1 >= 0)
            {
                if (c.pieces[x, y - 1] is null)
                {
                    possMove.Add(new King(x, y - 1, c.pieces[x, y].team));
                }
                else
                {
                    if (c.pieces[x, y].Team == 'W' && c.pieces[x, y - 1].Team == 'B')
                    {
                        possMove.Add(new King(x, y - 1, team));
                    }
                    else if (c.pieces[x, y].Team == 'B' && c.pieces[x, y - 1].Team == 'W')
                    {
                        possMove.Add(new King(x, y - 1, team));
                    }
                }
            }
            if (x + 1 < 8 && y - 1 >= 0)
            {
                if (c.pieces[x + 1, y - 1] is null)
                {
                    possMove.Add(new King(x + 1, y - 1, c.pieces[x, y].team));
                }
                else
                {
                    if (c.pieces[x, y].Team == 'W' && c.pieces[x + 1, y - 1].Team == 'B')
                    {
                        possMove.Add(new King(x + 1, y - 1, team));
                    }
                    else if (c.pieces[x, y].Team == 'B' && c.pieces[x + 1, y - 1].Team == 'W')
                    {
                        possMove.Add(new King(x + 1, y - 1, team));
                    }
                }
            }
            if (x + 1 < 8 && y + 1 < 8)
            {
                if (c.pieces[x + 1, y + 1] is null)
                {
                    possMove.Add(new King(x + 1, y + 1, c.pieces[x, y].team));
                }
                else
                {
                    if (c.pieces[x, y].Team == 'W' && c.pieces[x + 1, y + 1].Team == 'B')
                    {
                        possMove.Add(new King(x + 1, y + 1, team));
                    }
                    else if (c.pieces[x, y].Team == 'B' && c.pieces[x + 1, y + 1].Team == 'W')
                    {
                        possMove.Add(new King(x + 1, y + 1, team));
                    }
                }
            }
            if (x - 1 >= 0 && y + 1 < 8)
            {
                if (c.pieces[x - 1, y + 1] is null)
                {
                    possMove.Add(new King(x - 1, y + 1, c.pieces[x, y].team));
                }
                else
                {
                    if (c.pieces[x, y].Team == 'W' && c.pieces[x - 1, y + 1].Team == 'B')
                    {
                        possMove.Add(new King(x - 1, y + 1, team));
                    }
                    else if (c.pieces[x, y].Team == 'B' && c.pieces[x - 1, y + 1].Team == 'W')
                    {
                        possMove.Add(new King(x - 1, y + 1, team));
                    }
                }
            }
            if (x - 1 >= 0 && y - 1 >= 0)
            {
                if (c.pieces[x - 1, y - 1] is null)
                {
                    possMove.Add(new King(x - 1, y - 1, c.pieces[x, y].team));
                }
                else
                {
                    if (c.pieces[x, y].Team == 'W' && c.pieces[x - 1, y - 1].Team == 'B')
                    {
                        possMove.Add(new King(x - 1, y - 1, team));
                    }
                    else if (c.pieces[x, y].Team == 'B' && c.pieces[x - 1, y - 1].Team == 'W')
                    {
                        possMove.Add(new King(x - 1, y - 1, team));
                    }
                }
            }

            return(possMove);
        }
Beispiel #2
0
 public abstract List <Pieces> Move(int x, int y, Chess c);
Beispiel #3
0
        public override List <Pieces> Move(int x, int y, Chess c)
        {
            List <Pieces> possMove = new List <Pieces>();
            int           ox       = x;
            int           oy       = y;
            char          team     = c.pieces[x, y].Team;

            while (x - 1 >= 0)
            {
                if (c.pieces[x - 1, y] is null)
                {
                    possMove.Add(new Rook(x - 1, y, team));
                }
                else
                {
                    if (c.pieces[ox, oy].Team == 'W' && c.pieces[x - 1, y].Team == 'B')
                    {
                        possMove.Add(new Rook(x - 1, y, team));
                    }
                    else if (c.pieces[ox, oy].Team == 'B' && c.pieces[x - 1, y].Team == 'W')
                    {
                        possMove.Add(new Rook(x - 1, y, team));
                    }
                    x = 1;
                }

                x = x - 1;
            }
            x = ox;
            y = oy;
            while (x + 1 < 8)
            {
                if (c.pieces[x + 1, y] is null)
                {
                    possMove.Add(new Rook(x + 1, y, team));
                }
                else
                {
                    if (c.pieces[ox, oy].Team == 'W' && c.pieces[x + 1, y].Team == 'B')
                    {
                        possMove.Add(new Rook(x + 1, y, team));
                    }
                    else if (c.pieces[ox, oy].Team == 'B' && c.pieces[x + 1, y].Team == 'W')
                    {
                        possMove.Add(new Rook(x + 1, y, team));
                    }
                    x = 6;
                }
                x = x + 1;
            }
            x = ox;
            y = oy;
            while (y - 1 >= 0)
            {
                if (c.pieces[x, y - 1] is null)
                {
                    possMove.Add(new Rook(x, y - 1, team));
                }
                else
                {
                    if (c.pieces[ox, oy].Team == 'W' && c.pieces[x, y - 1].Team == 'B')
                    {
                        possMove.Add(new Rook(x, y - 1, team));
                    }
                    else if (c.pieces[ox, oy].Team == 'B' && c.pieces[x, y - 1].Team == 'W')
                    {
                        possMove.Add(new Rook(x, y - 1, team));
                    }
                    y = 1;
                }
                y = y - 1;
            }
            x = ox;
            y = oy;
            while (y + 1 < 8)
            {
                if (c.pieces[x, y + 1] is null)
                {
                    possMove.Add(new Rook(x, y + 1, team));
                }
                else
                {
                    if (c.pieces[ox, oy].Team == 'W' && c.pieces[x, y + 1].Team == 'B')
                    {
                        possMove.Add(new Rook(x, y + 1, team));
                    }
                    else if (c.pieces[ox, oy].Team == 'B' && c.pieces[x, y + 1].Team == 'W')
                    {
                        possMove.Add(new Rook(x, y + 1, team));
                    }
                    y = 6;
                }
                y = y + 1;
            }
            return(possMove);
        }