Advertisement

Module:Card/has

Edit documentation

Description

Provides functions to ask if a card has or is something. Every function returns boolean values.

See also


local p    = {}
local data = mw.loadData('Module:Card/data')

local function verified_name(n)
    if data[n] then return n end
    if data[n .. " (Fire)"] then return n .. " (Fire)" end
    if data[n .. " (Frost)"] then return n .. " (Frost)" end
    if data[n .. " (Nature)"] then return n .. " (Nature)" end
    if data[n .. " (Shadow)"] then return n .. " (Shadow)" end
end

function p.promo(cardname)
    if data[cardname .. " (Promo)"] then return true else return false end
end

function p.nonpromo(cardname)
    -- nonpromo returns false if there are affinity_variants (infobox helper function)
    if data[cardname] then return true end
    return p.affinities(cardname)
end

function p.starter_card(cardname)
    if data[cardname] and data[cardname].starter_card then return true end
    if data[cardname .. " (Fire)"] and data[cardname .. " (Fire)"].starter_card then return true end
    if data[cardname .. " (Frost)"] and data[cardname .. " (Frost)"].starter_card then return true end
    if data[cardname .. " (Nature)"] and data[cardname .. " (Nature)"].starter_card then return true end
    if data[cardname .. " (Shadow)"] and data[cardname .. " (Shadow)"].starter_card then return true end
    return false
end

-- not even affinity
function p.normal(cardname)
    if data[cardname] then return true else return false end
end

function p.affinity(cardname, affinity)
    if data[cardname .. " (".. affinity ..")"] then return true else return false end
end

function p.affinities(cardname)
    if data[cardname .. " (Fire)"] then return true end
    if data[cardname .. " (Frost)"] then return true end
    if data[cardname .. " (Nature)"] then return true end
    if data[cardname .. " (Shadow)"] then return true end
    return false
end

return p