jogo do galo- 2ª parte

 

textcolor(0);
       textbackground(0);
       clrscr;
       textcolor(7);
       { Ambiente }
       textcolor(2);
       gotoxy(34,1);
       writeln('JOGO DO GALO');
       { Quadro do Jogador 1 }
       textcolor(4);
       gotoxy(10,3);
       writeln('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
       gotoxy(10,4);
       writeln('º             º');
       gotoxy(10,5);
       writeln('ÌÍÍÍÍÍÍÍÍÍËÍÍ͹');
       gotoxy(10,6);
       writeln('º         º   º');
       gotoxy(10,7);
       writeln('ÈÍÍÍÍËÍÍÍËÊÍÍͼ');
       gotoxy(10,8);
       writeln('     º   º');
       gotoxy(10,9);
       writeln('     ÈÍÍͼ');
       { Quadro do jogador 2 }
       textcolor(4);
       gotoxy(55,3);
       writeln('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
       gotoxy(55,4);
       writeln('º             º');
       gotoxy(55,5);
       writeln('ÌÍÍÍÍÍÍÍÍÍËÍÍ͹');
       gotoxy(55,6);
       writeln('º         º   º');
       gotoxy(55,7);
       writeln('ÈÍÍÍÍËÍÍÍËÊÍÍͼ');
       gotoxy(55,8);
       writeln('     º   º');
       gotoxy(55,9);
       writeln('     ÈÍÍͼ');
       textcolor(3);
       gotoxy(57,6);
       write('PONTOS');
       textcolor(4);
       write(':');
       textcolor(3);
       gotoxy(12,6);
       write('PONTOS');
       textcolor(4);
       write(':');
       { preencher quadros }
       textcolor(15);
       textbackground(0);
       gotoxy(17-trunc((length(jog1.nm) / 2)),4);
       write(jog1.nm);
       gotoxy(62-trunc((length(jog2.nm) / 2)),4);
       write(jog2.nm);
       textcolor(10);
       gotoxy(22,6);
       write(jog1.pt);
       gotoxy(67,6);
       write(jog2.pt);
       gotoxy(17,8);
       textcolor(14);
       write(jog1.simb);
       gotoxy(62,8);
       textcolor(14);
       write(jog2.simb);
       { Quadro da VEZ  }
       textcolor(11);
       textbackground(0);
       gotoxy(33,4);
       write('³            ³');
       gotoxy(33,5);
       write('ÃÄÄÄÄÄÄÄÄÄÄÄÄ´');
       gotoxy(33,6);
       write('³            ³');
       gotoxy(33,7);
       write('ÀÄÄÄÄÄÄÄÄÄÄÄÄÙ');
       textcolor(6);
       gotoxy(35,4);
       writeln(' A VEZ DO');
       { casas }
       textcolor(1);
       gotoxy(34,10);
       writeln('   ³   ³   ');
       gotoxy(34,11);
       writeln('ÄÄÄÅÄÄÄÅÄÄÄ');
       gotoxy(34,12);
       writeln('   ³   ³   ');
       gotoxy(34,13);
       writeln('ÄÄÄÅÄÄÄÅÄÄÄ');
       gotoxy(34,14);
       writeln('   ³   ³   ');
       { caixa de mensagens }
       gotoxy(10,17);
       textcolor(2);
       write('É');
       for c:=0 to 23 do
         write('Í');
       write('¹');
       textcolor(4);
       textbackground(3);
       write('MENSAGENS');
       textbackground(0);
       textcolor(2);
       write('Ì');
       for c:=0 to 23 do
           write('Í');
       write('»');
       {--}
       gotoxy(10,18);
       write('º');
       gotoxy(10,19);
       write('º');
       gotoxy(10,20);
       write('º');
       {-}
       gotoxy(70,18);
       write('º');
       gotoxy(70,19);
       write('º');
       gotoxy(70,20);
       write('º');
       {--}
       gotoxy(10,21);
       write('È');
       for c:=0 to 58 do
           write('Í');
       write('¼');
       KeyPadmsg;
       { creditos  }
       gotoxy(3,25);
       textcolor(8);
       Write('Feito por: ');
       textcolor(7);
       write('Ricardo Pinto');
       { Principal }
       Repeat
           tent:=tent+1;
           if odd(tent) then simb:='X'
           else simb:='O';
           if simb=jog1.simb then
              begin
                   gotoxy(34,6);
                   textbackground(0);
                   write('           ');
                   gotoxy(40-trunc(length(jog1.nm) /2),6);
                   textcolor(14);
                   write(jog1.nm);
                   textcolor(11);
                   gotoxy(46,5);
                   write('´    ');
                   gotoxy(46,6);
                   write('³    ');
                   gotoxy(46,7);
                   write('Ù    ');
                   textcolor(11);
                   gotoxy(29,5);
                   write('ÚÄÄÄÅ');
                   gotoxy(29,6);
                   write('³   ³');
                   gotoxy(29,7);
                   write('ÀÄÄÄÁ');
                   textcolor(14);
                   textbackground(4);
                   gotoxy(30,6);
                   write(' ',simb,' ');
              end
           else if simb=jog2.simb then
                begin
                   gotoxy(34,6);
                   textbackground(0);
                   write('           ');
                   gotoxy(40-trunc(length(jog2.nm) /2),6);
                   textcolor(14);
                   write(jog2.nm);
                   textcolor(11);
                   gotoxy(29,5);
                   write('    Ã');
                   gotoxy(29,6);
                   write('    ³');
                   gotoxy(29,7);
                   write('    À');
                   textcolor(11);
                   gotoxy(46,5);
                   write('ÅÄÄÄ¿');
                   gotoxy(46,6);
                   write('³   ³');
                   gotoxy(46,7);
                   write('ÁÄÄÄÙ');
                   textcolor(14);
                   textbackground(4);
                   gotoxy(47,6);
                   write(' ',simb,' ');
                end;
           {--}
           p:
           tecla:=readkey;
           if tecla=#0 then
              tecla:=readkey;
           clrmsg;
           case ord(tecla) of
                55:
                   begin
                        if cs[1].ck=false then
                           begin
                                cs[1].ck:=true;
                                cs[1].simb:=simb;
                                gotoxy(35,10);
                                textcolor(14);
                                write(simb);
                           end
                        else goto p;
                   end;
                56:
                   begin
                        if cs[2].ck=false then
                           begin
                                cs[2].ck:=true;
                                cs[2].simb:=simb;
                                gotoxy(39,10);
                                textcolor(14);
                                write(simb);
                           end
                        else goto p;
                   end;
                57:
                   begin
                        if cs[3].ck=false then
                           begin
                                cs[3].ck:=true;
                                cs[3].simb:=simb;
                                gotoxy(43,10);
                                textcolor(14);
                                write(simb);
                           end
                        else goto p;
                   end;
                52:
                   begin
                        if cs[4].ck=false then
                           begin
                                cs[4].ck:=true;
                                cs[4].simb:=simb;
                                gotoxy(35,12);
                                textcolor(14);
                                write(simb);
                           end
                        else goto p;
                   end;
                53:
                   begin
                        if cs[5].ck=false then
                           begin
                                cs[5].ck:=true;
                                cs[5].simb:=simb;
                                gotoxy(39,12);
                                textcolor(14);
                                write(simb);
                           end
                        else goto p;
                   end;
                54:
                   begin
                        if cs[6].ck=false then
                           begin
                                cs[6].ck:=true;
                                cs[6].simb:=simb;
                                gotoxy(43,12);
                                textcolor(14);
                                write(simb);
                           end
                        else goto p;
                   end;
                49:
                   begin
                        if cs[7].ck=false then
                           begin
                                cs[7].ck:=true;
                                cs[7].simb:=simb;
                                gotoxy(35,14);
                                textcolor(14);
                                write(simb);
                           end
                        else goto p;
                   end;
                50:
                   begin
                        if cs[8].ck=false then
                           begin
                                cs[8].ck:=true;
                                cs[8].simb:=simb;
                                gotoxy(39,14);
                                textcolor(14);
                                write(simb);
                            end
                        else goto p;
                   end;
                51:
                   begin
                        if cs[9].ck=false then
                           begin
                                cs[9].ck:=true;
                                cs[9].simb:=simb;
                                gotoxy(43,14);
                                textcolor(14);
                                write(simb);
                           end
                        else goto p;
                   end;
              { Caso Num Lock Desligado }
                71:begin numlmsg; goto p; end;
                72:begin ambasmsg; goto p; end;
                73:begin numlmsg; goto p; end;
                75:begin ambasmsg; goto p; end;
                77:begin ambasmsg; goto p; end;
                79:begin numlmsg; goto p; end;
                80:begin ambasmsg; goto p; end;
                81:begin numlmsg; goto p; end;
             { Caso Escape }
                27:goto fim;
             { caso outra tecla }
                else
                    begin
                        keypadmsg;
                        goto p;
                    end;
           end;
         { Fim do case }
  {XOX Verifica‡Æo de tres em linha XOX}
       { -- LINHA de cima --}
           if ((cs[1].ck=true) and (cs[2].ck=true) and (cs[3].ck=true)) then
              if ((cs[1].simb=jog1.simb) and (cs[2].simb=jog1.simb) and (cs[3].simb=jog1.simb)) then
                 begin
                      jog1win(jog1.nm,jog1.simb);
                      jog1.pt:=jog1.pt+1;
                      linha:=true;
                 end
              else
                  if ((cs[1].simb=jog2.simb) and (cs[2].simb=jog2.simb) and (cs[3].simb=jog2.simb)) then
                     begin
                          jog2win(jog2.nm,jog2.simb);
                          jog2.pt:=jog2.pt+1;
                          linha:=true;
                     end;
       { -- LINHA do meio --}
           if ((cs[4].ck=true) and (cs[5].ck=true) and (cs[6].ck=true)) then
              if ((cs[4].simb=jog1.simb) and (cs[5].simb=jog1.simb) and (cs[6].simb=jog1.simb)) then
                 begin
                      jog1win(jog1.nm,jog1.simb);
                      jog1.pt:=jog1.pt+1;
                      linha:=true;
                 end
              else
                  if ((cs[4].simb=jog2.simb) and (cs[5].simb=jog2.simb) and (cs[6].simb=jog2.simb)) then
                     begin
                          jog2win(jog2.nm,jog2.simb);
                          jog2.pt:=jog2.pt+1;
                          linha:=true;
                     end;
       { -- LINHA do baixo --}
           if ((cs[7].ck=true) and (cs[8].ck=true) and (cs[9].ck=true)) then
              if ((cs[7].simb=jog1.simb) and (cs[8].simb=jog1.simb) and (cs[9].simb=jog1.simb)) then
                 begin
                      jog1win(jog1.nm,jog1.simb);
                      jog1.pt:=jog1.pt+1;
                      linha:=true;
                 end
              else
                  if ((cs[7].simb=jog2.simb) and (cs[8].simb=jog2.simb) and (cs[9].simb=jog2.simb)) then
                     begin
                          jog2win(jog2.nm,jog2.simb);
                          jog2.pt:=jog2.pt+1;
                          linha:=true;
                     end;
       { -- 1§ COLUNA --}
           if ((cs[1].ck=true) and (cs[4].ck=true) and (cs[7].ck=true)) then
              if ((cs[1].simb=jog1.simb) and (cs[4].simb=jog1.simb) and (cs[7].simb=jog1.simb)) then
                 begin
                      jog1win(jog1.nm,jog1.simb);
                      jog1.pt:=jog1.pt+1;
                      linha:=true;
                 end
              else
                  if ((cs[1].simb=jog2.simb) and (cs[4].simb=jog2.simb) and (cs[7].simb=jog2.simb)) then
                     begin
                          jog2win(jog2.nm,jog2.simb);
                          jog2.pt:=jog2.pt+1;
                          linha:=true;
                     end;
       { -- 2§ COLUNA --}
           if ((cs[2].ck=true) and (cs[5].ck=true) and (cs[8].ck=true)) then
              if ((cs[2].simb=jog1.simb) and (cs[5].simb=jog1.simb) and (cs[8].simb=jog1.simb)) then
                 begin
                      jog1win(jog1.nm,jog1.simb);
                      jog1.pt:=jog1.pt+1;
                      linha:=true;
                 end
              else
                  if ((cs[2].simb=jog2.simb) and (cs[5].simb=jog2.simb) and (cs[8].simb=jog2.simb)) then
                     begin
                          jog2win(jog2.nm,jog2.simb);
                          jog2.pt:=jog2.pt+1;
                          linha:=true;
                     end;
       { -- 3§ COLUNA --}
           if ((cs[3].ck=true) and (cs[6].ck=true) and (cs[9].ck=true)) then
              if ((cs[3].simb=jog1.simb) and (cs[6].simb=jog1.simb) and (cs[9].simb=jog1.simb)) then
                 begin
                      jog1win(jog1.nm,jog1.simb);
                      jog1.pt:=jog1.pt+1;
                      linha:=true;
                 end
              else
                  if ((cs[3].simb=jog2.simb) and (cs[6].simb=jog2.simb) and (cs[9].simb=jog2.simb)) then
                     begin
                          jog2win(jog2.nm,jog2.simb);
                          jog2.pt:=jog2.pt+1;
                          linha:=true;
                     end;
       { -- DIAGONAL \ --}
           if ((cs[1].ck=true) and (cs[5].ck=true) and (cs[9].ck=true)) then
              if ((cs[1].simb=jog1.simb) and (cs[5].simb=jog1.simb) and (cs[9].simb=jog1.simb)) then
                 begin
                      jog1win(jog1.nm,jog1.simb);
                      jog1.pt:=jog1.pt+1;
                      linha:=true;
                 end
              else
                  if ((cs[1].simb=jog2.simb) and (cs[5].simb=jog2.simb) and (cs[9].simb=jog2.simb)) then
                     begin
                          jog2win(jog2.nm,jog2.simb);
                          jog2.pt:=jog2.pt+1;
                          linha:=true;
                     end;
       { -- DIAGONAL  /   --}
           if ((cs[3].ck=true) and (cs[5].ck=true) and (cs[7].ck=true)) then
              if ((cs[3].simb=jog1.simb) and (cs[5].simb=jog1.simb) and (cs[7].simb=jog1.simb)) then
                 begin
                      jog1win(jog1.nm,jog1.simb);
                      jog1.pt:=jog1.pt+1;
                      linha:=true;
                 end
              else
                  if ((cs[3].simb=jog2.simb) and (cs[5].simb=jog2.simb) and (cs[7].simb=jog2.simb)) then
                     begin
                          jog2win(jog2.nm,jog2.simb);
                          jog2.pt:=jog2.pt+1;
                          linha:=true;
                     end;
  {XOX Fim de Verifica‡Æo de tres em linha XOX}
       until ((linha=true) or (tent=9));
   {++++++++++ Fim do Repeat ++++++++++++}
       if ((tent=9) and (linha=false)) then
        begin
             clrmsg;
             textcolor(5+128);
             gotoxy(31,19);
             write('Ninguem Ganhou !!');
        end;
       tecla:=readkey;
     until ((jog1.pt=max_num) or (jog2.pt=max_num));
   if jog1.pt>jog2.pt then
      begin
           if tecla=#0 then
              tecla:=readkey;
           textcolor(7);
           textbackground(2);
           clrscr;
           textbackground(1);
           gotoxy(1,1);
           clreol;
           gotoxy(34,1);
           textcolor(15);
           writeln('JOGO DO GALO');
           textbackground(2);
           textcolor(4);
           gotoxy(34,6);
           writeln('PARABNS !!');
           gotoxy(18,15);
           textcolor(1);
           write('O ',jog1.nm);
           textcolor(6+blink);
           write(' GANHOU ');
           textcolor(1);
           write('com ');
           textcolor(5);
           write(jog1.pt-jog2.pt);
           textcolor(1);
           write(' ponto(s) de vantagem.');
           festa_1;
           readkey;
      end
   else if jog2.pt>jog1.pt then
      begin
           if tecla=#0 then
              tecla:=readkey;
           textcolor(7);
           textbackground(2);
           clrscr;
           textbackground(1);
           gotoxy(1,1);
           clreol;
           gotoxy(34,1);
           textcolor(15);
           writeln('JOGO DO GALO');
           textbackground(2);
           textcolor(4);
           gotoxy(34,6);
           writeln('PARABNS !!');
           gotoxy(18,15);
           textcolor(1);
           write('O ',jog2.nm);
           textcolor(6+blink);
           write(' GANHOU ');
           textcolor(1);
           write('com ');
           textcolor(5);
           write(jog2.pt-jog1.pt);
           textcolor(1);
           write(' ponto(s) de vantagem.');
           festa_2;
           readkey;
      end;
 
   fim:
   textcolor(7);
   textbackground(0);
   clrscr;
   writeln('Obrigado por ter jogado ao GALO.');
   writeln('E volte sempre !');
end.