Module:TAMNAMS: Difference between revisions
Added hardness range lookup for a range with arbitrary endpoints |
Added back code for handling cases where endpoints of a range exceed a smaller range but fit within a larger range |
||
| Line 451: | Line 451: | ||
lower_ratio = p.step_ratio_floor(step_ratio_1) | lower_ratio = p.step_ratio_floor(step_ratio_1) | ||
upper_ratio = p.step_ratio_ceil (step_ratio_2) | upper_ratio = p.step_ratio_ceil (step_ratio_2) | ||
else | else | ||
lower_ratio = p.step_ratio_floor(step_ratio_2) | lower_ratio = p.step_ratio_floor(step_ratio_2) | ||
upper_ratio = p.step_ratio_ceil (step_ratio_1) | upper_ratio = p.step_ratio_ceil (step_ratio_1) | ||
end | end | ||
-- If one ratio corresponds to the endpoint of a named hardness range | |||
-- but the other ratio exceeds that of a smaller range, default to the | |||
-- largest range that would accommodate it. | |||
-- 2:1 to (L:s > 3:1) = hard-of-basic | |||
-- 4:1 and up = ultrahard | |||
-- (L:s < 3:2) to 2:1 = soft-of-basic | |||
-- 4:3 and lower = ultrasoft | |||
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 | |||
upper_ratio = {1,0} | |||
elseif (upper_ratio[1]/upper_ratio[2] == 2/1 and lower_ratio[1]/lower_ratio[2] < 3/1) | |||
or upper_ratio[1]/upper_ratio[2] == 4/3 then | |||
lower_ratio = {1,1} | |||
end | |||
local named_ratio_range = p.lookup_step_ratio_range(lower_ratio, upper_ratio, use_extended) | |||
return named_ratio_range | return named_ratio_range | ||
end | end | ||
| Line 990: | Line 1,004: | ||
function p.tester() | function p.tester() | ||
return p.find_step_ratio_range_for_ratio_pair({13,8},{ | return p.find_step_ratio_range_for_ratio_pair({13,8},{3,2}) | ||
end | end | ||
return p | return p | ||