Module:Sandbox/GauTest/Township: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 926: Line 926:
function p.GetWorshipTable()
function p.GetWorshipTable()
local function GetCheckpointCell(checkpoint)
local function GetCheckpointCell(checkpoint)
return '\r\n|-\r\n!'..Icons.Icon({'Worship', type='township', notext=true})..'<br>'..checkpoint..'%<br>'..(checkpoint*Township.maxWorship/100)..'/'..Township.maxWorship
return '\r\n|-\r\n!'..checkpoint..'%<br>'..(checkpoint*Township.maxWorship/100)..'/'..Township.maxWorship
end
end
Line 932: Line 932:
table.insert(ret, '\r\n{| class="wikitable" style="text-align:left"')
table.insert(ret, '\r\n{| class="wikitable" style="text-align:left"')
table.insert(ret, '\r\n!Checkpoint')
table.insert(ret, '\r\n!'..Icons.Icon({'Worship', type='township'}))
-- Names
-- Names
for _, worship in ipairs(Township.worships) do
for _, worship in ipairs(Township.worships) do
if worship.isHidden == false then
if worship.isHidden == false then
table.insert(ret, '\r\n!'..Icons.Icon({worship.name, type='monster'}))
table.insert(ret, '\r\n!'..Icons.Icon({'Statue of '..worship.name, type='building', notext=true})..Icons.Icon({worship.name, type='monster'}))
end
end
end
end
Line 964: Line 964:
for _, checkpoint in ipairs(worship.checkpoints) do
for _, checkpoint in ipairs(worship.checkpoints) do
for modifier, magnitude in pairs(checkpoint) do
for modifier, magnitude in pairs(checkpoint) do
if modifiers[modifier] == nil then
local swappedModifier = string.sub(modifier, 1, string.len('increased')) == 'increased' and string.gsub(modifier, 'increased', 'decreased') or string.gsub(modifier, 'decreased', 'increased')
-- The modifier already exists, so we add the two modifiers together
if modifiers[modifier] ~= nil then
modifiers[modifier] = modifiers[modifier] + magnitude
-- The inverse modifier already exists, so we subtract the negative value of the new modifier
elseif modifiers[swappedModifier] ~= nil then
modifiers[swappedModifier] = modifiers[swappedModifier] - magnitude
-- The modifier does not exist, so create the modifier
else
modifiers[modifier] = magnitude
modifiers[modifier] = magnitude
else
modifiers[modifier] = modifiers[modifier] + magnitude
end
end
end
end
572

edits