class Detector

Public Class Methods

new(credentials) click to toggle source
# File lib/minitest/naga/detector.rb, line 2
def initialize(credentials)
  @credentials = credentials
  @locked_achievements = Achievement.locked_achievements(@credentials)
end

Public Instance Methods

a_trip_to_the_whizz_palace(total_time) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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_time() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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