Sha256: daf4072db4da09557a815265e41a5e360ceeffb17c9cae1353e1858debf0feae

Contents?: true

Size: 983 Bytes

Versions: 84

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

84 entries across 84 versions & 1 rubygems

Version Path
glimmer-dsl-swt-4.23.0.1 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.23.0.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.2.6 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.2.5 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.2.4 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.2.3 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.2.2 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.2.1 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.2.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.1.2 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.1.1 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.1.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.22.0.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.20.16.0 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.21.2.5 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.21.2.4 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.21.2.3 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.21.2.2 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.21.2.1 samples/elaborate/klondike_solitaire/model/game.rb
glimmer-dsl-swt-4.21.2.0 samples/elaborate/klondike_solitaire/model/game.rb