// Copyright 2005 David Caldwell <david@porkrind.org>, Jim Radford <radford@blackbean.org> -*- c -*-
function work(div,game){pile.prototype.init.call(this,div,game);this.accept_stacks=true;this.can_drag=function(index){return in_order_by(in_numeric_order,this.pile,index)&&this.pile.length-index<=drag_max_given_free(game.work);};this.accept=function(cards){return this.pile.length==0&&cards.length<=drag_max_given_free(game.work,this)?1:this.pile.length!=0&&in_suit_order(cards[0],this.top())?3:this.pile.length!=0&&in_numeric_order(cards[0],this.top())?2:0;};}
work.prototype.xoffset=0;work.prototype=new pile();function reserve(div,game){pile.prototype.init.call(this,div,game);this.accept=function(card){return false;}
this.can_drag=function(index){return true;}
this.drag_stacks=false;}
reserve.prototype=new pile();function game(){pile_game.prototype.init.call(this,this.name);this.good=new Array(0);this.work=new Array(0);for(var c=1;c<=4;c++)
this.good.push(new generic_foundation("good"+c,this,true));for(var c=1;c<=10;c++)
if(doc.id("work"+c))
this.work.push(new work("work"+c,this));this.reserve=new reserve("reserve",this);}
game.prototype=new pile_game();game.prototype.name="flower";game.prototype.deal=function(deck){this.reserve.pile=deck;for(var y=0;y<6;y++)
for(var w in this.work){var c;this.work[w].push(c=this.reserve.pop());c.face=up;}
for(var c=0;c<this.reserve.pile.length;c++)
this.reserve.pile[c].face=up;};game.prototype.is_complete=function(){return this.good[0].pile.length==13&&this.good[1].pile.length==13&&this.good[2].pile.length==13&&this.good[3].pile.length==13&&WON;}
game.prototype.complete=function(){return this.complete_generic(this.good,[this.work,[this.reserve]]);}
