Skip to content

Commit c975392

Browse files
changed log to record of attempts so that i can later use the letter 'L' for another game feature
1 parent d3ff823 commit c975392

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

bin/gemwarrior

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ end
9797

9898
begin
9999
GameOptions.add 'log_file_path', "#{Dir.home}/.gemwarrior_log"
100+
GameOptions.add 'save_file_path', "#{Dir.home}/.gemwarrior_save"
100101
GameOptions.add 'options_file_path', "#{Dir.home}/.gemwarrior_options"
101102

102103
options = parse_options_cli

lib/gemwarrior/repl.rb

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,25 @@ def print_options
161161
end
162162
end
163163

164-
def display_log
165-
if File.exist?(GameOptions.data['log_file_path'])
164+
def display_record_of_attempts
165+
if File.exist?(GameOptions.data['log_file_path']) and !File.zero?(GameOptions.data['log_file_path'])
166166
File.open(GameOptions.data['log_file_path']).readlines.each do |line|
167167
print "#{line}"
168168
end
169-
puts
169+
if GameOptions.data['debug_mode']
170+
print 'Clear record of attempts (y/n)? '
171+
answer = gets.chomp.downcase
172+
173+
case answer
174+
when 'y'
175+
File.truncate(GameOptions.data['log_file_path'], 0)
176+
puts 'Record of attempts: erased!'
177+
end
178+
179+
puts
180+
end
170181
else
171182
puts 'No attempts made yet!'
172-
puts
173183
end
174184
end
175185

@@ -197,7 +207,7 @@ def print_main_menu
197207
puts ' (A)bout'
198208
puts ' (H)elp'
199209
puts ' (O)ptions'
200-
puts ' (L)og'
210+
puts ' (R)ecord of Attempts'
201211
puts ' (C)heck for Updates'
202212
puts ' (E)xit'
203213
puts '======================='
@@ -233,9 +243,9 @@ def run_main_menu(show_choices = true)
233243
puts choice
234244
print_options
235245
run_main_menu
236-
when 'l'
246+
when 'r'
237247
puts choice
238-
display_log
248+
display_record_of_attempts
239249
run_main_menu
240250
when 'c'
241251
puts choice
@@ -323,5 +333,11 @@ def prompt
323333
print (prompt_template % prompt_vars_arr).colorize(:yellow)
324334
print "\n"
325335
end
336+
337+
def command_exists?(cmd)
338+
ENV['PATH'].split(File::PATH_SEPARATOR).collect { |d|
339+
Dir.entries d if Dir.exist? d
340+
}.flatten.include?(cmd)
341+
end
326342
end
327343
end

lib/gemwarrior/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# Version of Gem Warrior
33

44
module Gemwarrior
5-
VERSION = '0.9.36'
5+
VERSION = '0.9.37'
66
end

0 commit comments

Comments
 (0)