-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.rb
More file actions
68 lines (57 loc) · 1.16 KB
/
interface.rb
File metadata and controls
68 lines (57 loc) · 1.16 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
# frozen_string_literal: true
module Interface
def ask_user_name
puts 'Enter your name:'
gets.chomp
end
def ask_to_make_choice
puts %(
Сhoose one of the options:
1. Skip
2. Take a card
3. Open cards
)
gets.chomp.to_i
end
def show_winner(player)
puts ''
puts '********** Result **********'
puts player.nil? ? 'Draw' : "Winner: #{player.name}"
puts '****************************'
puts ''
end
def play_new_game
puts %(
Want to start a new game?
1. Yes
2. No
)
gets.chomp.to_i
end
def enough_cards_msg
show_msg('You cannot take one more card')
end
def wrong_option_msg
show_msg('You have chosen the wrong option. Choose the right option from the list')
end
def new_game_msg
show_msg('New game started')
end
def skip_msg(player)
show_msg("#{player.name} skip his turn")
end
def money_limit(player)
show_msg("#{player.name} don't have money")
end
def cards_border
puts ''
puts "===== #{name} cards ====="
puts ''
yield if block_given?
puts ''
end
def show_msg(msg)
puts ''
puts msg.to_s
end
end