Sha256: b23f0bad69b3fc9588371d5eb99fe3efff2086f445e6ff5cac8c2fbf0035ea21

Contents?: true

Size: 744 Bytes

Versions: 2

Compression:

Stored size: 744 Bytes

Contents

class GlimmerKlondikeSolitaire
  module Model
    class DealingPile
      DEALING_INITIAL_COUNT = 24
      
      def initialize(game)
        @game = game
        reset!
      end
      
      def reset!
        playing_cards.clear
        DEALING_INITIAL_COUNT.times { playing_cards << @game.deck.pop }
      end

      def deal!
        playing_card = playing_cards.shift
        if playing_card.nil?
          @game.dealt_pile.playing_cards.each do |a_playing_card|
            playing_cards << a_playing_card
          end
          @game.dealt_pile.playing_cards.clear
        else
          @game.dealt_pile.push!(playing_card)
        end
    end
      
      def playing_cards
        @playing_cards ||= []
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
glimmer_klondike_solitaire-1.1.0 app/glimmer_klondike_solitaire/model/dealing_pile.rb
glimmer_klondike_solitaire-1.0.1 app/glimmer_klondike_solitaire/model/dealing_pile.rb