-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.rb
56 lines (45 loc) · 845 Bytes
/
user.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require_relative 'hand'
require_relative 'bank'
require_relative 'rules'
class User
include Rules
attr_accessor :name, :bank
def initialize(name = '')
@hand = Hand.new
@bank = Bank.new(START_MONEY)
@name = name
end
def clear_round
@hand.cards.clear
@hand.points = 0
end
def cards?
@hand.cards.empty?
end
def cards
@hand.cards
end
def take_card(deck)
@hand.take_card(deck)
end
def points
@hand.points
end
def money
@bank.money
end
def money?
@bank.money?
end
# Кошелек юзера достаем из него деньги
def bet
@bank.make_bets(@player, @dealer)
end
def withdraw(money)
@bank.money -= money
end
# Кладем деньги в кошеле юзера
def get_money(money)
@bank.get_money(money)
end
end