app/helpers/talents_helper.rb
# Adjust percentages if row doesn't isn't near 100.
# This can occur if a large number of players of
# a class/spec don't have talents selected (e.g. they
# were reset by Blizzard following major class revamp)
Adjust percentages if row doesn't isn't near 100.
This can occur if a large number of players of
a class/spec don't have talents selected
Adjust percentages if row doesn ' t isn ' t near 100 . This can occur if a large number of players of a class / spec don ' t have talents selected
def normalize hash
    (0..6).each do |tier|
      talent = -> row { hash["#{tier}-#{row}"] }
      total = talent.(0)[:percent] + talent.(1)[:percent] + talent.(2)[:percent]
      next if total == 0 
      if (total < 95) then
        mod = 100 / total
        (0..2).each { |row|
          per = (talent.(row)[:percent] * mod).round(1)
          talent.(row)[:percent] = per > 0.1 ? per : 0
        }
      end
    end
  end
def normalize hash ( 0 .. 6 ) . each do | tier | talent = -> row { hash [ "#{tier}-#{row}" ] } total = talent . ( 0 ) [ :percent ] + talent . ( 1 ) [ :percent ] + talent . ( 2 ) [ :percent ] next if total == 0 if ( total < 95 ) then mod = 100 / total ( 0 .. 2 ) . each { | row | per = ( talent . ( row ) [ :percent ] * mod ) . round ( 1 ) talent . ( row ) [ :percent ] = per > 0.1 ? per : 0 } end end end
Adjust percentages if row doesn't isn't near 100.
Adjust percentages if row doesn ' t isn ' t near 100 .
# don't normalize if NO talents selected (e.g. immediately after a talent refund)
hash
<not_specific>