board=klass() function board:init(ruleset) self.ruleset=ruleset self.cursor=cursor:new(self) self.animator=animator:new() self.slots={} self.wells={} -- board slots -- ...n_slots: normal for i=1,ruleset.n_slots do add(self.slots,slot:new(ruleset)) end -- n_slots+1: special add(self.slots,slot:new(ruleset,1)) -- wells: -- ...n_suits: wands, cups, swords, pentacles, etc local function add_suit(_self,suit) add(_self.wells,well:new(_self.ruleset, function(lst,new) assert(lst) -- the ace is always present initially if (new.suit!=suit) return return new.suit==suit and new.rank==lst.rank+1 end)) end for suit in all(self.ruleset.deck.suits) do add_suit(self,suit) end -- n_suits+1: arcana ascending add(self.wells,well:new(self.ruleset,function(lst,new) if (new.suit!='a') return if (not lst) return new.rank==0 return new.rank==lst.rank+1 end)) -- n_suits+2: arcana descending add(self.wells,well:new(self.ruleset,function(lst,new) if (new.suit!='a') return if (not lst) return new.rank==self.ruleset.n_arcana-1 return new.rank==lst.rank-1 end)) self:deal() end function board:deal() local n_usable_slots=self.ruleset.n_slots - 1 -- first, pull the aces local available={} for card=1,#self.ruleset.deck.cards do available[card]=true end for i=1,#self.ruleset.deck.aces do local well=self.wells[i] local ace=self.ruleset.deck.aces[i] well:add(ace) -- temporarily, so would_accept will work self:animate_move_ace_to_well(ace,i) available[ace]=false end local eligible_bottom_row={} for card=1,#self.ruleset.deck.cards do local skip if not available[card] then skip=true else for w in all(self.wells) do if (w:would_accept(card)) skip=true break end end if (not skip) add(eligible_bottom_row,card) end -- let the animation install the aces for real for w in all(self.wells) do w:clear() end function i_to_slot(i) if (i