示例#1
0
        public void showPossibleMoves(String cmd)
        {
            Point p = new Point(cmd);

            current = board.fields[p.X, p.Y];

            if (current == null)
            {
                return;
            }

            if (current.color != c.color)
            {
                return;
            }

            current.generateAllowedMoves();

            Console.WriteLine();
            Console.WriteLine("possible movements: ");

            foreach (String s in current.moves)
            {
                Console.Write(" " + s);
            }

            current.showThruthTable();

            if (current.moves.Count == 0)
            {
                Console.WriteLine("No possible moves for this figure");
            }

            Console.WriteLine();
        }
示例#2
0
        public int rating(String request)
        {
            Point fp = new Point(request[0].ToString() + request[1].ToString());
            Point mp = new Point(request[2].ToString() + request[3].ToString());

            current = board.fields[fp.X, fp.Y];
            target  = board.fields[mp.X, mp.Y];

            if (!ai || turn == 'w')
            {
                //if user chose no figure (empty field)
                if (current == null)
                {
                    return(0);
                }

                //if user chose no its own figure (opponent figure chosen)
                if (current.color != c.color)
                {
                    return(0);
                }

                //if user want to move its own figure above its own figure w to w, b to b
                if (target != null && target.color == current.color)
                {
                    return(0);
                }

                current.generateAllowedMoves();

                if (!current.matrix[mp.X, mp.Y])
                {
                    return(0);
                }
            }

            //removed hit figure
            if (target != null)
            {
                nc.figures.Remove(target);
                board.fields[mp.X, mp.Y] = null;
            }

            current.move(mp);
            board.fields[mp.X, mp.Y] = current;

            board.fields[fp.X, fp.Y] = null;

            c.movements++;

            if (checkForMate())
            {
                return(2);
            }

            int n = (c.color == 'w') ? 0 : 7;

            if (current.type == 'P' && current.pos.X == n)
            {
                int z = c.figures.IndexOf(current);
                c.figures[z] = new Queen(ref board, current.pos, c.color);
            }

            Player p = c;

            c  = nc;
            nc = p;

            turn = c.color;

            System.Threading.Thread.Sleep(350);

            return(1);
        }