Sha256: daf4072db4da09557a815265e41a5e360ceeffb17c9cae1353e1858debf0feae

Contents?: true

Size: 983 Bytes

Versions: 83

Compression:

Stored size: 983 Bytes

Contents

require_relative 'playing_card'
require_relative 'dealt_pile'
require_relative 'dealing_pile'
require_relative 'column_pile'
require_relative 'foundation_pile'

class KlondikeSolitaire
  module Model
    class Game
      COLUMN_PILE_COUNT = 7
        
      attr_reader :deck, :dealing_pile, :dealt_pile, :column_piles, :foundation_piles
      
      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
                  
      def restart!
        @deck = new_deck
        @dealt_pile.reset!
        @dealing_pile.reset!
        @column_piles.each(&:reset!)
        @foundation_piles.each(&:reset!)
      end
        
      private
      
      def new_deck
        PlayingCard.deck.shuffle
      end
    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
glimmer-dsl-swt-4.30.0.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.29.0.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.28.0.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.27.0.1 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.27.0.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.26.0.1 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.26.0.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.25.0.2 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.25.0.1 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.25.0.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.24.4.8 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.24.4.7 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.24.4.6 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.24.4.5 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.24.4.4 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.24.4.3 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.24.4.2 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.24.4.1 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.24.4.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.24.3.2 samples/elaborate/klondike_solitaire/model/game.rb