Talk:Player Rank

From Granblue Fantasy Wiki
Jump to: navigation, search

Rank Table Update Script[edit]

#!/usr/bin/env ruby

# Add new data here
next_rp_for_rank = {
    1 => 50, 2 => 150, 3 => 300, 4 => 400,
    5 => 600, 6 => 700, 7 => 700, 8 => 900, 9 => 1100,
    10 => 1600, 11 => 1500, 12 => 1600, 13 => 1900, 14 => 2000,
    15 => 2100, 16 => 2200, 17 => 2300, 18 => 2850, 19 => 3550,
    20 => 3950, 21 => 4000, 22 => 4450, 23 => 4950, 24 => 5500,
    25 => 6100, 26 => 6750, 27 => 7450, 28 => 8200, 29 => 9000,
    30 => 9850, 31 => 10750, 32 => 11700, 33 => 12700, 34 => 13750,
    35 => 14850, 36 => 16000, 37 => 17200, 38 => 18450, 39 => 19750,
    40 => 21100, 41 => 22500, 42 => 23950, 43 => 25450, 44 => 27000,
    45 => 28600, 46 => 30250, 47 => 31950, 48 => 33700, 49 => 35500,
    50 => 37350, 51 => 39250, 52 => 41200, 53 => 43200, 54 => 45250,
    55 => 47350, 56 => 49500, 57 => 51700, 58 => 53950, 59 => 56250,
    60 => 58600, 61 => 61000, 62 => 63450, 63 => 65950, 64 => 68500,
    65 => 71100, 66 => 73750,
}

# Assuming ordered Ruby 1.9 hashes here
rp_sum = 0
total_rp_for_rank = [0, 0] + next_rp_for_rank.values.map { |rp|
    rp_sum += rp
    rp_sum
}

def separate_thousands(n)
    n.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
end

puts DATA.read.gsub(%r{^\|([0-9]+)\|\|[^|]*\|\|[^|]*\|\|}) { |s|
    rank = Regexp.last_match[1].to_i
    rp = next_rp_for_rank[rank]
    total_rp = if rank == 1 then '-' else total_rp_for_rank[rank] end
    if rp.nil?
        s
    else
        "|#{rank}||#{separate_thousands(rp)}||#{separate_thousands(total_rp)}||"
    end
}

# Paste the current wiki table after the __END__ line.
__END__
|-
|1||50||-||10||20
...
|-
|175|| || || ||