eval("eval(\"(onkeyupAif([q$=Math,M=$.min,qc.style.display='block'][Q=e.keyCode-48L2]){g=[];IS=[i=104];i--;gD$.random()*9qq{c:i%Q,w:i%13}))i>9NU=gDT=C=qi%3?5:6P(onresizeJdownJmoveJupAd(5,qqW=c.width=innerWidth,H=c.height=innerHeightPa.scale(u=M(H/.7,W)/334,uPRVX/u-6,kVY/u-5qe=(e.typeL0)[7];if(s=S[x=R>>5])if(y=M(k/Et++),e=='w')IT=(X=s)[Y=y]GFu?1:0;TG--t-y;T=s[t].w-Fw+t-yLs[t].c-FcNT+1POeLxLk<0GgBGrGUD9qqg.pop()PeLsGTG(xGk<0?T-13L++CGXDY,T):S[x]=s.concat(XDY,tGX[Y].w+1-s[t-1].wNT))PIeNT=qp=r=2;p--;)O{pGi-1_Z1qqqq+i?i<C+2?1:2:gB/gBPIy in s=U)m=TGX==sGY<=y,m-p_m?R-9:Zm?k+(y-Y)*8+44:50+y*EFu|=y==t,Fc,Fw,1Pr=rGsB}})(dAp?p-2_y?3:1qe,x,26,34)Ld(yN5+p,e+.5,x+.5,25,33)Ly_3-w%2,('ЈQΚА'[h?h-10:3]Lh+1)+'♠♥♣♦'[yGw],e+3,x+10):(KStyle='#'+'fff0004172aaa'.substr(e,3),h?KRect(j,h):KText(j))})}})(0)\"!_Gd(!Zi*32+1q!V=e.page!US[i]!P);!OIi in S)!N?0:!L||!Ka.fill!J=onmouse!Ifor(!G&&!Fs[y].!EM(1q(H/u-90)/(t=sB-1))|q!D.splice(!B.length!A=function(e,j,h,p){!q0,!jx,y,w)".replace(/!(\w)([^!]*)(?!$)/g,".replace(/$1/g,'$2')"))
// \ /
// \ /\____/\ /
// \ /\/ \/\ /
// \ /\( )/\ /
// 1k \ /\\____//\ / by
// Spider \ (#__#) / @veubeke
// Solitaire \ ' ' / games.23inch.de/spider
// \ /
// Features: \ / Optimizations:
// * 1,2 or 4 colors \ / * dictionary compression
// * automatic resize \ / * cyrillic letters to save J,Q and K for compression
// \/ * too many to name them all...
// start a new game
(onkeyup = function(e,x,y,w,h,p) {
// allow only keys 1,2,4 (default: 2)
if([0,$=Math,min=$.min,0,c.style.display='block'][colors=e.keyCode-48||2]) {
// create cards
cards = [];
for(stacks=[i=104]; i--; cards.splice($.random()*90,0,{c:i%colors,w:i%13}))
i>9 ? 0 : stacks[i] = cards.splice(marked=current=0,i%3?5:6);
// update the game state
(onresize = onmousedown = onmousemove = onmouseup = function(e,x,y,w,h,p) {
// draw background
draw(5,0,0,width=c.width=innerWidth,height=c.height=innerHeight);
// resize to fill window
a.scale(scale=min(height/.7,width)/334,scale);
// get input
mouseX = e.pageX/scale-6,
mouseY = e.pageY/scale-50,
e = (e.type||0)[7];
// mark cards
if(s=stacks[x = mouseX >> 5])
if(y=min(mouseY/min(10,(height/scale-90)/(t=s.length-1))|0, t++),e=='w')
for(marked=(markS=s)[markY=y]&&s[y].u?1:0; marked&&--t-y;
marked = s[t].w-s[y].w+t-y||s[t].c-s[y].c?0:marked+1);
// deal cards
for(i in stacks)
e || x || mouseY<0 && cards.length && occupied && stacks[i].splice(90,0,cards.pop());
// move cards
e || s && marked && (
// remove completed deck
x&&mouseY<0 ? marked-13 || ++current && markS.splice(markY,marked)
// move cards in tableau
: stacks[x] = s.concat(markS.splice(markY, t&&markS[markY].w+1-s[t-1].w?0:marked))
);
// draw stock, tableau and foundations
for(e?0:marked=0,p=occupied=2; p--;)
for(i in stacks) {
// stock and foundations
p && i-1 && draw(i*32+10,10,0,0,0,+i?i<current+2?1:2:cards.length/cards.length);
// tableau
for(y in s=stacks[i])
m = marked&&markS==s&&markY<=y,
m-p && draw(m?mouseX-9:i*32+10,m?mouseY+(y-markY)*8+44:50+y*min(10,(height/scale-90)/(t=s.length-1))|0,
s[y].u |= y==t,s[y].c,s[y].w,1);
occupied = occupied && s.length
}
})(
// draw a card, a rectangle or a symbol
draw = function(e,x,y,w,h,p) {
// draw card
p ? p-2&&draw(y?3:10,e,x,26,34)||draw(y?0:5+p,e+.5,x+.5,25,33)||
y&&draw(3-w%2,('ЈQΚА'[h?h-10:3]||h+1)+'♠♥♣♦'[y&&w],e+3,x+10)
// draw rectangle / symbol
: (a.fillStyle = '#'+'fff0004172aaa'.substr(e,3),
h?a.fillRect(x,y,w,h):a.fillText(x,y,w))
})
}
})(0)