|
|
| (41 intermediate revisions by 4 users not shown) |
| Line 1: |
Line 1: |
| local p = {};
| | This page is protected from editing. Please see [[Deadlock:User pages]]. |
| local data = mw.loadJsonData("Data:ItemData.json")
| |
| | |
| -- Utility function to get item by name
| |
| local function get_json_item(name)
| |
| for _, v in pairs(data) do
| |
| if v["Name"] == name and not v["IsDisabled"] then
| |
| return v
| |
| end
| |
| end
| |
| return nil
| |
| end
| |
| | |
| -- Format numbers with commas
| |
| local lang = mw.language.getContentLanguage()
| |
| local function formatNum(amount)
| |
| return lang:formatNum(tonumber(amount))
| |
| end
| |
| | |
| -- Main function to generate infobox content
| |
| p.generate_infobox = function(frame)
| |
| local item_name = frame.args[1]
| |
| local item = get_json_item(item_name)
| |
| if not item then return "<span class='error'>Item not found: " .. item_name .. "</span>" end
| |
|
| |
| -- Determine item type
| |
| local item_type = "Weapon"
| |
| if item.Slot == "Armor" then
| |
| item_type = "Vitality"
| |
| elseif item.Slot == "Tech" then
| |
| item_type = "Spirit"
| |
| end
| |
|
| |
| -- Generate stats section
| |
| local stats = {}
| |
| if item.TechPower and item.TechPower ~= "0" then
| |
| table.insert(stats, "• "..item.TechPower.." [[File:Spirit icon.png|20px]] Spirit Power")
| |
| end
| |
| if item.WeaponPower and item.WeaponPower ~= "0" then
| |
| table.insert(stats, "• "..item.WeaponPower.." [[File:Weapon Icon.png|20px]] Weapon Damage")
| |
| end
| |
| if item.TechResist and item.TechResist ~= "0" then
| |
| table.insert(stats, "• "..item.TechResist.." [[File:Spirit Resist Icon.png|20px]] Tech Resist")
| |
| end
| |
| if item.BulletResist and item.BulletResist ~= "0" then
| |
| table.insert(stats, "• "..item.BulletResist.." [[File:Bullet Resist Icon.png|20px]] Bullet Resist")
| |
| end
| |
| local stats_text = table.concat(stats, "\n|-\n| ")
| |
|
| |
| -- Generate components section if exists
| |
| local components_text = ""
| |
| if item.Components then
| |
| local component = data[item.Components[1]]
| |
| if component then
| |
| components_text = [=[
| |
| ! colspan="4" style="text-align:left; padding:0 12px; font-weight:bold; font-size:16px; font-family:'Retail Demo Bold',serif; ]=] ..
| |
| (item_type == "Weapon" and "background-color: #9E630C; color: #DCCFC6;" or
| |
| item_type == "Vitality" and "background-color: #203500; color: #C7C9C6;" or
| |
| "background-color: #372248; color: #C9C7CB;") .. [=[">COMPONENTS:<br/>{{ItemIcon|]=] .. component.Name .. [=[}}]=]
| |
| end
| |
| end
| |
|
| |
| -- Generate the full infobox
| |
| local infobox = [=[
| |
| <div class="infobox_item" style="float:right; display:inline-block; vertical-align:top;">
| |
| {| style="text-align:left; border-collapse:collapse; width:312px; max-width:100%; height:30px; color: #FFEFD7; padding:12px; font-family:'Retail Demo Regular',serif; ]=] ..
| |
| (item_type == "Weapon" and "background-color: #80550F;" or
| |
| item_type == "Vitality" and "background-color: #4D7214;" or
| |
| "background-color: #623585;") .. [=["
| |
| ! colspan="4"; style="width:280px; padding:5px 12px; text-align:center; font-size:24px; font-family:'Retail Demo Bold',serif; ]=] ..
| |
| (item_type == "Weapon" and "background-color: #C97A03;" or
| |
| item_type == "Vitality" and "background-color: #659818;" or
| |
| "background-color: #8B56B4;") .. [=[">]=] .. item.Name .. [=[
| |
| |-
| |
| | colspan=4 class="infobox-image" style="padding:5px; text-align:center;">[[File:]=] .. item.Name .. [=[.png|144px]]
| |
| |-
| |
| | colspan=2 style="text-align:right; width:50%; ]=] ..
| |
| (item_type == "Weapon" and "border-right:1px solid #C97A03;" or
| |
| item_type == "Vitality" and "border-right:1px solid #659818;" or
| |
| "border-right:1px solid #8B56B4;") .. [=[ padding-right:0.5em;">Cost
| |
| | colspan=2 style="padding-left:0.5em;">{{Souls|]=] .. formatNum(item.Cost) .. [=[}}}
| |
| |-
| |
| | colspan=2 style="text-align:right; width:50%; ]=] ..
| |
| (item_type == "Weapon" and "border-right:1px solid #C97A03;" or
| |
| item_type == "Vitality" and "border-right:1px solid #659818;" or
| |
| "border-right:1px solid #8B56B4;") .. [=[ padding-right:0.5em;">Tier
| |
| | colspan=2 style="padding-left:0.5em;">]=] .. item.Tier .. [=[
| |
| |-
| |
| | colspan=2 style="text-align:right; width:50%; ]=] ..
| |
| (item_type == "Weapon" and "border-right:1px solid #C97A03;" or
| |
| item_type == "Vitality" and "border-right:1px solid #659818;" or
| |
| "border-right:1px solid #8B56B4;") .. [=[ padding-right:0.5em;">Shop Bonus
| |
| | colspan=2 style="padding-left:0.5em;">]=] ..
| |
| (item_type == "Weapon" and "+" .. (6 + (tonumber(item.Tier)-1)*4) .. "% Weapon Damage" or
| |
| item_type == "Vitality" and "+" .. (11 + (tonumber(item.Tier)-1)*3) .. "% Base Health" or
| |
| "+" .. (4 * tonumber(item.Tier)) .. " Spirit Power") .. [=[
| |
| |-
| |
| ]=] .. components_text .. [=[
| |
| |-
| |
| | colspan="4" style="text-align:left; padding:0 12px; color:#FFEFD7; ]=] ..
| |
| (item_type == "Weapon" and "background-color: #80550F;" or
| |
| item_type == "Vitality" and "background-color: #4D7214;" or
| |
| "background-color: #623585;") .. [=[">]=] .. item.Description .. [=[
| |
| |-
| |
| | ]=] .. stats_text .. [=[
| |
| |}
| |
| </div>]=]
| |
|
| |
| return infobox
| |
| end
| |
| | |
| return p
| |