#!/usr/bin/env ruby

livesfile = ENV['HOME'] + "/.lives-left"

lives = 8

begin
    File.open(livesfile, "r") do |file|
	lives = file.gets.to_i
    end
rescue
end

if lives < 1
    message = [ "YOU FAIL IT!", 
		"Your skill is not enough!", 
		"See you next time, bye bye!"]

    message.each do |s|
	puts s.center(80)
    end
else
    puts "Segmentation Fault; #{lives} lives left."

    lives -= 1

    File.open(livesfile, "w") do |file|
	file.puts(lives)
    end
end

