FANDOM


m
m (Maybe?)
Line 143: Line 143:
 
local dropRarity = p.getRelicDropRarity(relic, item_type, item_part)
 
local dropRarity = p.getRelicDropRarity(relic, item_type, item_part)
 
if(dropRarity ~= nil) then
 
if(dropRarity ~= nil) then
local relicText = relic.Tier.." "..relic.Name
+
local relicText = "[["..relic.Tier.." "..relic.Name.."]]"
 
local relicString = tooltipStart..relicText..tooltipCenter..relicText..tooltipEnd.." "..dropRarity
 
local relicString = tooltipStart..relicText..tooltipCenter..relicText..tooltipEnd.." "..dropRarity
 
if(relic.IsVaulted == 1) then
 
if(relic.IsVaulted == 1) then

Revision as of 00:42, June 20, 2018

--WARFRAME Wiki Void Drop Table
--http://warframe.wikia.com/
--Written by User:ChickenBar
 
local p = {}
 
local VoidData = mw.loadData( 'Module:Void/data' )
local Icon = require( "Module:Icon" )
local Shared = require( "Module:Shared" )
 
local TxtColors = {Common = '#9C7344', Uncommon = '#D3D3D3', Rare = '#D1B962'}
 
local tooltipStart = "<span style=\"border-bottom: 1px dotted;\" class=\"relic-tooltip\" data-param=\""
local tooltipCenter = "\">"
local tooltipEnd = "</span>"
 
-- Converts item names in data to proper names
-- So for example 'LATRON' becomes 'Latron Prime'
function p.getItemName(itemStr)
    caseItem = string.gsub(itemStr, "(%a)([%w_']*)", Shared.titleCase)
    if(itemStr ~= "FORMA") then
        caseItem = caseItem.." Prime"
    end
    return caseItem
end
 
-- Converts part names in data to proper casing
function p.getPartName(partStr, keepBlueprint)
    --User:Falterfire 6/19/2018:
    --      New parameter to remove ' Blueprint' if wanted
    --      IE returns 'Neuroptics' instead of 'Neuroptics Blueprint'
    if keepBlueprint == nil then keepBlueprint = true end
    local result = string.gsub(partStr, "(%a)([%w_']*)", Shared.titleCase)
    if not keepBlueprint and Shared.contains(result, ' Blueprint') then
        result = string.gsub(result, ' Blueprint', '')
    end
    return result
end
 
--Gets the relic with the appropriate name
function p.getRelic(Tier, Name)
    for i, relic in pairs(VoidData["Relics"]) do
        if (relic.Tier == Tier and relic.Name == Name) then
            return relic
        end
    end
    return nil
end
 
--Right now, all relics are on the same platform
--If that changes, this function will allow separating by platform
function p.isRelicOnPlatform(Relic, Platform)
    local Platforms = Relic.Platforms
    if(Platforms == nil) then
        return true
    else
        local foundIt = false
        for i, plat in pairs(Platforms) do
            if (plat == Platform) then
                foundIt = true
            end
        end
        return foundIt
    end
end
 
--Returns the rarity if a relic drops a part
--Otherwise, returns nil
function p.getRelicDropRarity(Relic, item, part)
    for i, drop in pairs(Relic.Drops) do
        if ( drop.Item == item and drop.Part == part) then
            return drop.Rarity
        end
    end
 
    return nil
end
 
--Returns the part icon for a drop
--(IE Braton Prime Barrel returns the Prime Barrel icon)
function p.getPartIconForDrop(drop)
    local iName = p.getItemName(drop.Item)
    local pName = p.getPartName(drop.Part)
    local iconSize =''
    local primeToggle = 'Prime '
    if iName == 'Forma' then
        iconSize = '43'
    else
        iconSize = '54'
    end
 
    if iName == 'Odonata Prime' then
        if pName == 'Harness Blueprint' or pName == 'Systems Blueprint' or pName == 'Wings Blueprint' then
            primeToggle = 'Archwing '
        end
    elseif pName == 'Carapace' or pName == 'Cerebrum' or pName == 'Systems' then
        primeToggle = ''
    end
 
    local icon =''
    if(pName == 'Blueprint') then
        icon = Icon._Prime(Shared.titleCase(drop.Item), nil,iconSize)
    elseif iName == 'Kavasa Prime' then
        icon = Icon._Prime('Kavasa', nil,iconSize)
    else
        icon = Icon._Item(primeToggle..pName,"",iconSize)
    end
 
    return icon
end
 
--Returns the item icon for a drop
--(IE Braton Prime Barrel returns the Braton Prime icon)
function p.getItemIconForDrop(drop)
    local iName = p.getItemName(drop.Item)
    local pName = p.getPartName(drop.Part)
    local iconSize =''
    if iName == 'Forma' then
        iconSize = '38'
    else
        iconSize = '38'
    end
 
    local icon =''
    icon = Icon._Prime(Shared.titleCase(drop.Item), nil, iconSize)
 
    return icon
end
 
function p.item( frame )
    local platform = frame.args[1]
    local item_type = string.upper(frame.args[2])
    local item_part = string.upper(frame.args[3])
    local relic_tier = frame.args[4]
    if (item_part == "HELMET BLUEPRINT") then
        item_part = "NEUROPTICS BLUEPRINT"
    end
    local locations = {}
    local vaultLocations = {}
    local i
    for i, relic in pairs(VoidData["Relics"]) do
        if(p.isRelicOnPlatform(relic, platform) and (relic_tier == nil or relic.Tier == relic_tier)) then
            local dropRarity = p.getRelicDropRarity(relic, item_type, item_part)
            if(dropRarity ~= nil) then
                local relicText = "[["..relic.Tier.." "..relic.Name.."]]"
                local relicString = tooltipStart..relicText..tooltipCenter..relicText..tooltipEnd.." "..dropRarity
                if(relic.IsVaulted == 1) then
                    relicString = relicString.." ([[Prime Vault|V]])"
                    table.insert(vaultLocations, relicString)
                else
                    if(relic.IsBaro == 1) then
                        relicString = relicString.." ([[Baro Ki%27Teer|B]])"
                    end
                    table.insert(locations, relicString)
                end
            end
        end
    end
 
    for _, i in pairs(vaultLocations) do
        table.insert(locations, i)
    end
    return table.concat(locations, "<br/>")
end
 
function p.relicTooltip(frame)
    local relicName = frame.args ~= nil and frame.args[1] or frame
    local platform = frame.args ~= nil and frame.args[2]
    if(platform == nil) then platform = 'PC' end
    if(relicName == nil) then return nil end
 
    local bits = Shared.splitString(relicName, ' ')
    local Tier = bits[1]
    local RName = bits[2]
 
    local theRelic = p.getRelic(Tier, RName)
    if(theRelic == nil) then return 'ERROR: No relic found' end
    if(not p.isRelicOnPlatform(theRelic, Platform)) then return "ERROR: That relic isn't on that platform" end
 
    local result = '{|'
 
    local rareTxt = {Common = '', Uncommon = '', Rare = ''}
 
    for i, drop in pairs(theRelic.Drops) do
        local rarity = drop.Rarity
        if(rarity ~= nil) then
            if(rareTxt[rarity] ~= '') then rareTxt[rarity] = rareTxt[rarity]..'\n' end
            if(i > 1) then rareTxt[rarity] = rareTxt[rarity]..'|-' end
 
            local iName = p.getItemName(drop.Item)
            local pName = p.getPartName(drop.Part)
 
            local icon = p.getPartIconForDrop(drop)
 
            rareTxt[rarity] = rareTxt[rarity]..'\n| rowspan=2 class=\"Image\" | '..icon
 
            rareTxt[rarity] = rareTxt[rarity]..'\n| class = "gradientText" style = "vertical-align:bottom; color:'..TxtColors[rarity]..';" | '..iName
            rareTxt[rarity] = rareTxt[rarity]..'\n|-\n| class = "gradientText" style = "vertical-align:top; color:'..TxtColors[rarity]..';" | '..pName
        end
    end
 
 
    result = result..rareTxt['Common']..'\n'..rareTxt['Uncommon']
    result = result..'\n'..rareTxt['Rare']
    result = result..'\n|}'
 
    return result
end
 
function p.getRelicDrop(frame)
    local relicName = frame.args ~= nil and frame.args[1] or nil
    local rarity = frame.args ~= nil and frame.args[2] or nil
    local number = frame.args ~= nil and frame.args[3] or nil
    if number == nil then 
        --The number of the drop defaults to 1 if not set
        number = 1 
    elseif type(number) == 'string' then
        --If the argument is a string, force it into being a number
        number = tonumber(number)
    end
 
    --Platform comes from a special argument. Defaults to PC if not set
    local platform = frame.args ~= nil and frame.args.platform or nil
    if platform == nil then platform = 'PC' end
 
    --Return an error if any arguments are missing
    if relicName == nil or relicName == '' then
        return "ERROR: Missing argument 'Relic Name'"
    elseif rarity == nil or rarity == '' then
        return "ERROR: Missing argument 'Rarity'"
    end
 
    local bits = Shared.splitString(relicName, ' ')
    local Tier = bits[1]
    local RName = bits[2]
 
    local theRelic = p.getRelic(Tier, RName)
 
    --Return an error if the relic wasn't found
    if theRelic == nil then
        return "ERROR: Invalid relic '"..relicName.."'"
    end
 
    local count = 0
    for i, drop in pairs(theRelic.Drops) do
        --Loop through the drops to find drops of the chosen rarity
        if drop.Rarity == rarity then
            count = count + 1
            --Once enough drops of the right kind have been found, return the icon + the item name
            if count == number then
                local iName = p.getItemName(drop.Item)
                local pName = p.getPartName(drop.Part, false)
                local icon = p.getItemIconForDrop(drop)
 
                return icon..' [['..iName..'|'..iName..' '..pName..']]'
            end
        end
    end
 
    --If we got to here, there weren't enough drops of that rarity for this relic.
    return "ERROR: Only found "..count.." drops of "..rarity.." rarity for "..relicName
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.