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', height = check(link_the_stat(char_data.height,"h")), breast = check(link_the_stat(char_data.breast,"b")), feet = check(link_the_stat(char_data.feet,"f")), age = check(char_data.age), 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 p.table(frame) local data = { '==Girls List==', '{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',       '! Name', '! class="unsortable" | Picture', '! data-sort-type="number" | Height', '! data-sort-type="number" | Breast Size', '! data-sort-type="number" | Feet', '! class="sortable" | Unlocks At ', '! class="sortable" | Release Date ', '|-'   }

for _, name in ipairs(sorted(girls)) do       local girl_data = girls[name] table.insert(data, '| '..name ..'') table.insert(data, '| ') table.insert(data, '|'..check(link_the_stat(girl_data.height,"h",true))) table.insert(data, '|'..check(link_the_stat(girl_data.breast,"b",true))) table.insert(data, '|'..check(link_the_stat(girl_data.feet,"f",true)))

local u = {} for i, unlock in ipairs(girl_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, '|'..table.concat(u, " "))

if type(check(girl_data.release)) == "number" then e=girl_data.release elseif check(girl_data.release)==" Please insert data to Module:Girls/data." then e=girl_data.release else e=..girl_data.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, '| Height || '..link_named_stat(char_data.height, "h")) table.insert(data, '|-') table.insert(data, '| Breast || '..link_named_stat(char_data.breast, "b")) table.insert(data, '|-') table.insert(data, '| Feet || '..link_named_stat(char_data.feet, "f")) 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

function bold(str) return ""..str.."" end

-- Create data for each cell. function outfit_name_cell(outfit) return bold(outfit.name) end

function outfit_name_cell_link(outfit, name) if string.match(outfit.name, name) then return bold(outfit.name:gsub(name, ""..name.."")) end for _, alt_name in ipairs(girls[name].alt_names) do   if string.match(outfit.name, alt_name) then return bold(outfit.name:gsub(alt_name, ""..alt_name.."")) end end end

function outfit_picture_cell(outfit, size) return "" end

function outfit_hired_cell(outfit, size) return "" end

function add_ruby_symbol(str) if string.match(str, "Rubies") then str = str:gsub("Rubies", "Rubies ") end return str end

-- Event in BOLD font. function add_event(event, name) if name ~= nil then return ""..name.."" end return ""..event.."" end

-- Add thumbnail in newline function add_thumbnail(thumbnail, size, link) return " " end

-- function add_outfit_unlock(unlock, thumbnail) local data = {} -- Add cost and 'from' part if necessary. if unlock.cost ~= nil then table.insert(data, add_ruby_symbol(unlock.cost)) if unlock.event ~= nil or unlock.other ~= nil then table.insert(data, "from") end end -- Add event link if unlock.event ~= nil then table.insert(data, add_event(unlock.event, unlock.name)) -- Add new line for other as note/comment in new line. end -- Add other as comment or ending for alone 'cost' variable. if unlock.other ~= nil then table.insert(data, unlock.other) end if thumbnail ~= nil and unlock.thumbnail then local size = "300px" if unlock.event == "Tournament" or unlock.event == "Tutorial" then size = "100px" end table.insert(data, add_thumbnail(unlock.thumbnail, size, unlock.event)) end return table.concat(data, " "); end

-- thumbnails, if not nil - thumbnails of events will be added. function outfit_unlock_cell(outfit, thumbnails) local cell = {} for _, unlock in ipairs(outfit.unlock) do   table.insert(cell, add_outfit_unlock(unlock, thumbnails)) end return table.concat(cell, " ") end

function cell_style(styles) local style = {} -- Include width with cell. if styles.width ~= nil then table.insert(style, "width: "..styles.width..";") end if styles.color_top ~= nil then table.insert(style, "border-top:solid 3px "..styles.color_top..";") end

if styles.color ~= nil then table.insert(style, "background-color: "..styles.color..";") end

return "style=\""..table.concat(style, " ").."\" | " end

function count_elems(arr) local count = 0 for _, elem in pairs(arr) do   count = count + 1 end return count end

function girl_outfits_table_single(girl_data) -- 5 outfits in a row can make table unreadable for lower resolutions. local outfits_max_length = 4 local outfits_num = count_elems(girl_data.outfits) -- Determine number of columns in Outfits table. if (outfits_num < outfits_max_length) then outfits_max_length = outfits_num end

-- Beginning of the table with all settings. local data = { '{| class="wikitable" style="float:right; margin-left:auto; margin-right:0px; text-align: center;"', '! colspan="'..(outfits_max_length + 1)..'" | Outfits', '|-',     }  local column = 0 local row = 1; -- Helper lists to not iterate through the same data all the time. local outfit_name_row = {'! scope="row" '..cell_style({ width = "100px" })..'Outfit name'} local unlock_row = {'! scope="row" | Unlock'} local picture_row = {'! scope="row" | Picture'} local hired_row = {'! scope="row" | Hired'} for _, outfit in ipairs(girl_data.outfits) do   local name_style = cell_style({width = "250px", color_top = "grey"}) if row == 1 then name_style = cell_style({width = "250px"}) end table.insert(outfit_name_row, "| "..name_style..outfit_name_cell(outfit)) table.insert(unlock_row, "| "..cell_style({width = "250px"})..outfit_unlock_cell(outfit)) table.insert(picture_row, "| "..outfit_picture_cell(outfit, "100px")) table.insert(hired_row, "| "..outfit_hired_cell(outfit, "250px")) column = column + 1 if column == outfits_max_length then column = 0 row = row + 1 -- Add End of the row. table.insert(outfit_name_row, "|-") table.insert(unlock_row, "|-") table.insert(picture_row, "|-") table.insert(hired_row, "|-") -- Add full rows to the table. table.insert(data, table.concat(outfit_name_row, "\n")) table.insert(data, table.concat(unlock_row, "\n")) table.insert(data, table.concat(picture_row, "\n")) table.insert(data, table.concat(hired_row, "\n")) -- Reset Rows to default value. outfit_name_row = {'! scope="row"'..cell_style({width = "100px", color_top = "grey"})..'Outfit name'} unlock_row = {'! scope="row" | Unlock'} picture_row = {'! scope="row" | Picture'} hired_row = {'! scope="row" | Hired'} end end -- Add last outfits. if column > 0 then -- Add End of the row. table.insert(outfit_name_row, "|-") table.insert(unlock_row, "|-") table.insert(picture_row, "|-") table.insert(hired_row, "|-")

-- Add full rows to the table. table.insert(data, table.concat(outfit_name_row, "\n")) table.insert(data, table.concat(unlock_row, "\n")) table.insert(data, table.concat(picture_row, "\n")) table.insert(data, table.concat(hired_row, "\n")) end table.insert(data, '|}') --for i,j in pairs(data) do mw.log(j) end return table.concat(data, '\n') 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

return girl_outfits_table_single(char_data) end

function girl_outfits_table_all(girl_data, name, outfits_columns) -- Beginning of the table with all settings. local data = {'! colspan="'..outfits_columns..'" '..cell_style({color = "#99EEFF"})..' '..name..' ', '|-',     }  local column = 0 -- Helper lists to not iterate through the same data all the time. local outfit_name_row = {} local picture_row = {} local unlock_row = {} local cell_width = (100 / outfits_columns).."%" for _, outfit in ipairs(girl_data.outfits) do   local name_style = cell_style({width = cell_width, color = "#E3E3E3"}) table.insert(outfit_name_row, "| "..name_style..outfit_name_cell_link(outfit, name)) --table.insert(picture_row, "| "..cell_style({width = cell_width})..   --                          " "..outfit_picture_cell(outfit, "150px")..    --                          " "..outfit_hired_cell(outfit, "300px")) table.insert(picture_row, "| "..cell_style({width = cell_width})..                             " "..outfit_hired_cell(outfit, "300px")) table.insert(unlock_row, "| "..cell_style({width = cell_width})..outfit_unlock_cell(outfit, true))

column = column + 1 if column == outfits_columns then column = 0 -- Add End of the row. table.insert(outfit_name_row, "|-") table.insert(picture_row, "|-") table.insert(unlock_row, "|-") -- Add full rows to the table. table.insert(data, table.concat(outfit_name_row, "\n")) table.insert(data, table.concat(picture_row, "\n")) table.insert(data, table.concat(unlock_row, "\n")) -- Reset Rows to default value. outfit_name_row = {} picture_row = {} unlock_row = {}

end end -- Add last outfits. if column > 0 then -- Add End of the row. table.insert(outfit_name_row, "|-") table.insert(picture_row, "|-") table.insert(unlock_row, "|-")

-- Add full rows to the table. table.insert(data, table.concat(outfit_name_row, "\n")) table.insert(data, table.concat(picture_row, "\n")) table.insert(data, table.concat(unlock_row, "\n")) end return table.concat(data, '\n') end

function sorted(girls_data) local list = {} for name, _ in pairs(girls_data) do   table.insert(list, name) end table.sort(list) return list end

function p.outfits_all(frame) local outfits_columns = 4 local data = { '{| class="wikitable" style="text-align: center; width: 99%"', '! colspan="'..outfits_columns..'" | Outfits ', '|-',     }  for _, name in ipairs(sorted(girls)) do    table.insert(data, girl_outfits_table_all(girls[name], name, outfits_columns)) end table.insert(data, "|}") return table.concat(data, "\n") end

return p