class Achievement

Keeps track of users achievements

Public Class Methods

new() click to toggle source
# File lib/utils/game/achievements.rb, line 9
def initialize
  @pastel = Pastel.new
  @store = DATA
  @user = @store.transaction { @store[:user] }
  @chieve_list = %w[employee_otm]
  @spinner = TTY::Spinner.new('[:spinner] :title', success_mark: @pastel.green('+'))
end

Public Instance Methods

employee_otm() click to toggle source
# File lib/utils/game/achievements.rb, line 26
def employee_otm
  if @user[/[K|k]ristian/]
    @spinner.auto_spin
    @spinner.update(title: 'Evaluating Performance')
    sleep 5
    @spinner.update(title: 'Calculated Value Added to Company:')
    @spinner.success(@pastel.green("\nšŸ‘ØšŸ»ā€šŸ’¼ Kristian has earned: Employee Of The Month\n"))
    increment_chieve('employee_otm')
    sleep 5
  end
end
increment_chieve(chieve) click to toggle source
# File lib/utils/game/achievements.rb, line 21
def increment_chieve(chieve)
  puts 'šŸ† Achievement Unlocked! šŸŽŠ'
  @store.transaction { @store['achievements'][chieve] += 1 }
end
list() click to toggle source
# File lib/utils/game/achievements.rb, line 17
def list
  @chieve_list
end