Class: Detector

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/naga/detector.rb

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Detector

Returns a new instance of Detector.



2
3
4
5
# File 'lib/minitest/naga/detector.rb', line 2

def initialize(credentials)
  @credentials = credentials
  @locked_achievements = Achievement.locked_achievements(@credentials)
end

Instance Method Details

#a_trip_to_the_whizz_palace(total_time) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/minitest/naga/detector.rb', line 26

def a_trip_to_the_whizz_palace(total_time)
  achievement = @locked_achievements["A trip to the whizz palace"]
  if achievement
    if 300 <= total_time && total_time <= 600
      achievement.unlock(@credentials)
    end
  end
end

#bluebeard(item) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/minitest/naga/detector.rb', line 35

def bluebeard(item)
  achievement = @locked_achievements["Bluebeard"]
  if achievement
    if item.level == 3
      achievement.unlock(@credentials)
    end
  end
end

#cant_catch_em_all(count, failures) ⇒ Object



71
72
73
74
75
76
77
78
79
# File 'lib/minitest/naga/detector.rb', line 71

def cant_catch_em_all(count, failures)
  achievement = @locked_achievements["Can't Catch 'Em All"]
  if achievement
    quarter = (count * 0.25).to_i
    if (count >= 50) && (failures <= quarter)
      achievement.unlock(@credentials)
    end
  end
end

#dressed_like_a_bat(count) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/minitest/naga/detector.rb', line 14

def dressed_like_a_bat(count)
  achievement = @locked_achievements["Dressed like a bat"]
  if achievement
    now = Time.now
    start_time = Time.new(now.year, now.month, now.day, 22, 0, 0)
    end_time = Time.new(now.year, now.month, now.day+1, 3, 59, 0)
    if count == 237 && ((start_time..end_time).cover? Time.now)
      achievement.unlock(@credentials)
    end
  end
end

#i_am_legendary(item) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/minitest/naga/detector.rb', line 53

def i_am_legendary(item)
  achievement = @locked_achievements["I am Legendary"]
  if achievement
    if item.level == 5
      achievement.unlock(@credentials)
    end
  end
end

#my_first_timeObject



7
8
9
10
11
12
# File 'lib/minitest/naga/detector.rb', line 7

def my_first_time
  achievement = @locked_achievements["My First Time"]
  if achievement
    achievement.unlock(@credentials)
  end
end

#papyrus(count, failures, errors) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/minitest/naga/detector.rb', line 62

def papyrus(count, failures, errors)
  achievement = @locked_achievements["Papyrus"]
  if achievement
    if (count == 2009) && (failures == 0) && (errors == 0)
      achievement.unlock(@credentials)
    end
  end
end

#purple_rain(item) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/minitest/naga/detector.rb', line 44

def purple_rain(item)
  achievement = @locked_achievements["Purple Rain"]
  if achievement
    if item.level == 4
      achievement.unlock(@credentials)
    end
  end
end

#why_do_we_fall(count, failures) ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/minitest/naga/detector.rb', line 81

def why_do_we_fall(count, failures)
  achievement = @locked_achievements["Why do we fall? So we can learn to pick ourselves up."]
  if achievement
    if (count >= 2) && (failures == count)
      achievement.unlock(@credentials)
    end
  end
end