Report abuse


			
class Game_Option
#Contain configuration data
  def initialize main
    @file = File.new
    @filename = "data/configuration/preferences.conf"
    @game = check
  end
  def read
    @game = check
    @game['name'].to_s
  end
  def check
    unless File.exist?(@filename)
      create
    else
      @file.yaml_read(@filename)
    end
  end
  def create
    @data = { 'name' => 'User' }
    @file.yaml_write data , @filename
    check
  end
  def configuration 
# This is where user configure data like username
      loop {
        puts "Welcome to the preference menu. This is the list of options you can change. \n Username: Change your name.\n End: End configuration."
        option = gets.chomp.downcase
        case option
          when 'username'
            puts 'The default is ' + data['name'].to_s + ' Could you like to change that? y/n.'
            input = gets.chomp.downcase
            if input == 'n'
              break
            elsif input == 'y'
              puts"Since you want to change your name, please enter your desired name."
              data['name'] = gets.chomp
              puts"Now the name is...." + data['name']
            end
          when 'end'
            break
          puts "Try again"
        end
      }
    @file.yaml_write @data , @filename
  end
end