You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.7KB

  1. #!/usr/bin/env ruby
  2. require 'colorize'
  3. type = ARGV.first || '**'
  4. times = Hash.new { |h, k| h[k] = [] }
  5. Dir["html/#{type}/*_kill.html"].each do |f|
  6. f = File.basename f
  7. f = f.split '_'
  8. name = f[1]
  9. time = f[2].delete_suffix('s').to_i
  10. times[name] << time
  11. end
  12. def humanize(secs)
  13. [[60, :s], [60, :m], [24, :h], [1000, :d]].inject([]){ |s, (count, name)|
  14. if secs > 0
  15. secs, n = secs.divmod(count)
  16. s.unshift "#{n.to_i}#{name}"
  17. end
  18. s
  19. }.join(' ')
  20. end
  21. wings = {
  22. '98cm' => %w[mama siax ensol],
  23. '99cm' => %w[skorv arts arkk],
  24. '100cm' => %w[ai drkai],
  25. 'W1 - Spirit Vale' => %w[vg gors sab],
  26. 'W2 - Salvation Pass' => %w[sloth trio matt],
  27. 'W3 - Stronghold of the Faithful' => %w[kc twstcstl xera],
  28. 'W4 - Bastion of the Penitent' => %w[cairn mo sam dei]
  29. }
  30. def display_time(min, mean, max, size: 4)
  31. min = humanize(min).rjust(size, ' ')
  32. mean = humanize(mean).rjust(size, ' ')
  33. max = humanize(max).rjust(size, ' ')
  34. "min=#{min.colorize :green}\tmean=#{mean.colorize :yellow}\tmax=#{max.colorize :red}"
  35. end
  36. length = times.keys.collect(&:size).max
  37. wings.each do |wing, bosses|
  38. sum_min, sum_mean, sum_max = [0, 0, 0]
  39. content = []
  40. bosses.each do |boss|
  41. time = times[boss]
  42. next if time.empty?
  43. mean = (time.sum.to_f / time.count).round
  44. boss = "#{boss.ljust(length, ' ').colorize :blue}"
  45. min, max = time.minmax
  46. sum_min += min
  47. sum_mean += mean
  48. sum_max += max
  49. content << "\t#{boss}\t#{display_time min, mean, max}"
  50. end
  51. next if content.empty?
  52. puts wing
  53. puts "\t\t\t#{display_time sum_min, sum_mean, sum_max}"
  54. content.each { |c| puts c }
  55. end