Skip to main content
2 of 7
added 512 characters in body
edc65
  • 32.2k
  • 3
  • 36
  • 90

#JavaScript (E6) ~750

To be golfed

3 kinds of shapes:

  1. Back and Jocker: more or less literal
  2. JQK: mark at topleft and rightbottom, inner frame and 3 kind of rows inside, always the same structure
  3. A...10: mark at topleft and rightbottom, inner frame with 3 kind of rows inside, variable with the numeric value. Taken care of with lookup using array q

The z string (compressed) contains the basic building blocks for

  • numeric cards - 3 blocks, 7 chars each
  • joker - 11 blocks, 13 char each, used simply in sequence
F=c=>
{
  p='|',b=' ',d=b+b,t=d+b;
  l='------';
  z="9X2X4XJ55O10-2K |6|1E | J4|1R |1O3|3|2K2|3|3E1| J1|4R | O1|6| K20-1E55R".replace(/\d/g,n=>-n?b.repeat(-~n):l);
  c=c.split(b);
  for(o=i=''; c[0]&&i<13; i++)
  {
    o+=c.map(c => {
      if (i==0 || i==12) r=' -'+l+l+b;
      else
      {
        if (c=='B') r=' *'.repeat(7).substr(i&1,13);
        else if (c=='R') r=z.substr(i*13+8,13);
        else {
          [,h,k]=c.match(/(.+)(.)/),n=h-1|0,
          k='♣♦♥♠'[{C:0,D:1,H:2,S:3}[k]],
          r=t+t+t+(n>8?b:d);
          if(i==1)r=h+k+r;
          else if(i==11)r+=k+h;
          else if(i==2||i==10)r=t+'-'+l+t;
          else {
            if (h>'A')
            {
              if(i==3)r=k+t+t;
              else if(i==9)r=t+t+k;
              else if(i==6)r=t+h+t;
              else r=t+b+t
            }
            else 
            { 
              q=[64,1028,1092,8194,8258,8322,8326,9350,8802,9766][n]>>(i+i-6)&3,
              r=z.substr(q*7,7).replace(/X/g,k)
            }
            r=d+p+r+p+d
          }
        }
        r=p+r+p
      }
      return r
    }).join(' ')+'\n'
  }  
  console.log(o);
}
edc65
  • 32.2k
  • 3
  • 36
  • 90