// Copyright 2006 David Caldwell <david@greenfelt.net>, Jim Radford <jim@greenfelt.net>  All rights reserved. -*- c -*- 
function tableau(div,game){pile.prototype.init.call(this,div,game);this.accept_stacks=true;this.accept=function(cards){return this.pile.length==0&&cards.length<=drag_max_given_free(game.tableau,this)?1:this.pile.length!=0&&in_suit_order(cards[0],this.top())?3:0;};this.drag_order=in_suit_order;this.can_drag=function(index){return in_order_by(in_suit_order,this.pile,index)&&this.pile.length-index<=drag_max_given_free(game.tableau);};this.xoffset=0;}
tableau.prototype=new pile();function game(){pile_game.prototype.init.call(this,this.game);this.decks=2;this.foundation=[];for(var i=1;i<=8;i++)
this.foundation.push(new generic_foundation("good"+i,this));this.tableau=[];for(var i=1;i<=10;i++)
this.tableau.push(new tableau("tableau"+i,this));this.stock=new pile("stock",this);this.waste=new pile("waste",this);this.create_deck(this.stock,this.waste,1,0);this.stock.xoffset=this.stock.yoffset=.3;this.deal=function(deck){this.stock.pile=deck;for(var c=0;c<40;c++){var card;this.tableau[c%this.tableau.length].push(card=this.stock.pop());card.face=up;}};}
game.prototype=new pile_game();game.prototype.game="fortythieves";game.prototype.is_complete=function(){for(var i in this.foundation)
if(this.foundation[i].pile.length==0||this.foundation[i].top().rank!=king)
return NOT_COMPLETE;return WON;}
game.prototype.complete=function(){return this.complete_generic(this.foundation,[this.tableau,[this.waste]]);}
