WARFRAME Wiki
Advertisement
WARFRAME Wiki


Lua error in Module:Docbunto at line 922: documentation markup for Docbunto not found in Module:Void.
Created with Docbunto

See Also

Code


--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'}

-- 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)
  return string.gsub(partStr, "(%a)([%w_']*)", Shared.titleCase)
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

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 relicString = relic.Tier.." "..relic.Name.." "..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]
    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]..'<br/>'
            end
            
            local iName = p.getItemName(drop.Item)
            local pName = p.getPartName(drop.Part)
            local icon ='' 
            if(pName == 'Blueprint') then
                icon = Icon._Prime(Shared.titleCase(drop.Item))
            else
                icon = Icon._Item('Prime '..pName)
            end
            
            local innerText = icon..' '..iName..' '..pName
            
            rareTxt[rarity] = rareTxt[rarity].."<span style=\"color:" ..TxtColors[rarity]..";\">"..innerText.. "</span>"
        end
    end
    
    result = result..rareTxt['Common']..'<br/>'..rareTxt['Uncommon']
    result = result..'<br/>'..rareTxt['Rare']
    
    return result
end

return p
Advertisement