Class: TwentyOne::Bet

Inherits:
Object
  • Object
show all
Defined in:
lib/twenty_one/bet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBet

Returns a new instance of Bet.



8
9
10
# File 'lib/twenty_one/bet.rb', line 8

def initialize()
	@chips = [] 
end

Instance Attribute Details

#chipsObject (readonly)

Returns the value of attribute chips.



6
7
8
# File 'lib/twenty_one/bet.rb', line 6

def chips
  @chips
end

Instance Method Details

#clearObject



40
41
42
# File 'lib/twenty_one/bet.rb', line 40

def clear
	@chips = []
end

#payout(type) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/twenty_one/bet.rb', line 20

def payout(type)
	res = []

	if type == :twenty_one
		payout_generator = Player.new "Temporary player"
		
		payout_generator.make_bet value * 2.5
		
		res.concat payout_generator.bet.chips
		payout_generator = nil
	elsif type == :push
		res.concat @chips
	else
		2.times do res.concat @chips end 
	end	

	@chips = []
	res
end

#present(chips) ⇒ Object



12
13
14
# File 'lib/twenty_one/bet.rb', line 12

def present(chips)
	@chips = chips
end

#valueObject



16
17
18
# File 'lib/twenty_one/bet.rb', line 16

def value
	Chip.get_amount(@chips)
end