No edit summary |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local qualities = {'Nor', 'Good', 'Great', 'Top', 'Divine'} |
local qualities = {'Nor', 'Good', 'Great', 'Top', 'Divine'} |
||
local qualities2 = {'Normal', 'Good', 'Great', 'Top', 'Divine'} |
local qualities2 = {'Normal', 'Good', 'Great', 'Top', 'Divine'} |
||
+ | local gear = { 'Longswords', 'Shields' } |
||
− | |||
⚫ | |||
--Function to add the Japanese Name under the Enligsh name if it founds the Japanese name in the Data Module |
--Function to add the Japanese Name under the Enligsh name if it founds the Japanese name in the Data Module |
||
local function japaneseName(name) |
local function japaneseName(name) |
||
local ttag = mw.html.create() |
local ttag = mw.html.create() |
||
− | if (Longswords[name].Japanese == '' or Longswords[name]. |
+ | if (Longswords[name].Japanese == '' or Longswords[name].Japanese == nil) then |
ttag:wikitext("'''".. name .."'''") |
ttag:wikitext("'''".. name .."'''") |
||
else |
else |
||
Line 210: | Line 209: | ||
end |
end |
||
return ttag |
return ttag |
||
+ | end |
||
+ | |||
+ | --Function to get all Data from item name |
||
+ | local function getData(name) |
||
+ | for k = 1, #gear do |
||
⚫ | |||
+ | if (data[name] ~= nil) then |
||
+ | local value = {} |
||
+ | value.name = name |
||
+ | if ( data[name].Japanese ~= nil ) then |
||
+ | value.Japanese = data[name].Japanese end |
||
+ | value.Description = data[name].Description |
||
+ | value.Rarity = data[name].Rarity |
||
+ | value.Usable = data[name].Usable |
||
+ | value.Skill = data[name].Skill |
||
+ | value.SkillLvl = data[name].SkillLvl |
||
+ | value.Stat1 = data[name].Stat1 |
||
+ | value.Stat1Value = data[name].Stat1Value |
||
+ | if ( data[name].Stat2 ~= nil ) then |
||
+ | value.Stat2 = data[name].Stat2 |
||
+ | value.Stat2Value = data[name].Stat2Value |
||
+ | end |
||
+ | value.Special = data[name].Special |
||
+ | if ( data[name].CraftClass ~= nil ) then |
||
+ | value.CraftClass = data[name].CraftClass |
||
+ | value.CraftRank = data[name].CraftRank |
||
+ | value.Ingredients = data[name].Ingredients |
||
+ | value.Amount = data[name].Amount |
||
+ | end |
||
+ | value.Sold = data[name].Sold |
||
+ | value.Sell = data[name].Sell |
||
+ | value.Type = data[name].Type |
||
+ | return value |
||
+ | end |
||
+ | end |
||
end |
end |
||
-- Main function that creates Template for Item |
-- Main function that creates Template for Item |
||
return { |
return { |
||
− | + | buildGearInfobox = function(frame) |
|
local args = frame.args; |
local args = frame.args; |
||
local name = mw.text.decode(args['Name']); |
local name = mw.text.decode(args['Name']); |
||
+ | local data = getData(name); |
||
− | local navTable = mw.html.create('table'):css('float', 'right') |
||
+ | local result = {} |
||
− | :css('margin-left', '10px'):css('margin-bottom', '10px'):css('background', '#f8cb34'):css('font-size', 'small') |
||
+ | |||
− | :css('border', '2px solid #511e00'):css('border-radius', '10px'):css('width', '300px') |
||
+ | table.insert(result, '{| style="float: right; margin-left: 10px; margin-bottom: 10px; background: #f8cb34; font-size: small; border: 2px solid #511e00; border-radius: 10px; width: 300px"') |
||
− | |||
+ | table.insert(result, '{|-') |
||
+ | table.insert(result, '{| '..data.name) |
||
+ | table.insert(result, '{|-') |
||
+ | table.insert(result, '{| ola') |
||
+ | --[=[ |
||
--First Row (Brown) - Title, Image and Description |
--First Row (Brown) - Title, Image and Description |
||
:tag('tr'):css('text-align', 'center') |
:tag('tr'):css('text-align', 'center') |
||
Line 300: | Line 339: | ||
:node(cell(Longswords[name].Type, 'td', '#ffffff', 'center', '145', '2', 'bottom-right','6px')) |
:node(cell(Longswords[name].Type, 'td', '#ffffff', 'center', '145', '2', 'bottom-right','6px')) |
||
:done() |
:done() |
||
+ | ]=]-- |
||
− | return frame:preprocess(tostring(navTable)) |
||
+ | table.insert(result, '|}') |
||
+ | return table.concat(result, '\n') |
||
end |
end |
||
} |
} |
Revision as of 21:54, 24 October 2021
Documentation for this module may be created at Module:Test/doc
local qualities = {'Nor', 'Good', 'Great', 'Top', 'Divine'}
local qualities2 = {'Normal', 'Good', 'Great', 'Top', 'Divine'}
local gear = { 'Longswords', 'Shields' }
--Function to add the Japanese Name under the Enligsh name if it founds the Japanese name in the Data Module
local function japaneseName(name)
local ttag = mw.html.create()
if (Longswords[name].Japanese == '' or Longswords[name].Japanese == nil) then
ttag:wikitext("'''".. name .."'''")
else
ttag:wikitext("'''".. name .."<br>"..Longswords[name].Japanese.."'''")
end
return ttag
end
--Function that creates Brown table with name and Icon
local function createTabber(name,i,h,hide)
local ttag = mw.html.create('table')
if (hide ~= 1) then
ttag:addClass('mobile-hidden')
end
ttag:css('background', '#ac6219'):css('border-radius', '6px'):attr('width', '100%')
:tag('tr')
:css('position', 'relative')
:tag('td')
:attr('width', '192px'):attr('height', h):css('color', 'white'):css('align', 'center')
:node(japaneseName(name))
:done()
:tag('td')
:tag('span')
:css('position', 'absolute'):css('bottom', '0'):css('right', '0'):addClass('mobile-hidden')
:wikitext('[[File:Gear '..qualities2[i]..'.png]]')
:done()
:tag('span')
:css('position', 'absolute'):css('bottom', '0'):css('right', '0')
:wikitext('[[File:'.. name ..'.png]]')
:done()
:done()
:done()
:tag('tr')
:attr('align', 'left')
:tag('td')
:css('background', '#ffffff'):css('border-radius', '3px'):css('padding-left', '3px'):css('padding-right', '3px')
:attr('colspan', '2')
:wikitext(Longswords[name].Description)
:done()
:done()
return ttag
end
--Function adds tabber for the different Icons Backgrounds If Item is craftable and has diferent Qualities
local function makeQuality(name)
local tabber = mw.html.create('tabber')
for i = 1, 5 do
if (Longswords[name].CraftClass == nil) then
tabber = createTabber(name,1,72,1)
break
end
tabber:wikitext('|-|'..qualities[i]..'= ')
:node(createTabber(name,i,85,i))
:done()
end
return tabber
end
--Function to create the Table Row of the main Headers use in Rarity, Usable By, Stats, Information, etc.
local function mainHeader(name, h)
local ttag = mw.html.create('tr'):css('position', 'relative')
:tag('td'):attr('height', h):addClass('mobile-hidden'):done()
:tag('th'):css('background', '#ffdd7a'):css('border-top-right-radius', '6px'):css('border-top-left-radius', '6px')
:css('display','inline'):css('position', 'absolute'):css('right', '18px'):attr('colspan', '4')
:attr('width','256'):attr('height', h):wikitext(name)
:done()
return ttag
end
--Function to fill in the right lives usable by the item
local function usable(name)
local lifeIcons = { Paladin = '[[File:Paladin icon 0.png|link=Paladin]] ',
Mercenary = '[[File:Mercenary icon 0.png|link=Mercenary]] ',
Hunter = '[[File:Hunter icon 0.png|link=Hunter]] ',
Magician = '[[File:Magician icon 0.png|link=Magician]] ',
Miner = '[[File:Miner icon 0.png|link=Miner]] ',
Woodcutter = '[[File:Woodcutter icon 0.png|link=Woodcutter]] ',
Angler = '[[File:Angler icon 0.png|link=Angler]] ',
Cook = '[[File:Mercenary icon 0.png|link=Cook]] ',
Blacksmith = '[[File:Blacksmith icon 0.png|link=Blacksmith]] ',
Carpenter = '[[File:Carpenter icon 0.png|link=Carpenter]] ',
Tailor = '[[File:Tailor icon 0.png|link=Tailor]] ',
Alchemist = '[[File:Alchemist icon 0.png|link=Alchemist]] '}
if (Longswords[name].Usable[1] == "All") then
return mw.html.create():wikitext('[[File:Paladin icon 1.png|link=Paladin]] [[File:Mercenary icon 1.png|link=Mercenary]] [[File:Hunter icon 1.png|link=Hunter]] [[File:Magician icon 1.png|link=Magician]] [[File:Miner icon 1.png|link=Miner]] [[File:Woodcutter icon 1.png|link=Woodcutter]] [[File:Angler icon 1.png|link=Angler]] [[File:Cook icon 1.png|link=Cook]] [[File:Blacksmith icon 1.png|link=Blacksmith]] [[File:Carpenter icon 1.png|link=Carpenter]] [[File:Tailor icon 1.png|link=Tailor]] [[File:Alchemist icon 1.png|link=Alchemist]]')
else
--LifeIcons [ Key -> item]
for key, item in pairs(lifeIcons) do
for i, live in pairs(Longswords[name].Usable) do
if (live == key) then
lifeIcons[key] = '[[File:'..live..' icon 1.png|link='..live..']] '
end
end
end
return mw.html.create():wikitext(lifeIcons.Paladin..lifeIcons.Mercenary..lifeIcons.Hunter..lifeIcons.Magician
..lifeIcons.Miner..lifeIcons.Woodcutter..lifeIcons.Angler..lifeIcons.Cook
..lifeIcons.Blacksmith..lifeIcons.Carpenter..lifeIcons.Tailor..lifeIcons.Alchemist)
end
return
end
--Function to add Row for Gender if applied
local function gender(name)
if (Longswords[name].Gender == '' or Longswords[name].Gender == nil) then
return
end
local ttag = mw.html.create('tr')
:tag('td'):attr('colspan', '4'):attr('align', 'center')
:wikitext('[[File:'..Longswords[name].Gender..' only.png]]')
:done()
return ttag
end
--Function to fill in the right skill and level required by the item
local function required(name)
local ttag = mw.html.create()
if ((Longswords[name].SkillLvl == '' or Longswords[name].SkillLvl == nil) and
(Longswords[name].Skill == '' or Longswords[name].Skill == nil)) then
return mw.html.create():wikitext('------')
end
if ((Longswords[name].SkillLvl ~= '' or Longswords[name].SkillLvl ~= nil) and
(Longswords[name].Skill == '' or Longswords[name].Skill == nil)) then
return mw.html.create():wikitext('Level '..Longswords[name].SkillLvl)
end
return mw.html.create():wikitext(Longswords[name].Skill..' Level '..Longswords[name].SkillLvl)
end
--Funciton to create a cell
local function cell(text, tp, color, align, width, colspan, border, value, border2, value2)
ttag = mw.html.create(tp):css('background', color)
:attr('colspan', colspan):attr('width', width):attr('height', '25'):attr('align', align)
if(border ~= nil) then
ttag:css('border-'..border..'-radius', value)
end
if(border2 ~= nil) then
ttag:css('border-'..border2..'-radius', value2)
end
ttag:wikitext(text)
return ttag
end
--Function to create rows for values of Stat1 and Sell prices Info
local function valuesDisplay(first,second)
local ttag = mw.html.create('tr')
:node(cell(first, 'th', '#ffffff', 'center', '71', '1'))
:node(cell(second, 'td', '#ffffff', 'center', '72', '1'))
return ttag
end
--Function to create rows for second Stat Info
local function stat2(name)
if (Longswords[name].Stat2 == '' or Longswords[name].Stat2 == nil) then
return
end
local ttag = mw.html.create('tr')
:node(cell(Longswords[name].Stat2, 'td', '#ffe2ab', 'center', '145', '2'))
:node(cell(Longswords[name].Stat2Value, 'td', '#ffffff', 'center', '145', '2'))
return ttag
end
--Function to create rows for Recipe Info
local function recipe(name)
if (Longswords[name].CraftClass == nil) then
return
end
if (Longswords[name].Ingredients[2] == '' or Longswords[name].Ingredients[2] == nil) then
ttag = mw.html.create()
:node(mainHeader(Longswords[name].CraftClass..'<br>'..Longswords[name].CraftRank..' Recipe', '47'))
:tag('tr'):attr('align', 'center')
:node(cell(Longswords[name].Ingredients[1], 'td', '#ffe2ab', 'center', '218', '3', 'top-left','6px', 'bottom-left', '6px'))
:node(cell('x '..Longswords[name].Amount[1], 'td', '#ffffff', 'center', '72', '1', 'top-right', '6px', 'bottom-right', '6px'))
:done()
return ttag
elseif (Longswords[name].Ingredients[3] == '' or Longswords[name].Ingredients[3] == nil) then
ttag = mw.html.create()
:node(mainHeader(Longswords[name].CraftClass..'<br>'..Longswords[name].CraftRank..' Recipe', '47'))
:tag('tr')
:node(cell(Longswords[name].Ingredients[1], 'td', '#ffe2ab', 'center', '218', '3', 'top-left','6px'))
:node(cell('x '..Longswords[name].Amount[1], 'td', '#ffffff', 'center', '72', '1', 'top-right', '6px'))
:done()
:tag('tr')
:node(cell(Longswords[name].Ingredients[2], 'td', '#ffe2ab', 'center', '218', '3', 'bottom-left','6px'))
:node(cell('x '..Longswords[name].Amount[2], 'td', '#ffffff', 'center', '72', '1', 'bottom-right', '6px'))
:done()
return ttag
else
ttag = mw.html.create()
:node(mainHeader(Longswords[name].CraftClass..'<br>'..Longswords[name].CraftRank..' Recipe', '47'))
:tag('tr')
:node(cell(Longswords[name].Ingredients[1], 'td', '#ffe2ab', 'center', '218', '3', 'top-left','6px'))
:node(cell('x '..Longswords[name].Amount[1], 'td', '#ffffff', 'center', '72', '1', 'top-right', '6px'))
:done()
:tag('tr')
:node(cell(Longswords[name].Ingredients[2], 'td', '#ffe2ab', 'center', '218', '3'))
:node(cell('x '..Longswords[name].Amount[2], 'td', '#ffffff', 'center', '72', '1'))
:done()
:tag('tr')
:node(cell(Longswords[name].Ingredients[3], 'td', '#ffe2ab', 'center', '218', '3', 'bottom-left','6px'))
:node(cell('x '..Longswords[name].Amount[3], 'td', '#ffffff', 'center', '72', '1', 'bottom-right', '6px'))
:done()
return ttag
end
return ttag
end
--Function to get all Data from item name
local function getData(name)
for k = 1, #gear do
local data = mw.loadData('Module:Gear/'..gear[k]..'/Data')
if (data[name] ~= nil) then
local value = {}
value.name = name
if ( data[name].Japanese ~= nil ) then
value.Japanese = data[name].Japanese end
value.Description = data[name].Description
value.Rarity = data[name].Rarity
value.Usable = data[name].Usable
value.Skill = data[name].Skill
value.SkillLvl = data[name].SkillLvl
value.Stat1 = data[name].Stat1
value.Stat1Value = data[name].Stat1Value
if ( data[name].Stat2 ~= nil ) then
value.Stat2 = data[name].Stat2
value.Stat2Value = data[name].Stat2Value
end
value.Special = data[name].Special
if ( data[name].CraftClass ~= nil ) then
value.CraftClass = data[name].CraftClass
value.CraftRank = data[name].CraftRank
value.Ingredients = data[name].Ingredients
value.Amount = data[name].Amount
end
value.Sold = data[name].Sold
value.Sell = data[name].Sell
value.Type = data[name].Type
return value
end
end
end
-- Main function that creates Template for Item
return {
buildGearInfobox = function(frame)
local args = frame.args;
local name = mw.text.decode(args['Name']);
local data = getData(name);
local result = {}
table.insert(result, '{| style="float: right; margin-left: 10px; margin-bottom: 10px; background: #f8cb34; font-size: small; border: 2px solid #511e00; border-radius: 10px; width: 300px"')
table.insert(result, '{|-')
table.insert(result, '{| '..data.name)
table.insert(result, '{|-')
table.insert(result, '{| ola')
--[=[
--First Row (Brown) - Title, Image and Description
:tag('tr'):css('text-align', 'center')
:tag('td'):attr('colspan', '4')
:node(makeQuality(name))
:done()
:done()
--Second Row - Rarity
:node(mainHeader('Rarity','25'))
:tag('tr'):attr('align', 'center')
:tag('td'):css('background', '#ffffff'):css('border-radius', '6px'):attr('colspan', '4'):attr('height', '25')
:wikitext('[[File:'..Longswords[name].Rarity..' Stars.png]]')
:done()
:done()
--Third Row - Usable
:node(mainHeader('Usable by','25'))
:tag('tr'):attr('align', 'center')
:tag('td'):css('background', '#f8cb34'):css('border-radius', '6px'):attr('colspan', '4'):attr('height', '25')
:node(usable(name))
:done()
:done()
--Fourth Row - Gender If applied
:node(gender(name))
--Fifth Row - Skill and Skill Level Required
:node(mainHeader('Required','25'))
:tag('tr'):attr('align', 'center')
:tag('td'):css('background', '#ffffff'):css('border-radius', '6px'):attr('colspan', '4'):attr('height', '25')
:node(required(name))
:done()
:done()
--Sixth Row - Stats. (Magic) Attack, (Magic) Defense and Special Effect
:node(mainHeader('Stats','25'))
:tag('tr'):attr('align', 'center')
:tag('th'):css('background', '#ffe2ab'):css('border-top-left-radius', '6px')
:attr('colspan', '2'):attr('rowspan', '5'):attr('width', '145')
:wikitext(Longswords[name].Stat1)
:done()
:node(cell('Normal', 'th', '#ffffff', 'center', '71', '1'))
:node(cell(Longswords[name].Stat1Value[1], 'td', '#ffffff', 'center', '72', '1', 'top-right','6px'))
:done()
:node(valuesDisplay(qualities[2],Longswords[name].Stat1Value[2]))
:node(valuesDisplay(qualities[3],Longswords[name].Stat1Value[3]))
:node(valuesDisplay(qualities[4],Longswords[name].Stat1Value[4]))
:node(valuesDisplay(qualities[5],Longswords[name].Stat1Value[5]))
:node(stat2(name))
:tag('tr')
:node(cell('Special Effects', 'th', '#ffe2ab', 'center', '145', '2', 'bottom-left','6px'))
:node(cell(Longswords[name].Special, 'td', '#ffffff', 'center', '145', '2', 'bottom-right','6px'))
:done()
--Seventh Row - Recipe
:node(recipe(name))
--Eighth Row (Last Row) - Information
:node(mainHeader('Information','25'))
:tag('tr')
:node(cell('Buy price [[Dosh]]', 'th', '#ffe2ab', 'center', '145', '2', 'top-left','6px'))
:node(cell(Longswords[name].Sold, 'td', '#ffffff', 'center', '145', '2', 'top-right','6px'))
:done()
:tag('tr'):attr('align', 'center')
:tag('th'):css('background', '#ffe2ab'):css('border-top-left-radius', '6px')
:attr('colspan', '2'):attr('rowspan', '5'):attr('width', '145')
:wikitext('Sell price<br>[[Dosh]]')
:done()
:node(cell('Normal', 'th', '#ffffff', 'center', '71', '1'))
:node(cell(Longswords[name].Sell[1], 'td', '#ffffff', 'center', '72', '1'))
:done()
:node(valuesDisplay(qualities[2],Longswords[name].Sell[2]))
:node(valuesDisplay(qualities[3],Longswords[name].Sell[3]))
:node(valuesDisplay(qualities[4],Longswords[name].Sell[4]))
:node(valuesDisplay(qualities[5],Longswords[name].Sell[5]))
:tag('tr')
:node(cell('Type', 'th', '#ffe2ab', 'center', '145', '2', 'bottom-left','6px'))
:node(cell(Longswords[name].Type, 'td', '#ffffff', 'center', '145', '2', 'bottom-right','6px'))
:done()
]=]--
table.insert(result, '|}')
return table.concat(result, '\n')
end
}