Module:Girls

-- The following pages are related: https://fapceo.wikia.com/wiki/Module:Girls https://fapceo.wikia.com/wiki/Module:Girls/data local p = {} local girls = mw.loadData('Module:Girls/data')

function compareLess(x, y)   return x[1] < y[1] end function compareMore(x, y)   return x[1] > y[1] end function tableSort(table1,table2,more) for i,v in ipairs(table1) do       table1[i] = {table1[i], table2[i]} end if more == 'less' then table.sort(table1, compareLess) else table.sort(table1, compareMore) end for i, v in ipairs(table1) do       table1[i] = v[1] table2[i] = v[2] end return table2 end

function check(stat) if stat == nil then return " Please insert data to Module:Girls/data." elseif stat == "" then return "Unknown" end return stat end

function link_the_stat(stat,typ,only) if stat == nil then stat = "Add data here" elseif only == true then if typ == "f" then if string.match(stat, "small") then stat = 'data-sort-value="1" |small' end if string.match(stat, "medium") then stat = 'data-sort-value="2" |medium' end if string.match(stat, "large") then stat = 'data-sort-value="3" |large' end elseif typ == "b" then if string.match(stat, "small") then stat = 'data-sort-value="1" |small' end if string.match(stat, "medium") then stat = 'data-sort-value="2" |medium' end if string.match(stat, "large") then stat = 'data-sort-value="3" |large' end elseif typ == "h" then if string.match(stat, "small") then stat = 'data-sort-value="1" |small' end if string.match(stat, "medium") then stat = 'data-sort-value="2" |medium' end if string.match(stat, "large") then stat = 'data-sort-value="3" |large' end end else if typ == "f" then stat = stat:gsub("small", "small") stat = stat:gsub("medium", "medium") stat = stat:gsub("large", "large") elseif typ == "b" then stat = stat:gsub("small", "small") stat = stat:gsub("medium", "medium") stat = stat:gsub("large", "large") elseif typ == "h" then stat = stat:gsub("small", "small") stat = stat:gsub("medium", "medium") stat = stat:gsub("large", "large") end end return stat end

function p.infobox(frame) local name = mw.title.getCurrentTitle.text local char_data = girls[name] if char_data == nil then return " Please insert data to Module:Girls/data." end local data = {} local infobox = { image = name..'_icon.jpg', feet = check(link_the_stat(char_data.feet,"f")), breast = check(link_the_stat(char_data.breast,"b")), height = check(link_the_stat(char_data.height,"h")), occupation = check(char_data.occupation), likes = check(char_data.likes), dislikes = check(char_data.dislikes) }   table.insert(data, frame:expandTemplate { title = 'Girl info', args = infobox }) table.insert(data, ""..check(char_data.desc)) table.insert(data, frame:expandTemplate { title = 'Clear'}) return table.concat(data, '\n') end

function p.description(frame) local name = mw.title.getCurrentTitle.text local char_data = girls[name] if char_data == nil then return " Please insert data to Module:Girls/data." end local data = {} table.insert(data, ""..check(char_data.desc)) return table.concat(data, '\n') end

function outfit_naming(outfit, name) if string.match(outfit, "other") then return outfit:gsub("?!other", "") elseif string.match(outfit, name) then return outfit else return name.." "..outfit end end

function outfit_picture(outfit, name) if string.match(outfit, "other") then return outfit:gsub("?!other", "") elseif string.match(outfit, name) then return outfit else return name.." "..outfit end end

function p.outfits(frame) local name = mw.title.getCurrentTitle.text local char_data=girls[name] if char_data == nil then return " Please insert data to Module:Girls/data." end local data = { '{| class="wikitable sortable" style="float:right; margin-left:auto; margin-right:0px; text-align: center; width: 800px;"', '|+Outfits', '|-',       '! class="unsortable" | Hired', '! class="unsortable" | Picture', '! Outfit name', '! data-sort-type="number"| Cost', '|-'       }    for i,j in pairs(char_data.outfit) do        table.insert(data, '| ")        table.insert(data, '| ") table.insert(data, '| '..outfit_naming(i,name)) if j == "Starting Outfit" then cost = ' data-sort-value="0" |'..j else cost = j end table.insert(data, '| '..cost) table.insert(data, '|-') end table.insert(data, '|}') for i,j in pairs(data) do mw.log(j) end return table.concat(data, '\n') end

function p.table(frame) local data = { '==Girls List==', '{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',       '! Name', '! class="unsortable" | Picture', '! data-sort-type="number" | Feet', '! data-sort-type="number" | Breast Size', '! data-sort-type="number" | Height', '! class="sortable" | Unlocks At ', '! class="sortable" | Release Date ', '|-'   }    for a, s in pairs(girls) do        table.insert(data, '| '..a..'') table.insert(data, '| ') table.insert(data, '|'..check(link_the_stat(s.feet,"f",true))) table.insert(data, '|'..check(link_the_stat(s.breast,"b",true))) table.insert(data, '|'..check(link_the_stat(s.height,"h",true)))

local u = {} for i, unlock in ipairs(s.unlock) do           if unlock.other ~= nil then -- Enter data as is. u[#u+1] = unlock.other elseif unlock.event ~= nil and unlock.name ~= nil then -- Enter link to event with different display name. u[#u+1] = ..unlock.name.. elseif unlock.event ~= nil then -- Enter link to event with default name. u[#u+1] = ..unlock.event.. else u[#u+1] = 'Wrong Event_Type in Module:Girls/data' end end table.insert(data, '|'..table.concat(u, " "))

if type(check(s.release)) == "number" then e=s.release elseif check(s.release)==" Please insert data to Module:Girls/data." then e=s.release else e=..s.release.. end table.insert(data, '|'..e)       table.insert(data, '|-') end table.insert(data, '|}') for i, d in pairs(data) do mw.log(d) end return table.concat(data, "\n") end

function link_named_stat(stat, type) if stat == nil then return "Add data here" end

if type == "f" then if string.match(stat, "small") then return ..stat.. end if string.match(stat, "medium") then return ..stat.. end if string.match(stat, "large") then return ..stat.. end elseif type == "b" then if string.match(stat, "small") then return ..stat.. end if string.match(stat, "medium") then return ..stat.. end if string.match(stat, "large") then return ..stat.. end elseif type == "h" then if string.match(stat, "small") then return ..stat.. end if string.match(stat, "medium") then return ..stat.. end if string.match(stat, "large") then return ..stat.. end end return stat end

function p.basic_info(frame) local name = mw.title.getCurrentTitle.text local char_data=girls[name] if char_data == nil then return " Please insert data to Module:Girls/data." end local data = { '{| class="wikitable" style="float:left; width: 300px;"', '|-',       }    table.insert(data, '| scope="col" colspan="2" | ') table.insert(data, '|-') table.insert(data, '| Feet || '..link_named_stat(char_data.feet, "f")) table.insert(data, '|-') table.insert(data, '| Breast || '..link_named_stat(char_data.breast, "b")) table.insert(data, '|-') table.insert(data, '| Height || '..link_named_stat(char_data.height, "h")) table.insert(data, '|-') table.insert(data, '| Occupation || '..check(char_data.occupation)) table.insert(data, '|-') table.insert(data, '| Likes || '..check(char_data.likes)) table.insert(data, '|-') table.insert(data, '| Dislikes || '..check(char_data.dislikes)) table.insert(data, '|-') local u = {} for i, unlock in ipairs(char_data.unlock) do       if unlock.other ~= nil then -- Enter data as is. u[#u+1] = unlock.other elseif unlock.event ~= nil and unlock.name ~= nil then -- Enter link to event with different display name. u[#u+1] = ..unlock.name.. elseif unlock.event ~= nil then -- Enter link to event with default name. u[#u+1] = ..unlock.event.. else u[#u+1] = 'Wrong Event_Type in Module:Girls/data' end end table.insert(data, '| Unlocked || '..table.concat(u, " ")) table.insert(data, '|}') return table.concat(data, '\n') end

return p