Beispiel #1
0
 public override void Move(Coordonates from, Coordonates to)
 {
     if (Game.piece_position[to.x, to.y] != null)
     {
         Game.eated.Add(Game.piece_position[to.x, to.y]);
     }
     Game.piece_position[to.x, to.y] = Game.piece_position[from.x, from.y]; Game.piece_position[from.x, from.y] = null; firstmove = false;
 }
Beispiel #2
0
 public virtual void Move(Coordonates from, Coordonates to)
 {
     if (Game.piece_position[to.x, to.y] != null)
     {
         Game.eated.Add(Game.piece_position[to.x, to.y]);
     }
     Game.piece_position[to.x, to.y] = Game.piece_position[from.x, from.y]; Game.piece_position[from.x, from.y] = null;
 }
Beispiel #3
0
        public override List <Coordonates> GetUsableCoordonates(Coordonates Piece_coordonates, Piece[,] Board)
        {
            List <Coordonates> coords = new List <Coordonates>();
            int orx = Piece_coordonates.x; int ory = Piece_coordonates.y;

            Piece_coordonates.x++;
            while (!Piece_coordonates.OutOfBoard() && Board[Piece_coordonates.x, Piece_coordonates.y] == null)
            {
                coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y));
                Piece_coordonates.x++;
            }
            if (!Piece_coordonates.OutOfBoard() && Board[Piece_coordonates.x, Piece_coordonates.y].color != Board[orx, ory].color)
            {
                coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y));
            }
            Piece_coordonates = new Coordonates(orx, ory);
            Piece_coordonates.x--;
            while (!Piece_coordonates.OutOfBoard() && Board[Piece_coordonates.x, Piece_coordonates.y] == null)
            {
                coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y));
                Piece_coordonates.x--;
            }
            if (!Piece_coordonates.OutOfBoard() && Board[Piece_coordonates.x, Piece_coordonates.y].color != Board[orx, ory].color)
            {
                coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y));
            }
            Piece_coordonates = new Coordonates(orx, ory);
            Piece_coordonates.y++;
            while (!Piece_coordonates.OutOfBoard() && Board[Piece_coordonates.x, Piece_coordonates.y] == null)
            {
                coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y));
                Piece_coordonates.y++;
            }
            if (!Piece_coordonates.OutOfBoard() && Board[Piece_coordonates.x, Piece_coordonates.y].color != Board[orx, ory].color)
            {
                coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y));
            }
            Piece_coordonates = new Coordonates(orx, ory);
            Piece_coordonates.y--;
            while (!Piece_coordonates.OutOfBoard() && Board[Piece_coordonates.x, Piece_coordonates.y] == null)
            {
                coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y));
                Piece_coordonates.y--;
            }
            if (!Piece_coordonates.OutOfBoard() && Board[Piece_coordonates.x, Piece_coordonates.y].color != Board[orx, ory].color)
            {
                coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y));
            }
            return(coords);
        }
Beispiel #4
0
        public override List <Coordonates> GetUsableCoordonates(Coordonates Piece_coordonates, Piece[,] Board)
        {
            List <Coordonates> coords = new List <Coordonates>();

            int[] tabx = new int[] { 1, 2, 2, 1, -1, -2, -2, -1 };
            int[] taby = new int[] { 2, 1, -1, -2, -2, -1, 1, 2 };
            for (int n = 0; n < 8; n++)
            {
                if (!new Coordonates(Piece_coordonates.x + tabx[n], Piece_coordonates.y + taby[n]).OutOfBoard() && (Board[Piece_coordonates.x + tabx[n], Piece_coordonates.y + taby[n]] == null || Board[Piece_coordonates.x + tabx[n], Piece_coordonates.y + taby[n]].color != Board[Piece_coordonates.x, Piece_coordonates.y].color))
                {
                    coords.Add(new Coordonates(Piece_coordonates.x + tabx[n], Piece_coordonates.y + taby[n]));
                }
            }
            return(coords);
        }
Beispiel #5
0
        public override List <Coordonates> GetUsableCoordonates(Coordonates Piece_coordonates, Piece[,] Board)
        {
            List <Coordonates> coords = new List <Coordonates>();

            for (int i = -1; i < 2; i++)
            {
                for (int j = -1; j < 2; j++)
                {
                    if (!new Coordonates(Piece_coordonates.x + i, Piece_coordonates.y + j).OutOfBoard() && (Board[Piece_coordonates.x + i, Piece_coordonates.y + j] == null || Board[Piece_coordonates.x + i, Piece_coordonates.y + j].color != Board[Piece_coordonates.x, Piece_coordonates.y].color))
                    {
                        coords.Add(new Coordonates(Piece_coordonates.x + i, Piece_coordonates.y + j));
                    }
                }
            }
            return(coords);
        }
Beispiel #6
0
        public override List <Coordonates> GetUsableCoordonates(Coordonates Piece_coordonates, Piece[,] Board)
        {
            List <Coordonates> coords = new List <Coordonates>();

            if (color == Color.White)
            {
                if (!new Coordonates(Piece_coordonates.x, Piece_coordonates.y + 1).OutOfBoard() && Board[Piece_coordonates.x, Piece_coordonates.y + 1] == null)
                {
                    coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y + 1));
                }
                if (!new Coordonates(Piece_coordonates.x - 1, Piece_coordonates.y + 1).OutOfBoard() && Board[Piece_coordonates.x - 1, Piece_coordonates.y + 1] != null && Board[Piece_coordonates.x - 1, Piece_coordonates.y + 1].color == Piece.Color.Black)
                {
                    coords.Add(new Coordonates(Piece_coordonates.x - 1, Piece_coordonates.y + 1));
                }
                if (!new Coordonates(Piece_coordonates.x + 1, Piece_coordonates.y + 1).OutOfBoard() && Board[Piece_coordonates.x + 1, Piece_coordonates.y + 1] != null && Board[Piece_coordonates.x + 1, Piece_coordonates.y + 1].color == Piece.Color.Black)
                {
                    coords.Add(new Coordonates(Piece_coordonates.x + 1, Piece_coordonates.y + 1));
                }
                if (firstmove && Board[Piece_coordonates.x, Piece_coordonates.y + 1] == null)
                {
                    coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y + 2));
                }
            }
            else
            {
                if (!new Coordonates(Piece_coordonates.x, Piece_coordonates.y - 1).OutOfBoard() && Board[Piece_coordonates.x, Piece_coordonates.y - 1] == null)
                {
                    coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y - 1));
                }
                if (!new Coordonates(Piece_coordonates.x - 1, Piece_coordonates.y - 1).OutOfBoard() && Board[Piece_coordonates.x - 1, Piece_coordonates.y - 1] != null && Board[Piece_coordonates.x - 1, Piece_coordonates.y - 1].color == Piece.Color.White)
                {
                    coords.Add(new Coordonates(Piece_coordonates.x - 1, Piece_coordonates.y - 1));
                }
                if (!new Coordonates(Piece_coordonates.x + 1, Piece_coordonates.y - 1).OutOfBoard() && Board[Piece_coordonates.x + 1, Piece_coordonates.y - 1] != null && Board[Piece_coordonates.x + 1, Piece_coordonates.y - 1].color == Piece.Color.White)
                {
                    coords.Add(new Coordonates(Piece_coordonates.x + 1, Piece_coordonates.y - 1));
                }
                if (firstmove && Board[Piece_coordonates.x, Piece_coordonates.y - 1] == null)
                {
                    coords.Add(new Coordonates(Piece_coordonates.x, Piece_coordonates.y - 2));
                }
            }
            return(coords);
        }
Beispiel #7
0
        public void NewTurn(Player player)
        {
            DisplayBoard(new List <Coordonates>());
            TurnOf(player);
            List <Coordonates> templist = new List <Coordonates>();
            Coordonates        temp;

            do
            {
                temp = AskCase();
                while (temp.OutOfBoard() || piece_position[temp.x, temp.y] == null || piece_position[temp.x, temp.y].color != player.color)
                {
                    DisplayBoard(new List <Coordonates>());
                    TurnOf(player);
                    Console.WriteLine("Coordonnées erronées où non disponibles\nMerci de rentrer les coordonnées sous cette forme \"x,y\"");
                    temp = AskCase();
                }
                templist = piece_position[temp.x, temp.y].GetUsableCoordonates(temp, piece_position);
                if (templist.Count() == 0)
                {
                    DisplayBoard(new List <Coordonates>());
                    TurnOf(player);
                    Console.WriteLine("Aucun mouvement disponible pour cette piece\nMerci d'en choisir une autre");
                }
            } while (templist.Count() == 0);
            DisplayBoard(templist);
            TurnOf(player);
            foreach (Coordonates co in templist)
            {
                //Console.WriteLine(co.x+"|"+co.y);
            }
            Coordonates temp2 = AskCase();

            while (temp2.OutOfBoard() || templist.Find(s => s.x == temp2.x && s.y == temp2.y) == null)
            {
                DisplayBoard(templist);
                TurnOf(player);
                Console.WriteLine("Coordonnées erronées où non disponibles\nMerci de rentrer les coordonnées sous cette forme \"x,y\"");
                temp2 = AskCase();
            }
            piece_position[temp.x, temp.y].Move(new Coordonates(temp.x, temp.y), new Coordonates(temp2.x, temp2.y));
        }
Beispiel #8
0
 public virtual List <Coordonates> GetUsableCoordonates(Coordonates Piece_coordonates, Piece[,] Board)
 {
     return(new List <Coordonates>());
 }