Sha256: bca458099d7960dc758ed3873bfd9b637949a4af9888485ef8a6b625cb37f619

Contents?: true

Size: 779 Bytes

Versions: 2

Compression:

Stored size: 779 Bytes

Contents

require "twenty_one/player"

module TwentyOne
	class Dealer < Player
		attr_reader :shoe

		def initialize(name, shoe)
			super name

			@shoe = shoe
		end

		def showdown(player)
			if player.hand.value == @hand.value && player.hand.value <= 21
				player.deal_bet :push	

				@pushes += 1

				return :push
			elsif @hand.value <= 21 && player.hand.value < @hand.value || player.hand.value > 21  
				@chips.push player.bet.chips

				player.deal_bet :bust

				@wins += 1

				return :bust
			else
				win_type = :win

				if player.hand.value == 21
					player.deal_bet :twenty_one
					win_type = :twenty_one
				else
					player.deal_bet :win
				end

				@busts += 1

				return win_type 
			end	
		end

		def hit(player)
			player.hand.cards.push shoe.pop
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twenty_one-0.1.1 lib/twenty_one/dealer.rb
twenty_one-0.1.0 lib/twenty_one/dealer.rb