mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
29 lines
397 B
Ruby
29 lines
397 B
Ruby
require_relative "./card_kind.rb"
|
|
|
|
module Model
|
|
class Pack
|
|
def initialize
|
|
@cards = []
|
|
reshuffle
|
|
end
|
|
|
|
def reshuffle_if_necessary
|
|
return if @cards.count > 2
|
|
reshuffle
|
|
end
|
|
|
|
def draw
|
|
reshuffle_if_necessary
|
|
@cards.pop
|
|
end
|
|
|
|
private
|
|
|
|
def reshuffle
|
|
puts "RESHUFFLING"
|
|
@cards = 4.times.map {|_| CardKind::KINDS_SET}.flatten
|
|
@cards.shuffle!
|
|
end
|
|
end
|
|
end
|