Sha256: 23cc7a9505aaa1950e0479fb3b0b8029c67b3797ab2d0a557352d52a5bb1a59d
Contents?: true
Size: 617 Bytes
Versions: 4
Compression:
Stored size: 617 Bytes
Contents
module Codebreaker module Score def score @player.score += 250 if win? @player.score += @hint * 100 + @attempts * 50 puts "#{player.name}, your score: #{@player.score}!" end def save_score? puts 'Do you want to save your score in score file?(y/n)' save_score_file if @player.agree? exit end private def save_score_file path = File.expand_path("../../score/#{@player.name}_score.txt", __FILE__) File.open(path, 'a') {|file| file.puts "#{@player.score} - #{Time.now.asctime}" } puts "You score saved in file: #{path}" end end end
Version data entries
4 entries across 4 versions & 1 rubygems