require_relative "card.rb" $deck = Deck.new(jokers: true).cards.shuffle! class Hand # Creates an object that holds and can play cards. Interacts with Deck objects. @@deck = Deck.new.cards.shuffle! attr_accessor :cards # @return [Array] def initialize @cards = Array.new(3) {$deck.shift} end =begin @param card [CardDeck::Card] the card played @return [void] @note Gameplay method =end def play(card) raise "Card not found" unless @cards.include? card if card.num == "King" $value = 99 elsif card.num == "Joker" $value = 0 else $value += card.value end i, done = 0, false for index in @cards if index.num == card.num and not done discard = @cards[i] @cards.delete_at i @cards.push $deck.shift $deck.push discard done = true end i += 1 end card end =begin @return [void] Displays cards =end def view_cards print "These are your cards: " @cards.each {|card| print "\t#{card}"} end alias inspect cards end