(test) |
No edit summary |
||
Line 356: | Line 356: | ||
next_label = h.LinkToCategory(next_label, string.match(next_label, '/.+/(.+)') )..' →' |
next_label = h.LinkToCategory(next_label, string.match(next_label, '/.+/(.+)') )..' →' |
||
end |
end |
||
− | previous_label = tostring( mw.html.create('td'):css('width', '20%'):wikitext(previous_label) ) |
+ | previous_label = tostring( mw.html.create('td'):css('width', '20%'):css('text-align', 'left'):wikitext(previous_label) ) |
− | next_label = tostring( mw.html.create('td'):css('width', '20%'):wikitext(next_label) ) |
+ | next_label = tostring( mw.html.create('td'):css('width', '20%'):css('text-align', 'right'):wikitext(next_label) ) |
− | current_label = |
+ | current_label = tostring(mw.html.create('span'):css('font-size', '18px'):wikitext(j..' / 7')) |
+ | current_label = design.span(current_label..'<br>'..string.upper(list[i].values[j].tooltip)).bold |
||
current_label = tostring( mw.html.create('td'):css('width', '60%'):css('text-align', 'center'):wikitext(current_label) ) |
current_label = tostring( mw.html.create('td'):css('width', '60%'):css('text-align', 'center'):wikitext(current_label) ) |
||
current_label = tostring( mw.html.create('tr'):wikitext(previous_label..current_label..next_label) ) |
current_label = tostring( mw.html.create('tr'):wikitext(previous_label..current_label..next_label) ) |
||
current_label = tostring( mw.html.create('table'):css('width', '100%'):wikitext(current_label) ) |
current_label = tostring( mw.html.create('table'):css('width', '100%'):wikitext(current_label) ) |
||
− | current_label = tostring(mw.html.create('span'):css('font-size', '18px'):css('font-weight', 'bold'):wikitext(j..' / 7'))..'<br>'..current_label |
||
output = output..design.messagebox({current_label}) |
output = output..design.messagebox({current_label}) |
||
end |
end |
Revision as of 13:53, 26 February 2021
/* Marvel Heroes and Villains
Based on the website http://marvel.wikia.com/Main_Page with popularity data from http://observationdeck.io9.com/something-i-found-marvel-character-popularity-poll-cb-1568108064 and power grid data from http://marvel.wikia.com/Power_Grid#Power Collected by: https://www.khanacademy.org/profile/Mentrasto/ */
CREATE TABLE marvels (ID INTEGER PRIMARY KEY,
name TEXT, popularity INTEGER, alignment TEXT, gender TEXT, height_m NUMERIC, weight_kg NUMERIC, hometown TEXT, intelligence INTEGER, strength INTEGER, speed INTEGER, durability INTEGER, energy_Projection INTEGER, fighting_Skills INTEGER);
INSERT INTO marvels VALUES(1,Hermes, Good, 1.80, 235.50, Olympus, 4, 5, 7, 3, 1, 5);
Insert INTO marvels Value(2,Artemis,Good,1.75,190.70,Olympus, 3, 5, 3, 6, 5);
Insert INTO marvels Values(3,Apollo, Good, 1.83, 235.50, Olympus, 3, 5, 4, 3, 6, 3);
Insert INTO marvels Values(4,Aphrodite, Good, 1.68.30, 172.60, Olympus, 3, 4, 3, 3, 6, 1);
INSERT INTO marvels values(5,Persephone, Good, 1.75,185.70,' 'Olympus' ', 3, 4, 2, 3, 6, 1);
local p = {}
local h = require("Module:HF")
local design = require('Module:Design')
local standard = require('Module:StandardizedName')
local getArgs = require('Dev:Arguments').getArgs
--local labels = {'Intelligence', 'Strength', 'Speed', 'Durability', 'Energy Projection', 'Fighting Skills'}
local list = {
[1] = { label = 'Intelligence',
tooltip = 'Ability to think and process information',
values = {
{ tooltip = 'Slow or Impaired',
category = 'Power Grid/Intelligence/Slow or Impaired',
},
{ tooltip = 'Normal',
category = 'Power Grid/Intelligence/Normal',
},
{ tooltip = 'Learned',
category = 'Power Grid/Intelligence/Learned',
},
{ tooltip = 'Gifted',
category = 'Power Grid/Intelligence/Gifted',
},
{ tooltip = 'Genius',
category = 'Power Grid/Intelligence/Genius',
},
{ tooltip = 'Super-Genius',
category = 'Power Grid/Intelligence/Super-Genius',
},
{ tooltip = 'Omniscient',
category = 'Power Grid/Intelligence/Omniscient',
},
},
},
[2] = { label = 'Strength',
tooltip = 'Ability to lift weight',
values = {
{ tooltip = 'Weak: cannot lift own body weight',
category = 'Power Grid/Strength/Weak',
},
{ tooltip = 'Normal: able to lift own body weight',
category = 'Power Grid/Strength/Normal',
},
{ tooltip = 'Peak Human: able to lift twice own body weight',
category = 'Power Grid/Strength/Peak Human',
},
{ tooltip = 'Superhuman: 800 lbs-25 ton',
category = 'Power Grid/Strength/Superhuman (800 lbs-25 ton)',
},
{ tooltip = 'Superhuman: 25-75 ton',
category = 'Power Grid/Strength/Superhuman (25-75 ton)',
},
{ tooltip = 'Superhuman: 75-100 ton',
category = 'Power Grid/Strength/Superhuman (75-100 ton)',
},
{ tooltip = 'Incalculable: in excess of 100 tons',
category = 'Power Grid/Strength/Incalculable',
},
},
},
[3] = { label = 'Speed',
tooltip = 'Ability to move over land by running or flight',
values = {
{ tooltip = 'Below normal',
category = 'Power Grid/Speed/Below Normal',
},
{ tooltip = 'Normal',
category = 'Power Grid/Speed/Normal',
},
{ tooltip = 'Superhuman: up to 700 MPH',
category = 'Power Grid/Speed/Superhuman',
},
{ tooltip = 'Speed of sound: Mach-1',
category = 'Power Grid/Speed/Speed of Sound',
},
{ tooltip = 'Supersonic: from Mach-2 to Orbital Velocity',
category = 'Power Grid/Speed/Supersonic',
},
{ tooltip = 'Speed of light: 300000 km/s',
category = 'Power Grid/Speed/Speed of Light',
},
{ tooltip = 'Warp: faster than light',
category = 'Power Grid/Speed/Warp',
},
},
},
[4] = { label = 'Durability',
tooltip = 'Ability to resist or recover from bodily injury',
values = {
{ tooltip = 'Weak',
category = 'Power Grid/Durability/Weak',
},
{ tooltip = 'Normal',
category = 'Power Grid/Durability/Normal',
},
{ tooltip = 'Enhanced',
category = 'Power Grid/Durability/Enhanced',
},
{ tooltip = 'Regenerative',
category = 'Power Grid/Durability/Regenerative',
},
{ tooltip = 'Bulletproof',
category = 'Power Grid/Durability/Bulletproof',
},
{ tooltip = 'Superhuman',
category = 'Power Grid/Durability/Superhuman',
},
{ tooltip = 'Virtually indestructible',
category = 'Power Grid/Durability/Virtually Indestructible',
},
},
},
[5] = { label = 'Energy Projection',
tooltip = 'Ability to discharge energy',
values = {
{ tooltip = 'None',
category = 'Power Grid/Energy Projection/None',
},
{ tooltip = 'Energy discharge on contact',
category = 'Power Grid/Energy Projection/On Contact',
},
{ tooltip = 'Single energy type: SHORT range and duration',
category = 'Power Grid/Energy Projection/Single Type: Short Range',
},
{ tooltip = 'Single energy type: MEDIUM range and duration',
category = 'Power Grid/Energy Projection/Single Type: Medium Range',
},
{ tooltip = 'Single energy type: LONG range and duration',
category = 'Power Grid/Energy Projection/Single Type: Long Range',
},
{ tooltip = 'Multiple energy types',
category = 'Power Grid/Energy Projection/Multiple Types',
},
{ tooltip = 'Virtually unlimited command of all types of energy',
category = 'Power Grid/Energy Projection/Virtually Unlimited',
},
},
},
[6] = { label = 'Fighting Skills',
tooltip = 'Proficiency in hand-to-hand combat',
values = {
{ tooltip = 'Poor',
category = 'Power Grid/Fighting Skills/Poor',
},
{ tooltip = 'Normal',
category = 'Power Grid/Fighting Skills/Normal',
},
{ tooltip = 'Some training',
category = 'Power Grid/Fighting Skills/Some Training',
},
{ tooltip = 'Experienced fighter',
category = 'Power Grid/Fighting Skills/Experienced Fighter',
},
{ tooltip = 'Master of a single form of combat',
category = 'Power Grid/Fighting Skills/Master: Single Form of Combat',
},
{ tooltip = 'Master of several forms of combat',
category = 'Power Grid/Fighting Skills/Master: Several Forms of Combat',
},
{ tooltip = 'Master of all forms of combat',
category = 'Power Grid/Fighting Skills/Master: All Forms of Combat',
},
},
},
}
--------------------------------------------------------------------------------
function p.main(frame)
local args = getArgs (frame)
local pagename = mw.title.getCurrentTitle().subpageText
local explanation = args.Explanation
local reference = args.Reference
local caption = 'Power Grid'
local value
local categories
local output_categories = {}
local output = {}
table.insert(output, '{{DEFAULTSORT:'..standard.name_for_sorting({pagename})..'|noerror}}')
table.insert(output_categories, 'Power Grid Added')
for i = 1,6 do
value, categories = p.add_tr(i, args[list[i].label], explanation)
table.insert(output, value)
output_categories = h.join_tables(output_categories, categories)
end
if not h.isempty(explanation)
then
explanation = tostring(mw.html.create('td'):attr('colspan', '8'):css('width', '350px'):wikitext('* '..explanation))
explanation = tostring(mw.html.create('tr'):wikitext(explanation))
else
explanation = ''
end
if not h.isempty(reference)
then
caption = caption..'<ref>'..reference..'</ref>'
table.insert(output_categories, 'Power Grid Complete')
else
table.insert(output_categories, 'Power Grid Reference Needed')
end
caption = mw.html.create('caption')
:css('color', 'white')
:css('background-color', 'gray')
:css('font-weight', 'bold')
--:css('font-style', 'italic')
:wikitext(caption)
caption = tostring(caption)
output = mw.html.create('table')
:attr('align', 'right')
:attr('cellspacing', '0')
:attr('cellpadding', '0')
:css('clear', 'both')
:css('background-color', 'white')
:css('border', '1px solid gray')
:wikitext(caption..table.concat(output)..explanation)
return frame:preprocess(tostring(output))..h.add_categories(output_categories)
end
--------------------------------------------------------------------------------
function p.add_tr(row_number, values, explanation)
local value1
local value2 = nil
local label = design.lua_add_tooltip(list[row_number].label, list[row_number].tooltip)
local output_categories = {}
local output
if string.find(values, '-', 1, true) ~= nil
then
value1, value2 = string.match(values, '(%d)%-(%d)')
value1 = tonumber(value1)
value2 = tonumber(value2)
if explanation ~= nil
then label = label .. '*'
end
else value1 = tonumber(values)
end
label = mw.html.create('td')
:css('color', 'black')
:css('text-align', 'left')
:css('width', '140px')
:css('padding', '0px 0px 0px 5px')
:wikitext(label)
label = tostring(label)
value1, output_categories = p.add_td(value1, value2, row_number)
output = tostring( mw.html.create('tr'):wikitext( label..value1 ) )
return output, output_categories
end
--------------------------------------------------------------------------------
function p.add_td(value1, value2, row_number)
local function cell(text, color)
return tostring(mw.html.create('td')
:css('width', '30px')
:css('text-align', 'center')
:css('border-bottom', '1px solid gray')
:css('background-color', color)
:wikitext(text)
)
end
local color1 = 'darkgray'
local color2 = 'royalblue'
local i
local category1
local category2
local tooltip1
local tooltip2
local output_categories = {}
local output = {'', '', '', '', '', '', ''}
category1 = list[row_number].values[value1].category
tooltip1 = design.lua_add_tooltip(value1, list[row_number].values[value1].tooltip)
tooltip1 = tostring( mw.html.create('span'):css('color', 'white'):wikitext(tooltip1) )
table.insert(output_categories, category1)
category1 = h.LinkToCategory(category1, tooltip1)
if not h.isempty(value2)
then
category2 = list[row_number].values[value2].category
tooltip2 = design.lua_add_tooltip(value2, list[row_number].values[value2].tooltip)
tooltip2 = tostring( mw.html.create('span'):css('color', 'white'):wikitext(tooltip2) )
table.insert(output_categories, category2)
category2 = h.LinkToCategory(category2, tooltip2)
end
for i = 1, 7 do
tooltip = design.lua_add_tooltip(i, list[row_number][i])
output[i] = cell('', 'transparent')
if i < value1
then output[i] = cell('', color1)
elseif i == value1
then output[i] = cell(category1, color1)
elseif value2 ~= nil
then
if i < value2
then output[i] = cell('', color2)
elseif i == value2
then output[i] = cell(category2, color2)
end
end
end
return table.concat(output), output_categories
end
--------------------------------------------------------------------------------
function p.power_grid_category(frame)
local args = getArgs (frame)
local subpageText = mw.title.getCurrentTitle().subpageText
local baseText = mw.title.getCurrentTitle().baseText
local rootText = mw.title.getCurrentTitle().rootText
local i
local j
local previous_label = ''
local next_label = ''
local current_label = ''
local category
local output = 'This category is a part of the official power ratings presented in various Marvel handbooks.<br>'
if baseText == rootText
then
for i = 1,6 do
if list[i].label == subpageText
then
category = h.Category(baseText, subpageText)
output = output..design.span(string.upper(subpageText)).bold..' — '..list[i].tooltip
output = design.messagebox({output})
end
end
else
for i = 1,6 do
if list[i].label == string.match(baseText, '/(.+)')
then
for j = 1,7 do
if list[i].values[j].category == baseText..'/'..subpageText
then
category = h.Category(baseText, j)
output = design.messagebox({output..design.span(string.upper(list[i].label)).bold..' — '..list[i].tooltip})
if j == 1
then
previous_label = ''
next_label = list[i].values[j+1].category
next_label = h.LinkToCategory(next_label, string.match(next_label, '/.+/(.+)') )..' →'
elseif j == 7
then
previous_label = list[i].values[j-1].category
previous_label = '← '..h.LinkToCategory(previous_label, string.match(previous_label, '/.+/(.+)') )
next_label = ''
else
previous_label = list[i].values[j-1].category
previous_label = '← '..h.LinkToCategory(previous_label, string.match(previous_label, '/.+/(.+)') )
next_label = list[i].values[j+1].category
next_label = h.LinkToCategory(next_label, string.match(next_label, '/.+/(.+)') )..' →'
end
previous_label = tostring( mw.html.create('td'):css('width', '20%'):css('text-align', 'left'):wikitext(previous_label) )
next_label = tostring( mw.html.create('td'):css('width', '20%'):css('text-align', 'right'):wikitext(next_label) )
current_label = tostring(mw.html.create('span'):css('font-size', '18px'):wikitext(j..' / 7'))
current_label = design.span(current_label..'<br>'..string.upper(list[i].values[j].tooltip)).bold
current_label = tostring( mw.html.create('td'):css('width', '60%'):css('text-align', 'center'):wikitext(current_label) )
current_label = tostring( mw.html.create('tr'):wikitext(previous_label..current_label..next_label) )
current_label = tostring( mw.html.create('table'):css('width', '100%'):wikitext(current_label) )
output = output..design.messagebox({current_label})
end
end
end
end
end
return output..category
end
return p