Class: CodebreakerVk::GameMessages

Inherits:
Object
  • Object
show all
Defined in:
lib/codebreaker_vk/game_messages.rb

Class Method Summary collapse

Class Method Details

.empty_db_msgObject



54
55
56
# File 'lib/codebreaker_vk/game_messages.rb', line 54

def empty_db_msg
  puts I18n.t('console.empty_db')
end

.error_msg(error) ⇒ Object



70
71
72
# File 'lib/codebreaker_vk/game_messages.rb', line 70

def error_msg(error)
  puts I18n.t('error', error: error)
end

.goodbyeObject



10
11
12
# File 'lib/codebreaker_vk/game_messages.rb', line 10

def goodbye
  puts I18n.t(:goodbye)
end

.greeting_msgObject



6
7
8
# File 'lib/codebreaker_vk/game_messages.rb', line 6

def greeting_msg
  puts I18n.t('console.greeting')
end

.lose_msgObject



50
51
52
# File 'lib/codebreaker_vk/game_messages.rb', line 50

def lose_msg
  puts I18n.t('console.lose')
end

.make_guess_msgObject



27
28
29
# File 'lib/codebreaker_vk/game_messages.rb', line 27

def make_guess_msg
  puts I18n.t('console.make_guess')
end

.round_info_text(result, attempts, hints) ⇒ Object



39
40
41
42
43
44
# File 'lib/codebreaker_vk/game_messages.rb', line 39

def round_info_text(result, attempts, hints)
  puts I18n.t('console.result', result: result)
  puts I18n.t('console.left_attempts_and_hints', attempts: attempts, hints: hints)
  puts I18n.t('console.make_guess')
  puts I18n.t('console.enter_hint') if hints.positive?
end

.select_difficulty_msgObject



23
24
25
# File 'lib/codebreaker_vk/game_messages.rb', line 23

def select_difficulty_msg
  puts I18n.t('console.select_difficulty', difficulties: Difficulty::DIFFICULTIES.keys.join(', '))
end

.show_db(loaded_db) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/codebreaker_vk/game_messages.rb', line 58

def show_db(loaded_db)
  sort_db(loaded_db).each_with_index do |user, index|
    puts I18n.t('console.stats_user_info', position: index + 1, name: user[:name], level: user[:level])
    puts I18n.t('console.stats_lefts', attempts: user[:left_attempts], all_attempts: user[:all_attempts],
                hints: user[:left_hints], all_hints: user[:all_hints])
  end
end

.show_rulesObject



66
67
68
# File 'lib/codebreaker_vk/game_messages.rb', line 66

def show_rules
  puts I18n.t('console.rules')
end

.showed_hint_msg(showed) ⇒ Object



31
32
33
# File 'lib/codebreaker_vk/game_messages.rb', line 31

def showed_hint_msg(showed)
  puts I18n.t('console.showed_hint', showed: showed)
end

.sort_db(loaded_db) ⇒ Object



74
75
76
# File 'lib/codebreaker_vk/game_messages.rb', line 74

def sort_db(loaded_db)
  loaded_db.sort_by { |user| [user[:all_attempts], -user[:left_attempts], -user[:left_hints]] }
end

.what_name_msgObject



19
20
21
# File 'lib/codebreaker_vk/game_messages.rb', line 19

def what_name_msg
  puts I18n.t('console.what_name')
end

.what_next_textObject



14
15
16
17
# File 'lib/codebreaker_vk/game_messages.rb', line 14

def what_next_text
  puts I18n.t('console.choose_the_command', stats: Console::COMMANDS[:stats], rules: Console::COMMANDS[:rules],
              start: Console::COMMANDS[:start], exit: Console::COMMANDS[:exit])
end

.win_msgObject



46
47
48
# File 'lib/codebreaker_vk/game_messages.rb', line 46

def win_msg
  puts I18n.t('console.win', yes: Console::ACCEPT_SAVING_RESULT)
end

.zero_hints_msgObject



35
36
37
# File 'lib/codebreaker_vk/game_messages.rb', line 35

def zero_hints_msg
  puts I18n.t('console.zero_hints')
end