Module:TAMNAMS: Difference between revisions

Ganaram inukshuk (talk | contribs)
Added back code for handling cases where endpoints of a range exceed a smaller range but fit within a larger range
Ganaram inukshuk (talk | contribs)
m Bugfix with hyposoft lookup
Line 439: Line 439:
-- ratios passed in.
-- ratios passed in.
function p.find_step_ratio_range_for_ratio_pair(step_ratio_1, step_ratio_2, use_extended)
function p.find_step_ratio_range_for_ratio_pair(step_ratio_1, step_ratio_2, use_extended)
local use_extended = use_extended == true
local use_extended = use_extended == true -- Does nothing for now
-- Swap ratios so they're in the right order
-- Swap ratios so they're in the right order
local hardness_1 = step_ratio_1[1] / step_ratio_1[2]
local hardness_1 = step_ratio_1[1] / step_ratio_1[2]
local hardness_2 = step_ratio_2[1] / step_ratio_2[2]
local hardness_2 = step_ratio_2[1] / step_ratio_2[2]
local lower_ratio = nil
local lower_ratio = nil
local upper_ratio = nil
local upper_ratio = nil
Line 463: Line 462:
-- (L:s < 3:2) to 2:1 = soft-of-basic
-- (L:s < 3:2) to 2:1 = soft-of-basic
-- 4:3 and lower = ultrasoft
-- 4:3 and lower = ultrasoft
if (lower_ratio[1]/lower_ratio[2] == 2/1 and upper_ratio[1]/upper_ratio[2] > 3/1)  
if (lower_ratio[1]/lower_ratio[2] == 2/1 and upper_ratio[1]/upper_ratio[2] > 3/1) or lower_ratio[1]/lower_ratio[2] == 4/1 then
or lower_ratio[1]/lower_ratio[2] == 4/1 then
upper_ratio = {1,0}
upper_ratio = {1,0}
elseif (upper_ratio[1]/upper_ratio[2] == 2/1 and lower_ratio[1]/lower_ratio[2] < 3/1)
elseif (upper_ratio[1]/upper_ratio[2] == 2/1 and lower_ratio[1]/lower_ratio[2] < 3/2) or upper_ratio[1]/upper_ratio[2] == 4/3 then
or upper_ratio[1]/upper_ratio[2] == 4/3 then
lower_ratio = {1,1}
lower_ratio = {1,1}
end
end
Line 1,004: Line 1,001:


function p.tester()
function p.tester()
return p.find_step_ratio_range_for_ratio_pair({13,8},{3,2})
return ""
.. p.find_step_ratio_range_for_ratio_pair({1,1},{2,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({1,1},{3,2}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({1,1},{4,3}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({4,3},{3,2}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({3,2},{2,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({3,2},{5,3}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({5,3},{2,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({2,1},{5,2}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({5,2},{3,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({2,1},{3,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({3,1},{4,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({4,1},{1,0}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({3,1},{1,0}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({2,1},{1,0}) .. "\n"
end
end


return p
return p