Module:Mermaid: Difference between revisions
From Portals of Phereon Wiki
Content added Content deleted
m (Undo) Tag: Undo |
mNo edit summary |
||
Line 6: | Line 6: | ||
local temp_res = {}; |
local temp_res = {}; |
||
local temp_res2 = {}; |
local temp_res2 = {}; |
||
local results = cargo.query("spirit_evolution","name,element,image,fxskills,sizebonus,reqstr,reqhealth, |
local results = cargo.query("spirit_evolution","name,element,image,fxskills,sizebonus,reqstr,reqhealth,reqtrait,reqmlvl,evinto",{ |
||
where = 'element="' .. frame.args[1] .. '"'; |
where = 'element="' .. frame.args[1] .. '"'; |
||
}); |
}); |
||
Line 16: | Line 16: | ||
if (result["reqhealth"] ~= nil) then |
if (result["reqhealth"] ~= nil) then |
||
header_req[#header_req+1] = tostring(mw.html.create('span'):css('color','#00AD00'):wikitext("Health genes " .. result["reqhealth"])); |
header_req[#header_req+1] = tostring(mw.html.create('span'):css('color','#00AD00'):wikitext("Health genes " .. result["reqhealth"])); |
||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
if (result["reqmlvl"] ~= nil) then |
if (result["reqmlvl"] ~= nil) then |
||
header_req[#header_req+1] = tostring(mw.html.create('span'):css('color','#CC9900'):wikitext("Max Level genes " .. result["reqmlvl"])); |
header_req[#header_req+1] = tostring(mw.html.create('span'):css('color','#CC9900'):wikitext("Max Level genes " .. result["reqmlvl"])); |
||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
local header_text = ''; |
local header_text = ''; |
||
Line 45: | Line 45: | ||
fix_size[#fix_size+1] = ' Size'; |
fix_size[#fix_size+1] = ' Size'; |
||
end |
end |
||
local evolutions = cargo.query("spirit_evolution_part","evosource |
local evolutions = cargo.query("spirit_evolution_part","evosource,evosize,evoelement,evotype,evoskills",{ |
||
where = 'name="' .. result["name"] .. '"'; |
where = 'name="' .. result["name"] .. '"'; |
||
}); |
}); |
||
Line 55: | Line 55: | ||
if evolution["evosource"] == nil then |
if evolution["evosource"] == nil then |
||
evo_res[#evo_res+1] = '<br>'; |
evo_res[#evo_res+1] = '<br>'; |
||
evo_res[#evo_res+1] = evolution["evotype"]; |
|||
evo_res[#evo_res+1] = tostring(mw.html.create('span'):addClass('simple-tooltip simple-tooltip-inline tooltipstered') |
|||
:attr('data-simple-tooltip',tostring(mw.html.create('span'):wikitext('Type: ' .. evolution["evotype"]))):wikitext(evolution["evoname"])); |
|||
else |
|||
evo_res[#evo_res+1] = evolution["evoname"]; |
|||
end |
|||
evo_res[#evo_res+1] = ": "; |
evo_res[#evo_res+1] = ": "; |
||
if (evolution["evoskills"] ~= nil) then |
if (evolution["evoskills"] ~= nil) then |
||
Line 73: | Line 68: | ||
evo_res[#evo_res+1] = " size"; |
evo_res[#evo_res+1] = " size"; |
||
evo_res[#evo_res+1] = ", "; |
evo_res[#evo_res+1] = ", "; |
||
end |
|||
if (evolution["evohealth"] ~= nil) then |
|||
evo_res[#evo_res+1] = evolution["evohealth"]; |
|||
evo_res[#evo_res+1] = " health"; |
|||
evo_res[#evo_res+1] = ", "; |
|||
end |
|||
if (evolution["evomana"] ~= nil) then |
|||
evo_res[#evo_res+1] = evolution["evomana"]; |
|||
evo_res[#evo_res+1] = " mana"; |
|||
evo_res[#evo_res+1] = ", "; |
|||
end |
|||
if (evolution["evostr"] ~= nil) then |
|||
evo_res[#evo_res+1] = evolution["evostr"]; |
|||
evo_res[#evo_res+1] = " strength"; |
|||
evo_res[#evo_res+1] = ", "; |
|||
end |
|||
if (evolution["evomagic"] ~= nil) then |
|||
evo_res[#evo_res+1] = evolution["evomagic"]; |
|||
evo_res[#evo_res+1] = " magic"; |
|||
evo_res[#evo_res+1] = ", "; |
|||
end |
|||
if (evolution["evoldmg"] ~= nil) then |
|||
evo_res[#evo_res+1] = evolution["evoldmg"]; |
|||
evo_res[#evo_res+1] = " lust dmg"; |
|||
evo_res[#evo_res+1] = ", "; |
|||
end |
|||
if (evolution["evolres"] ~= nil) then |
|||
evo_res[#evo_res+1] = evolution["evolres"]; |
|||
evo_res[#evo_res+1] = " lust res"; |
|||
evo_res[#evo_res+1] = ", "; |
|||
end |
|||
if (evolution["evoarmor"] ~= nil) then |
|||
evo_res[#evo_res+1] = evolution["evoarmor"]; |
|||
evo_res[#evo_res+1] = " armor"; |
|||
evo_res[#evo_res+1] = ", "; |
|||
end |
|||
if (evolution["evospeed"] ~= nil) then |
|||
evo_res[#evo_res+1] = evolution["evospeed"]; |
|||
evo_res[#evo_res+1] = " speed"; |
|||
evo_res[#evo_res+1] = ", "; |
|||
end |
|||
if (evolution["evopassive"] ~= nil) then |
|||
local evo_passives_parsed = utils.toNumberedTable(evolution["evopassive"],'/'); |
|||
for _, evo_passive in ipairs(evo_passives_parsed) do |
|||
evo_res[#evo_res+1] = evo_passive; |
|||
evo_res[#evo_res+1] = ", "; |
|||
end |
|||
end |
end |
||
evo_res[#evo_res] = nil; |
evo_res[#evo_res] = nil; |
Revision as of 00:03, 10 January 2022
Documentation for this module may be created at Module:Mermaid/doc
local p = {};
local cargo = mw.ext.cargo;
local utils = require( "Module:Utils" );
function p.spirits(frame)
local temp_res = {};
local temp_res2 = {};
local results = cargo.query("spirit_evolution","name,element,image,fxskills,sizebonus,reqstr,reqhealth,reqtrait,reqmlvl,evinto",{
where = 'element="' .. frame.args[1] .. '"';
});
for _, result in ipairs(results) do
local header_req = {};
if (result["reqstr"] ~= nil) then
header_req[#header_req+1] = tostring(mw.html.create('span'):css('color','#cc0000'):wikitext("Str genes " .. result["reqstr"]));
end
if (result["reqhealth"] ~= nil) then
header_req[#header_req+1] = tostring(mw.html.create('span'):css('color','#00AD00'):wikitext("Health genes " .. result["reqhealth"]));
end
if (result["reqmlvl"] ~= nil) then
header_req[#header_req+1] = tostring(mw.html.create('span'):css('color','#CC9900'):wikitext("Max Level genes " .. result["reqmlvl"]));
end
if (result["reqtrait"] ~= nil) then
header_req[#header_req+1] = tostring(mw.html.create('span'):css('color','#B800B8'):wikitext("Trait " .. result["reqlust"]));
end
local header_text = '';
if #header_req > 0 then
header_text = result["name"] .. ' Req. ' .. table.concat(header_req," ");
else
header_text = result["name"];
end
local fix_skills = {};
if (result["fxskills"] ~= nil) then
local fix_skills_parsed = utils.toNumberedTable(result["fxskills"],'/');
for _, skill in ipairs(fix_skills_parsed) do
fix_skills[#fix_skills+1] = '+ ';
fix_skills[#fix_skills+1] = skill;
fix_skills[#fix_skills+1] = '<br>';
end
fix_skills[#fix_skills] = nil;
end
local fix_size = {};
if (result["sizebonus"] ~= nil) then
fix_size[#fix_size+1] = '+ ';
fix_size[#fix_size+1] = result["sizebonus"];
fix_size[#fix_size+1] = ' Size';
end
local evolutions = cargo.query("spirit_evolution_part","evosource,evosize,evoelement,evotype,evoskills",{
where = 'name="' .. result["name"] .. '"';
});
local evo_res = {};
local evo_table = {};
evo_table["n"] = 0;
for _, evolution in ipairs(evolutions) do
if evolution["evoelement"] == nil or evolution["evoelement"] == result["element"] then
if evolution["evosource"] == nil then
evo_res[#evo_res+1] = '<br>';
evo_res[#evo_res+1] = evolution["evotype"];
evo_res[#evo_res+1] = ": ";
if (evolution["evoskills"] ~= nil) then
local evo_skills_parsed = utils.toNumberedTable(evolution["evoskills"],'/');
for _, evo_skill in ipairs(evo_skills_parsed) do
evo_res[#evo_res+1] = evo_skill;
evo_res[#evo_res+1] = ", ";
end
end
if (evolution["evosize"] ~= nil) then
evo_res[#evo_res+1] = evolution["evosize"];
evo_res[#evo_res+1] = " size";
evo_res[#evo_res+1] = ", ";
end
evo_res[#evo_res] = nil;
else
if evo_table[evolution["evosource"]] == nil then
evo_table[evolution["evosource"]] = {};
evo_table[evolution["evosource"]]["name"] = evolution["evosource"];
evo_table[evolution["evosource"]]["text"] = {};
evo_table["n"] = evo_table["n"] + 1;
end
local current_row = evo_table[evolution["evosource"]]["text"];
if (string.gsub(string.gsub(evolution["evoname"], "%s%(.*", ""),"%s%d+","") ~= evolution["evotype"]) then
current_row[#current_row+1] = tostring(mw.html.create('span'):addClass('simple-tooltip simple-tooltip-inline tooltipstered')
:attr('data-simple-tooltip',tostring(mw.html.create('span'):wikitext('Type: ' .. evolution["evotype"]))):wikitext(evolution["evoname"]));
else
current_row[#current_row+1] = evolution["evoname"];
end
current_row[#current_row+1] = ": ";
if (evolution["evoskills"] ~= nil) then
local evo_skills_parsed = utils.toNumberedTable(evolution["evoskills"],'/');
for _, evo_skill in ipairs(evo_skills_parsed) do
current_row[#current_row+1] = evo_skill;
current_row[#current_row+1] = ", ";
end
end
if (evolution["evosize"] ~= nil) then
current_row[#current_row+1] = evolution["evosize"];
current_row[#current_row+1] = " size";
current_row[#current_row+1] = ", ";
end
if (evolution["evohealth"] ~= nil) then
current_row[#current_row+1] = evolution["evohealth"];
current_row[#current_row+1] = " health";
current_row[#current_row+1] = ", ";
end
if (evolution["evomana"] ~= nil) then
current_row[#current_row+1] = evolution["evomana"];
current_row[#current_row+1] = " mana";
current_row[#current_row+1] = ", ";
end
if (evolution["evostr"] ~= nil) then
current_row[#current_row+1] = evolution["evostr"];
current_row[#current_row+1] = " strength";
current_row[#current_row+1] = ", ";
end
if (evolution["evomagic"] ~= nil) then
current_row[#current_row+1] = evolution["evomagic"];
current_row[#current_row+1] = " magic";
current_row[#current_row+1] = ", ";
end
if (evolution["evoldmg"] ~= nil) then
current_row[#current_row+1] = evolution["evoldmg"];
current_row[#current_row+1] = " lust dmg";
current_row[#current_row+1] = ", ";
end
if (evolution["evolres"] ~= nil) then
current_row[#current_row+1] = evolution["evolres"];
current_row[#current_row+1] = " lust res";
current_row[#current_row+1] = ", ";
end
if (evolution["evoarmor"] ~= nil) then
current_row[#current_row+1] = evolution["evoarmor"];
current_row[#current_row+1] = " armor";
current_row[#current_row+1] = ", ";
end
if (evolution["evospeed"] ~= nil) then
current_row[#current_row+1] = evolution["evospeed"];
current_row[#current_row+1] = " speed";
current_row[#current_row+1] = ", ";
end
if (evolution["evopassive"] ~= nil) then
local evo_passives_parsed = utils.toNumberedTable(evolution["evopassive"],'/');
for _, evo_passive in ipairs(evo_passives_parsed) do
current_row[#current_row+1] = evo_passive;
current_row[#current_row+1] = ", ";
end
end
current_row[#current_row] = nil;
current_row[#current_row+1] = '<br>';
end
end
end
if #fix_size > 0 and #fix_skills > 0 then
fix_size[#fix_size+1] = "<br>";
end
if #fix_size == 0 and #fix_skills == 0 and #evo_res > 0 then
evo_res[1] = "";
end
local html_table = mw.html.create('table'):addClass('label-table')
:tag('thead')
:tag('tr')
:tag('th'):attr('colspan', '3')
:tag('div'):addClass('label-header'):wikitext(header_text):done():done():done():done()
:tag('tbody')
:tag('tr')
:tag('td'):attr('rowspan', '0')
:tag('img'):addClass('label-image')
:attr('src', frame:callParserFunction{ name = 'filepath', args = result["image"],'72x72px' }):done():done()
:tag('td'):attr('colspan', '2'):css('border','none'):done():done();
local misc_text = table.concat(fix_size,"") .. table.concat(fix_skills,"") .. table.concat(evo_res,"");
if #misc_text > 0 then
html_table = html_table:tag('tr')
:tag('td'):attr('colspan', '2')
:tag('span'):addClass('label-text'):wikitext(misc_text):done():done():done();
end;
if evo_table["n"] > 0 then
evo_table["n"] = nil;
for _, evo_type in pairs(evo_table) do
evo_type["text"][#evo_type["text"]] = nil;
local name = string.gsub(evo_type["name"], '/', '<br>');
html_table = html_table:tag('tr')
:tag('td'):tag('span'):addClass('label-text'):wikitext(name):done():done()
:tag('td'):tag('span'):addClass('label-text'):wikitext(table.concat(evo_type["text"],"")):done():done():done();
end
end;
local squashed_name = string.gsub(result["name"], '%s+', '');
temp_res[#temp_res+1] = squashed_name;
temp_res[#temp_res+1] = '[['
temp_res[#temp_res+1] = tostring(html_table:allDone());
temp_res[#temp_res+1] = ']]\n';
if (result["evinto"] ~= nil) then
temp_res[#temp_res+1] = squashed_name;
temp_res[#temp_res+1] = ' --> ';
temp_res[#temp_res+1] = string.gsub(string.gsub(result["evinto"], '%s+', ''), '/', ' & ');
temp_res[#temp_res+1] = '\n';
end
temp_res2[#temp_res2+1] = 'click '
temp_res2[#temp_res2+1] = squashed_name;
temp_res2[#temp_res2+1] = ' "/wiki/';
temp_res2[#temp_res2+1] = result["name"];
temp_res2[#temp_res2+1] = '" "';
temp_res2[#temp_res2+1] = squashed_name;
temp_res2[#temp_res2+1] = '"\n';
end
local restbl = table.concat(temp_res,"");
local result = string.gsub( string.gsub(string.gsub(restbl,'"',"'"), '%[%[', '%["'), '%]%]', '"%]') .. table.concat(temp_res2,"");
return result;
end
function p.skillTree(frame)
local imgSize = frame.args[4];
local imgSizeParsed = {};
for match in (imgSize..'x'):gmatch("(.-)x") do
imgSizeParsed[#imgSizeParsed+1] = match;
end
local nodeSize = 'width:'..imgSizeParsed[1]..'px;height:'..imgSizeParsed[2]..'px';
local connection_w = math.floor(tonumber(imgSizeParsed[1])/2);
local connection_h = math.floor(tonumber(imgSizeParsed[2])/2.5);
local data = mw.title.makeTitle("",frame.args[3].."/load"):getContent();
if (data == nil) then return ""; end
data = string.gsub(string.gsub(data,'{{Documentation}}',''),'\\\"','"');
local stat,decoded = pcall(mw.text.jsonDecode,data);
if (stat == false) then return ""; end
local tf_type = {
[0] = '',
[1] = '[[File:Icon StatIncrease.png|' .. imgSize .. 'px|link=]]',
[2] = '',
[3] = '[[File:Icon GeneIncrease.png|' .. imgSize .. 'px|link=]]',
[4] = '[[File:Icon Skill.png|' .. imgSize .. 'px|link=]]',
[5] = '[[File:Icon Passive.png|' .. imgSize .. 'px|link=]]',
[6] = '[[File:Icon Form.png|' .. imgSize .. 'px|link=]]',
[7] = '[[File:Icon Buff Part.png|' .. imgSize .. 'px|link=]]',
[8] = '[[File:Icon_Special.png|' .. imgSize .. 'px|link=]]',
[9] = '[[File:Icon Core.png|' .. imgSize .. 'px|link=]]',
};
local tf_species = {
[3] = 'Harpy',
[6] = 'Mermaid',
[8] = 'Centaur',
[10] = 'Lymean',
[11] = 'Succubus',
[12] = 'PlantGirl',
[18] = 'LavaGirl',
[31] = 'LizardGirl',
[46] = 'InsectGirl',
[78] = 'BeastGirl',
[105] = 'Shadow',
[174] = 'Tanid'
};
local unknw = function(tab, index) return 'Unknown' end;
setmetatable(tf_type,{__index = unknw});
setmetatable(tf_species,{__index = unknw});
local tf_node = '[[File:Node.png|' .. imgSize .. 'px|link=]]';
local tf_connection_parent_h = 'width:' .. connection_w-14 .. 'px;height:' .. connection_h-14 .. 'px';
local tf_connection_parent_v = 'height:' .. connection_h-7 .. 'px;margin-top:-1px;text-align:center';
local tf_connection_img_h = 'width:' .. connection_w .. 'px;height:' .. connection_h .. 'px;' .. 'margin-left:-7px';
local tf_connection_img_v = 'width:' .. connection_w .. 'px;height:' .. connection_h .. 'px;';
local tf_connection = '[[File:Connection empty.png|' .. connection_w .. 'x' .. connection_h .. 'px|link=]]';
local tf_connection_a = '[[File:Connection full.png|' .. connection_w .. 'x' .. connection_h .. 'px|link=]]';
local tf_count = '[[File:EmptyBall.png|10x10px|link=]]';
local html_table = mw.html.create('table'):addClass('label-table');
local html_rows = {
[0] = mw.html.create('tr'):addClass('label-row'):tag('td'):done(),
[1] = mw.html.create('tr'):addClass('label-row'):tag('td'):done(),
[2] = mw.html.create('tr'):addClass('label-row'):tag('td'):done(),
[3] = mw.html.create('tr'):addClass('label-row'):tag('td'):done(),
[4] = mw.html.create('tr'):addClass('label-row'):tag('td')
:tag('div'):cssText(tf_connection_parent_h)
:tag('div'):cssText(tf_connection_img_h):addClass('label-connection-h-a'):wikitext(tf_connection_a):done():done():done(),
[5] = mw.html.create('tr'):addClass('label-row'):tag('td'):done(),
[6] = mw.html.create('tr'):addClass('label-row'):tag('td'):done(),
[7] = mw.html.create('tr'):addClass('label-row'):tag('td'):done(),
[8] = mw.html.create('tr'):addClass('label-row'):tag('td'):done(),
}
local header_width = 'width:' .. imgSizeParsed[1] .. 'px';
for i, result in ipairs(decoded[frame.args[2]]) do
local current_row = ((i-1) - (math.floor((i-1)/5))*5)*2;
local image = tf_type[result["type"]];
local name = string.gsub(result["name"],'%f[^%l](%u)','<wbr>%1');
local html_node = mw.html.create('td'):tag('div'):addClass('label-node'):cssText(nodeSize)
:tag('span'):addClass('label-header'):wikitext(name):cssText(header_width):done()
:tag('span'):addClass('label-image'):wikitext(image):done()
:tag('span'):addClass('label-image-background'):wikitext(tf_node):done()
:tag('span'):addClass('label-primary label-primary-'..frame.args[2]):wikitext(result["costPrimary"]):done();
for i = 1, result["count"] do
html_node = html_node
:tag('span'):addClass('label-count-' .. i):wikitext(tf_count):done();
end
if (result["costSecondary"] ~= nil and result["speciesSecondary"] ~= nil) then
html_node = html_node
:tag('span'):addClass('label-secondary label-secondary-'.. tf_species[result["speciesSecondary"]]):wikitext(result["costSecondary"]):done();
end
html_rows[current_row] = html_rows[current_row]:node(html_node:allDone());
if (result["connectionRight"] == true) then
html_rows[current_row] = html_rows[current_row]:tag('td')
:tag('div'):cssText(tf_connection_parent_h)
:tag('div'):cssText(tf_connection_img_h):addClass('label-connection-h'):wikitext(tf_connection):done():done():done();
else
html_rows[current_row] = html_rows[current_row]:tag('td'):done();
end
if (result["connectionBottom"] == true) then
html_rows[current_row+1] = html_rows[current_row+1]:tag('td')
:tag('div'):cssText(tf_connection_parent_v)
:tag('span'):cssText(tf_connection_img_v):addClass('label-connection-v'):wikitext(tf_connection):done():done():done()
:tag('td'):done();
else
if (current_row ~= 8) then
html_rows[current_row+1] = html_rows[current_row+1]:tag('td')
:tag('div'):cssText(tf_connection_parent_v)
:tag('div'):cssText(tf_connection_img_v):addClass('label-connection-v'):done():done():done()
:tag('td'):done();
end
end
end
html_table = html_table:node(html_rows[0])
:node(html_rows[1])
:node(html_rows[2])
:node(html_rows[3])
:node(html_rows[4])
:node(html_rows[5])
:node(html_rows[6])
:node(html_rows[7])
:node(html_rows[8]):allDone();
local result = tostring(html_table);
return result;
end
return p