Beispiel #1
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 #2
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));
        }