freakvista 0 Light Poster

Hy! I'm trying to make a new game and i have some problems...
First it chooses how many player it'll be, then the whole deck is slit, and it gives each player aprox the same amount of cards.
It works pretty well at 3,4,5,6 but it blocks at 2. I don't know what it's wrong with my algorithm

uses crt;
var n,x,i,j:byte;
    juc:array[1..6,1..26] of byte;

procedure nr_carti(nr:byte);          
begin for i:=1 to nr do
        juc[i,1]:=52 div nr;
      i:=0;
      while 52 mod nr-i<>0 do
      begin i:=i+1;
            juc[i,1]:=juc[i,1]+1
      end;
      for i:=1 to nr do write(juc[i,1]:4)
end;

procedure shuffle(nr:byte);
var a,b:byte;
    gasit:boolean;
begin writeln;
      writeln;
      for i:=1 to nr do
      begin for j:=2 to juc[i,1]+1 do
            begin repeat
                   gasit:=false;
                   juc[i,j]:=(random(13)+1)*10+(random(4)+1);      
                   a:=1;
                   while (a<=i-1) and not gasit do     
                   begin b:=2;
                         while (b<=juc[a,1]+1) and not gasit do
                         begin if juc[i,j]=juc[a,b] then gasit:=true;
                               b:=b+1
                         end;
                         a:=a+1
                   end;
                   b:=2;
                   while (b<=j-1) and not gasit do
                   begin if juc[i,j]=juc[i,b] then gasit:=true;
                         b:=b+1;
                   end
                  until not gasit;
            end;
      end;
end;

procedure type(y:byte);           
begin case y of
        1: begin textcolor(red);
                 write(chr(3));
           end;
        2: begin textcolor(red);
                 write(chr(4));
           end;
        3: begin textcolor(black);
                 write(chr(5));
           end;
        4: begin textcolor(black);
                 write(chr(3));
           end;
      end;
      textcolor(white);
end;

begin textbackground(green);
      textcolor(white);
      clrscr;
      write('Players(2-6)= '); readln(n);
      if (n>=2) and (n<=6) then
      begin nr_carti(n);
            randomize;
            shuffle(n);
            for i:=1 to n do
            begin for j:=2 to juc[i,1]+1 do
                  begin x:=juc[i,j] div 10;
                        case x of                             
                         1:begin write(' ACE ');
                                 tip(juc[i,j] mod 10);
                           end;
                         2:begin write(' 2 ');
                                 tip(juc[i,j] mod 10);
                           end;
                         3:begin write(' 3 ');
                                 tip(juc[i,j] mod 10);
                           end;
                         4:begin write(' 4 ');
                                 tip(juc[i,j] mod 10);
                           end;
                         5:begin write(' 5 ');
                                 tip(juc[i,j] mod 10);
                           end;
                         6:begin write(' 6 ');
                                 tip(juc[i,j] mod 10);
                           end;
                         7:begin write(' 7 ');
                                 tip(juc[i,j] mod 10);
                           end;
                         8:begin write(' 8 ');
                                 tip(juc[i,j] mod 10);
                           end;
                         9:begin write(' 9 ');
                                 tip(juc[i,j] mod 10);
                           end;
                         10:begin write(' 10 ');
                                  tip(juc[i,j] mod 10);
                            end;
                         11:begin write(' J ');
                                  tip(juc[i,j] mod 10);
                            end;
                         12:begin write(' Q ');
                                  tip(juc[i,j] mod 10);
                            end;
                         13:begin write(' K ');
                                  tip(juc[i,j] mod 10);
                            end;
                  end;
            end;
            writeln;
            writeln;
            writeln;
      end;
      end;
      readln
end.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.