Module:Skills/Gathering: Difference between revisions

buildAstrologyValueTable: Add cumulative chance column
(Added p.buildAstrologyValueTable)
(buildAstrologyValueTable: Add cumulative chance column)
Line 754: Line 754:
function p.buildAstrologyValueTable()
function p.buildAstrologyValueTable()
local result = '{|class="wikitable sortable"'
local result = '{|class="wikitable sortable"'
result = result..'\r\n!Value!!Chance'
result = result..'\r\n!rowspan="2"| Value!!colspan="2"| Chance'
result = result..'\r\n|-\r\n! This Value!! This Value or Greater'
local lastChance = 0
local lastChance = 0
local cumulativeChance = 100
for i, chance in Shared.skpairs(SkillData.Astrology.Defaults.valueWeight) do
for i, chance in Shared.skpairs(SkillData.Astrology.Defaults.valueWeight) do
local thisChance = (i == 5 and chance) or chance - lastChance
result = result..'\r\n|-'
result = result..'\r\n|-'
result = result..'\r\n|'..i
result = result..'\r\n|style="text-align:right"| '..i
if i == 5 then
result = result..'\r\n|style="text-align:right"| ' .. thisChance .. '%'
result = result..'||'..chance..'%'
result = result..'\r\n|style="text-align:right"| ' .. cumulativeChance .. '%'
else
cumulativeChance = cumulativeChance - thisChance
result = result..'||'..(chance - lastChance)..'%'
end
lastChance = chance
lastChance = chance
end
end