-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.rb
More file actions
94 lines (75 loc) · 2.15 KB
/
interface.rb
File metadata and controls
94 lines (75 loc) · 2.15 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
module Interface
class << self
def enter_user_name
puts 'Введите имя игрока:'
gets.chomp
end
def show_start_message
puts
puts '**************НАЧАЛО ИГРЫ**************'
end
def show_end_message
puts
puts '**************КОНЕЦ ИГРЫ**************'
end
def puts_empty_string
puts
end
def show_description(object)
puts object.description
end
def show_result_draw
puts
puts 'РЕЗУЛЬТАТ ИГРЫ: НИЧЬЯ'
end
def show_result_player_wins(player_name)
puts
puts "РЕЗУЛЬТАТ ИГРЫ: ПОБЕДА ИГРОКА \'#{player_name}\'"
end
def ask_for_next_game
puts
puts 'Начать новую игру? (Y/N)'
gets.chomp.upcase
end
def show_action_skip_info(player_name)
puts "Игрок \'#{player_name}\' пропускает ход"
end
def show_action_add_card_info(player_name)
puts "Игрок \'#{player_name}\' берёт одну карту"
end
def show_action_show_cards_info(player_name)
puts "Игрок \'#{player_name}\' открывает карты"
end
def withdraw_message(player_name, value)
puts "Игрок \'#{player_name}\' кладёт в банк #{value}$"
end
def debit_message(player_name, value)
puts "Игрок \'#{player_name}\' забирает из банка #{value}$"
end
def choose_from_collection(elements)
return if elements.empty?
loop do
show_collection(elements)
index = gets.chomp.to_i - 1
return index if index >= 0 && !elements[index].nil?
end
end
def show_collection(elements)
puts
elements.each.with_index(1) do |element, index|
puts "#{index}-\"#{element}\""
end
end
def show_card_mask(count)
mask = Array.new(count, '|*|').join(', ')
puts mask
end
def show_cards(cards)
cards_description = cards.map(&:description).join(', ')
puts cards_description
end
def show_player_score(score)
puts "СЧЁТ: #{score}"
end
end
end