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.
 
 
 
 
 

59 lines
1.7 KiB

#!/usr/bin/env ruby
require 'colorize'
type = ARGV.first || '**'
times = Hash.new { |h, k| h[k] = [] }
Dir["html/#{type}/*_kill.html"].each do |f|
f = File.basename f
f = f.split '_'
name = f[1]
time = f[2].delete_suffix('s').to_i
times[name] << time
end
def humanize(secs)
[[60, :s], [60, :m], [24, :h], [1000, :d]].inject([]){ |s, (count, name)|
if secs > 0
secs, n = secs.divmod(count)
s.unshift "#{n.to_i}#{name}"
end
s
}.join(' ')
end
wings = {
'98cm' => %w[mama siax ensol],
'99cm' => %w[skorv arts arkk],
'100cm' => %w[ai drkai],
'W1 - Spirit Vale' => %w[vg gors sab],
'W2 - Salvation Pass' => %w[sloth trio matt],
'W3 - Stronghold of the Faithful' => %w[kc twstcstl xera],
'W4 - Bastion of the Penitent' => %w[cairn mo sam dei]
}
def display_time(min, mean, max, size: 4)
min = humanize(min).rjust(size, ' ')
mean = humanize(mean).rjust(size, ' ')
max = humanize(max).rjust(size, ' ')
"min=#{min.colorize :green}\tmean=#{mean.colorize :yellow}\tmax=#{max.colorize :red}"
end
length = times.keys.collect(&:size).max
wings.each do |wing, bosses|
sum_min, sum_mean, sum_max = [0, 0, 0]
content = []
bosses.each do |boss|
time = times[boss]
next if time.empty?
mean = (time.sum.to_f / time.count).round
boss = "#{boss.ljust(length, ' ').colorize :blue}"
min, max = time.minmax
sum_min += min
sum_mean += mean
sum_max += max
content << "\t#{boss}\t#{display_time min, mean, max}"
end
next if content.empty?
puts wing
puts "\t\t\t#{display_time sum_min, sum_mean, sum_max}"
content.each { |c| puts c }
end