Class: Achievement

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/game/achievements.rb

Overview

Keeps track of users achievements

Instance Method Summary collapse

Constructor Details

#initializeAchievement

Returns a new instance of Achievement.



9
10
11
12
13
14
15
# 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

Instance Method Details

#employee_otmObject



26
27
28
29
30
31
32
33
34
35
36
# 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) ⇒ Object



21
22
23
24
# File 'lib/utils/game/achievements.rb', line 21

def increment_chieve(chieve)
  puts 'šŸ† Achievement Unlocked! šŸŽŠ'
  @store.transaction { @store['achievements'][chieve] += 1 }
end

#listObject



17
18
19
# File 'lib/utils/game/achievements.rb', line 17

def list
  @chieve_list
end