Example #1
0
        public static void imprimirTabuleiro(tabuleiro tab, bool[,] posicoesPossiveis)
        {
            ConsoleColor fundoOriginal = Console.BackgroundColor;
            ConsoleColor fundoAlterado = ConsoleColor.DarkGray;


            for (int i = 0; i < tab.linhas; i++)
            {
                Console.Write(8 - i + " ");
                for (int j = 0; j < tab.colunas; j++)
                {
                    if (posicoesPossiveis[i, j])
                    {
                        Console.BackgroundColor = fundoAlterado;
                    }
                    else
                    {
                        Console.BackgroundColor = fundoOriginal;
                    }
                    imprimirPeca(tab.peca(i, j));
                    Console.BackgroundColor = fundoOriginal;
                    Console.Write(" ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("  A B C D E F G H");
            Console.BackgroundColor = fundoOriginal;
        }
Example #2
0
 public Peca(Cor cor, tabuleiro tab)
 {
     this.Cor           = cor;
     this.Posicao       = Posicao;
     this.QtdMovimentos = 0;
     this.Tab           = tab;
 }
Example #3
0
        public static void ImprimirTabuleiro(tabuleiro tab, bool[,] posicoesPossiveis)
        {
            ConsoleColor Original = Console.BackgroundColor;
            ConsoleColor fundoNew = ConsoleColor.DarkGray;

            for (int i = 0; i < tab.Linha; i++)
            {
                Console.Write(8 - i + "  ");
                for (int j = 0; j < tab.Coluna; j++)
                {
                    if (posicoesPossiveis[i, j])
                    {
                        Console.BackgroundColor = fundoNew;
                    }
                    else
                    {
                        Console.BackgroundColor = Original;
                    }
                    ImprimirPeca(tab.Peca(i, j));
                    Console.BackgroundColor = Original;
                }
                Console.WriteLine();
            }
            Console.WriteLine("  a b c d e f g h");
            Console.BackgroundColor = Original;
        }
Example #4
0
        public override bool movimentospossiveis(tabuleiro tab, Posicao origem, Posicao destino)
        {
            Posicao pos = new Posicao(tab.linhas, tab.colunas);

            /* Testar Rock Pequeno */

            if (!partida.emcheque &&
                destino.Linha == origem.Linha && destino.Coluna == origem.Coluna + 2 &&
                tab.pecas[origem.Linha, origem.Coluna].qteMovimentos == 0 &&
                tab.pecas[origem.Linha, origem.Coluna + 3] is Torre &&
                tab.pecas[origem.Linha, origem.Coluna + 3].qteMovimentos == 0 &&
                tab.pecas[origem.Linha, origem.Coluna + 1] == null &&
                tab.pecas[origem.Linha, origem.Coluna + 2] == null)
            {
                return(true);
            }

            /* Testar Roque Grande */


            if (!partida.emcheque &&
                destino.Linha == origem.Linha && destino.Coluna == origem.Coluna - 2 &&
                tab.pecas[origem.Linha, origem.Coluna].qteMovimentos == 0 &&
                tab.pecas[origem.Linha, origem.Coluna - 4] is Torre &&
                tab.pecas[origem.Linha, origem.Coluna - 4].qteMovimentos == 0 &&
                tab.pecas[origem.Linha, origem.Coluna - 1] == null &&
                tab.pecas[origem.Linha, origem.Coluna - 2] == null &&
                tab.pecas[origem.Linha, origem.Coluna - 3] == null)
            {
                return(true);
            }

            /* Logica Geral */

            for (int i = origem.Linha - 1; i < origem.Linha + 2; i++)
            {
                for (int j = origem.Coluna - 1; j < origem.Coluna + 2; j++)
                {
                    pos.Linha  = i;
                    pos.Coluna = j;
                    if (!tab.PosicaoValida(pos))
                    {
                        continue;
                    }
                    if (i == destino.Linha && j == destino.Coluna)
                    {
                        if (tab.pecas[i, j] == null || tab.pecas[i, j].cor !=
                            tab.pecas[origem.Linha, origem.Coluna].cor)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }
            return(false);
        }
Example #5
0
 public Peca(tabuleiro tab, Cor cor)
 {
     this.posicao       = null;
     this.tab           = tab;
     this.cor           = cor;
     this.qteMovimentos = 0;
 }
Example #6
0
        public static void ImprimirTabuleiro(tabuleiro Tab, Cor jogador)
        {
            for (int i = 0; i < Tab.linhas; i++)
            {
                Console.Write(8 - i + " ");
                for (int j = 0; j < Tab.colunas; j++)
                {
                    if (Tab.peca(i, j) == null)
                    {
                        Console.Write("- ");
                    }
                    else
                    {
                        imprimirpeca(Tab.peca(i, j));
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }
            Console.WriteLine("  a b c d e f g h");
            Console.WriteLine();
            if (jogador == Cor.Branca)
            {
                Console.WriteLine("As Brancas jogam !!! ");
            }
            else
            {
                Console.WriteLine("As pretas jogam !!! ");
            }

            Console.WriteLine();
        }
Example #7
0
        public override bool movimentospossiveis(tabuleiro tab, Posicao origem, Posicao destino)
        {
            if (origem.Linha == destino.Linha || origem.Coluna == destino.Coluna)
            {
                return(false);
            }

            Posicao pos = new Posicao(origem.Linha, origem.Coluna);

            while (pos.Linha != destino.Linha && pos.Coluna != destino.Coluna)
            {
                if (destino.Linha > origem.Linha)
                {
                    pos.Linha++;
                }
                else
                {
                    pos.Linha--;
                }

                if (destino.Coluna > origem.Coluna)
                {
                    pos.Coluna++;
                }
                else
                {
                    pos.Coluna--;
                }
                if (!tab.PosicaoValida(pos))
                {
                    return(false);
                }

                if (tab.peca(pos.Linha, pos.Coluna) == null)
                {
                    if (pos.Linha == destino.Linha &&
                        pos.Coluna == destino.Coluna)
                    {
                        return(true);
                    }
                    else
                    {
                        continue;
                    }
                }

                if (tab.peca(pos.Linha, pos.Coluna).cor !=
                    tab.peca(origem.Linha, origem.Coluna).cor&&
                    pos.Linha == destino.Linha &&
                    pos.Coluna == destino.Coluna)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
 public PartidaDeXadrez()
 {
     tab          = new tabuleiro(8, 8);
     turno        = 1;
     jogadorAtual = Cor.Branca;
     terminada    = false;
     colocarPecas();
 }
Example #9
0
        public override bool movimentospossiveis(tabuleiro tab, Posicao origem, Posicao destino)
        {
            if (destino.Linha == origem.Linha || destino.Coluna == origem.Coluna)
            {
                return(false);
            }

            if (destino.Linha > origem.Linha + 2 ||
                destino.Linha < origem.Linha - 2 ||
                destino.Coluna > origem.Coluna + 2 ||
                destino.Coluna < origem.Coluna - 2)
            {
                return(false);
            }

            if (destino.Linha == origem.Linha + 1 ||
                destino.Linha == origem.Linha - 1)
            {
                if (destino.Coluna == origem.Coluna + 2 ||
                    destino.Coluna == origem.Coluna - 2)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            if (destino.Linha == origem.Linha + 2 ||
                destino.Linha == origem.Linha - 2)
            {
                if (destino.Coluna == origem.Coluna + 1 ||
                    destino.Coluna == origem.Coluna - 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            if (tab.peca(destino.Linha, destino.Coluna) == null)
            {
                return(true);
            }

            if (tab.peca(destino.Linha, destino.Coluna).cor !=
                tab.peca(origem.Linha, origem.Coluna).cor)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #10
0
 public PartidadeXadrez()
 {
     tab          = new tabuleiro(8, 8);
     posrei       = new Posicao(8, 8);
     jogadoratual = Cor.Branca;
     emcheque     = false;
     encerrada    = false;
     colocarpecas();
 }
Example #11
0
 public PartidaXadrez()
 {
     tab                 = new tabuleiro(8, 8);
     turno               = 1;
     xeque               = false;
     terminada           = false;
     jogadorAtual        = Cor.Branca;
     vulneravelEnPassant = null;
     colocarPecas();
 }
Example #12
0
 public PartidaDeXadrez()
 {
     Tab                 = new tabuleiro(8, 8);
     Turno               = 1;
     JogadorAtual        = Cor.branca;
     Terminada           = false;
     Xeque               = false;
     VulneravelEnPassant = null;
     pecas               = new HashSet <Peca>();
     Capturadas          = new HashSet <Peca>();
     ColocarPecas();
 }
Example #13
0
 public PartidaXadrez()
 {
     tab                 = new tabuleiro(8, 8);
     turno               = 1;
     jogadorAtual        = Cor.Branca;
     terminada           = false;
     xeque               = false;
     vulneravelEnPassant = null;
     pecas               = new HashSet <Peca>();
     capturadas          = new HashSet <Peca>();
     colocarPecas();
 }
Example #14
0
 public PartidaDeXadrez()
 {
     tab          = new tabuleiro(8, 8);
     turno        = 1;
     jogadorAtual = Cor.Amarelo;
     terminada    = false;
     xeque        = false;
     enPassant    = null;
     pecas        = new HashSet <Peca>();
     capturada    = new HashSet <Peca>();
     colocarPecas();
 }
Example #15
0
 public static void imprimirTabuleiro(tabuleiro tab)
 {
     for (int i = 0; i < tab.linhas; i++)
     {
         Console.Write(" " + (8 - i) + " ");
         for (int j = 0; j < tab.colunas; j++)
         {
             imprimirPeca(tab.peca(i, j));
         }
         Console.WriteLine();
     }
     Console.WriteLine("    A  B  C  D  E  F  J  H");
 }
Example #16
0
 public static void imprimirTabuleiro(tabuleiro tab)
 {
     for (int i = 0; i < tab.linha; i++)
     {
         Console.Write(8 - i + " ");
         for (int j = 0; j < tab.coluna; j++)
         {
             imprimirPeca(tab.peca(i, j));
         }
         Console.WriteLine();
     }
     Console.WriteLine("  a b c d e f g h");
 }
Example #17
0
 public static void ImprimirTabuleiro(tabuleiro tab)
 {
     for (int i = 0; i < tab.Linha; i++)
     {
         Console.Write(8 - i + " ");
         for (int j = 0; j < tab.Coluna; j++)
         {
             if (tab.Peca(i, j) == null)
             {
                 Console.Write("- ");
             }
             else
             {
                 ImprimirPeca(tab.Peca(i, j));
                 Console.Write("");
             }
         }
         Console.WriteLine();
     }
     Console.WriteLine("  a b c d e f g h");
 }
Example #18
0
 public Cavalo(tabuleiro tab, Cor cor) : base(cor, tab)
 {
 }
Example #19
0
 public Peao(tabuleiro tab, Cor cor, PartidaDeXadrez partida) : base(cor, tab)
 {
     this.partida = partida;
 }
Example #20
0
 public Rei(tabuleiro tab, Cor cor) : base(tab, cor)
 {
 }
Example #21
0
 public Rei(tabuleiro tab, Cor cor, PartidaDeXadrez partida) : base(tab, cor)
 {
     this.partida = partida;
 }
Example #22
0
 public Torre(tabuleiro tab, Cor cor) : base(cor, tab)
 {
 }
Example #23
0
 public Bispo(tabuleiro tab, Cor cor) : base(cor, tab)
 {
 }
Example #24
0
        public override bool movimentospossiveis(tabuleiro tab, Posicao origem, Posicao destino)
        {
            if (tab.peca(origem.Linha, origem.Coluna).cor == Cor.Branca &&
                destino.Linha > origem.Linha)
            {
                return(false);
            }
            if (tab.peca(origem.Linha, origem.Coluna).cor == Cor.Preta &&
                destino.Linha < origem.Linha)
            {
                return(false);
            }

            if ((origem.Linha == 3 || origem.Linha == 4) &&
                destino.Coluna != origem.Coluna &&
                tab.peca(destino.Linha, destino.Coluna) == null &&
                tab.peca(origem.Linha, destino.Coluna) is Peao &&
                tab.peca(origem.Linha, destino.Coluna).cor !=
                tab.peca(origem.Linha, origem.Coluna).cor&&
                tab.peca(origem.Linha, destino.Coluna) == partida.vulneravelenpassant)
            {
                return(true);
            }

            if (destino.Linha == origem.Linha)
            {
                return(false);
            }

            if (destino.Coluna > origem.Coluna + 1 ||
                destino.Coluna < origem.Coluna - 1)
            {
                return(false);
            }

            if (tab.peca(origem.Linha, origem.Coluna).qteMovimentos == 0)
            {
                if (destino.Linha > origem.Linha + 2 ||
                    destino.Linha < origem.Linha - 2)
                {
                    return(false);
                }
                if ((destino.Linha == origem.Linha + 2 ||
                     destino.Linha == origem.Linha - 2) &&
                    destino.Coluna != origem.Coluna)
                {
                    return(false);
                }
            }
            if (tab.peca(origem.Linha, origem.Coluna).qteMovimentos != 0)
            {
                if (destino.Linha > origem.Linha + 1 ||
                    destino.Linha < origem.Linha - 1 ||
                    destino.Coluna > origem.Coluna + 1 ||
                    destino.Coluna < origem.Coluna - 1)
                {
                    return(false);
                }
            }
            if (tab.peca(destino.Linha, destino.Coluna) == null)
            {
                if (destino.Coluna == origem.Coluna)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            if (tab.peca(destino.Linha, destino.Coluna).cor !=
                tab.peca(origem.Linha, origem.Coluna).cor&&
                destino.Coluna != origem.Coluna)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #25
0
 public Dama(tabuleiro tab, Cor cor) : base(tab, cor)
 {
 }
Example #26
0
 public Bispo(tabuleiro tab, Cor cor) : base(tab, cor)
 {
 }
Example #27
0
 public Cavalo(tabuleiro tab, Cor cor) : base(tab, cor)
 {
 }
Example #28
0
 public Torre(tabuleiro tab, Cor cor) : base(tab, cor)
 {
 }
Example #29
0
 public Peao(tabuleiro tab, Cor cor, PartidaXadrez partida) : base(tab, cor)
 {
     this.partida = partida;
 }
Example #30
0
 public Rainha(tabuleiro tab, Cor cor) : base(cor, tab)
 {
 }