Module:OccupationWorldJSONToWikiText

local p = {}

--[===[ Paste in console: =p.convert({args={[==[ A.json ]==], [==[ B.json ]==], [==[ C.json ]==], }})

]===]

local getWikitext= function(area) local wikitext = "" if (area.is_base == true) then if (area.army == 0) then wikitext = "Red army's HQ" elseif (area.army == 1) then wikitext = "Blue army's HQ" elseif (area.army == 2) then wikitext = "Green army's HQ" end end for _,effect in ipairs(area.area_bonuses) do		if (area.is_base and effect ~= nil) then wikitext = wikitext .. " "		end if (effect ~= nil) then wikitext = wikitext .. " ";		end end if (area.adjacent_area_bonus ~= nil) then wikitext = wikitext .. "";	end return mw.text.trim(wikitext); end

p.convert = function(frame) local b1 = mw.text.jsonDecode(frame.args[1] or "[]") local b2 = mw.text.jsonDecode(frame.args[2] or "[]") local b3 = mw.text.jsonDecode(frame.args[3] or "[]") local data = {}; -- data[area number] = [map id, battle 1 effect wikitext, battle 2 effect wikitext, battle 3 effect wikitext]; for _,area in ipairs(b1.areas) do		data[area.area_no] = {area.map_id, getWikitext(area)}; end for _,area in ipairs(b2.areas) do		data[area.area_no][3] = getWikitext(area); end for _,area in ipairs(b3.areas) do		data[area.area_no][4] = getWikitext(area); end local outputWikitext = [========[{| class="wikitable sortable" style="text-align:center;" !rowspan="2"|Area !rowspan="2"|Map !colspan="3"|Area effect !Battle 1 !Battle 2 !Battle 3 ]========]	for areaNum,info in ipairs(data) do outputWikitext = outputWikitext .. ([========[ ]========]):format(areaNum,info[1],info[2],info[3],info[4]); end return outputWikitext.."|}"; end
 * %s
 * %s
 * %s
 * %s
 * %s
 * %s

return p