Class: Patience::Tableau

Inherits:
Area show all
Defined in:
lib/patience/tableau.rb

Overview

Patience::Area::Foundation is a class, which represents Tableau area of the game. Every ordinary Tableau should have 7 piles and 28 cards in them. Each pile has 1 + “serial number of the pile” cards. Every last card in every pile is turned to its face. The other cards are face down.

cards = []
cards = 28.times { cards << Card.new(1, 1) }
tableau = Tableau.new(cards)
tableau.piles.size #=> 7
tableau.cards.size #=> 28

Instance Attribute Summary

Attributes inherited from Area

#piles

Instance Method Summary collapse

Methods inherited from Area

#add_from, #cards, #draw_on, #hit?, #pos

Constructor Details

#initialize(cards) ⇒ Tableau

Returns a new instance of Tableau.



17
18
19
20
21
# File 'lib/patience/tableau.rb', line 17

def initialize(cards)
  super(cards, 7)
  @piles.each_with_index { |pile, i| pile.cards += @cards.shuffle_off!(i+1) }
  self.pos = [31, 175]
end