Class: GlimmerKlondikeSolitaire::Model::Game

Inherits:
Object
  • Object
show all
Defined in:
app/glimmer_klondike_solitaire/model/game.rb

Constant Summary collapse

COLUMN_PILE_COUNT =
7

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGame

Returns a new instance of Game.



14
15
16
17
18
19
20
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 14

def initialize
  @deck = new_deck
  @dealt_pile = DealtPile.new(self)
  @dealing_pile = DealingPile.new(self)
  @column_piles = COLUMN_PILE_COUNT.times.map {|n| ColumnPile.new(self, n + 1)}
  @foundation_piles = PlayingCard::SUITS.map {|suit| FoundationPile.new(self, suit)}
end

Instance Attribute Details

#column_pilesObject (readonly)

Returns the value of attribute column_piles.



12
13
14
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 12

def column_piles
  @column_piles
end

#dealing_pileObject (readonly)

Returns the value of attribute dealing_pile.



12
13
14
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 12

def dealing_pile
  @dealing_pile
end

#dealt_pileObject (readonly)

Returns the value of attribute dealt_pile.



12
13
14
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 12

def dealt_pile
  @dealt_pile
end

#deckObject (readonly)

Returns the value of attribute deck.



12
13
14
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 12

def deck
  @deck
end

#foundation_pilesObject (readonly)

Returns the value of attribute foundation_piles.



12
13
14
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 12

def foundation_piles
  @foundation_piles
end

Instance Method Details

#restart!Object



22
23
24
25
26
27
28
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 22

def restart!
  @deck = new_deck
  @dealt_pile.reset!
  @dealing_pile.reset!
  @column_piles.each(&:reset!)
  @foundation_piles.each(&:reset!)
end