Module:ONGEKI Difficulty: Difference between revisions

remove reliance on hard-coded numbers
imported>Jack980517
No edit summary
imported>Jack980517
(remove reliance on hard-coded numbers)
Line 1: Line 1:
-- オンゲキ difficulty rated from 1 to 14+.
local p={}
local p={}
local function VerToNum(args)
local function VerToNum(args)
Line 7: Line 6:
function p.ongeki_difficulty_multi(frame)
function p.ongeki_difficulty_multi(frame)
     args=frame:getParent().args
     args=frame:getParent().args
    local version_range_borders = {6}
     local result = "オンゲキ "
     local result = "オンゲキ "
     if VerToNum({"ongeki", args[1]}) <= 5 then
     if VerToNum({"ongeki", args[1]}) < version_range_borders[1] then
         result = result .. "to R.E.D. difficulty rated from 1 to 14+, "
         result = result .. "to R.E.D. difficulty rated from 1 to 14+, "
     else
     else
Line 14: Line 14:
     end
     end
     -- since #args can't be used, and there's no removals in R.E.D. and older anyway (except ikazuchi nazo which doesn't use this template), i'm removing the period, and moving the comma to the above branch
     -- since #args can't be used, and there's no removals in R.E.D. and older anyway (except ikazuchi nazo which doesn't use this template), i'm removing the period, and moving the comma to the above branch
    local version_range_borders = {6} -- first range already dealt with above
     -- although there's only two ranges, the loops below shall remain to be future-proof
     -- although there's only two ranges, the loops below shall remain to be future-proof
     local i = 0
     local i = 0
Line 49: Line 48:
         end
         end
     end
     end
     if #included_ranges == 1 and VerToNum({"ongeki", args[1]}) <= 5 then -- first range special case
     if #included_ranges == 1 and VerToNum({"ongeki", args[1]}) < version_range_borders[1] then -- first range special case
         result = result .. "and " .. ranges_text[included_ranges[1]] .. "."
         result = result .. "and " .. ranges_text[included_ranges[1]] .. "."
         -- print(result)
         -- print(result)
Anonymous user