Module:DropsLineRoatz2

From Roat Pkz
Revision as of 16:32, 3 April 2024 by Hefner (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:DropsLineRoatz2/doc

local p = {}

local params = require('Module:Paramtest')
local lang = mw.language.getContentLanguage()
local coins_image = require('Module:Coins image')
local curr_image = require('Module:Currency Image')
local yesno = require('Module:Yesno')

local geprices_data = mw.loadJsonData('Module:GEPrices/data.json')

local ptitle = mw.title.getCurrentTitle()
local ns = ptitle.nsText
local title = ptitle.fullText
local pgTitle = ptitle.text

local coins_priceString = "%s Pkp"
local other_priceString = "%s Pkp"

--bg, txt, sort; acceptable non-quantity rarity names
local rarities = {
    always = { 'table-bg-blue', 1 },
    common = { 'table-bg-green', 16 },
    uncommon = { 'table-bg-yellow', 64 },
    rare = { 'table-bg-orange', 128 },
    ['very rare'] = { 'table-bg-red', 1024 },
    random = { 'table-bg-pink', 4096 },
    varies = { 'table-bg-pink', 4096 },
    once = { 'table-bg-pink', 65536 },
    conditional = { 'table-bg-pink', 65536 },
    _default = { 'table-bg-grey', 65536 }
}

-- colour-code
local rarities_class = {
    { 1, 'table-bg-blue' },
    { 1/25, 'table-bg-green' },
    { 1/99.99, 'table-bg-yellow' },
    { 1/999.99, 'table-bg-orange' },
    { 1/9999999, 'table-bg-red' }
}


function p.main(frame)
    local args = frame:getParent().args
    local frameArgs = frame.args

-- Params and defaults
    local name,namenotes,
        quantity,quantitynotes,
        rarity,rarity1,alt_rarity,alt_rarity_endash,
        raritynotes,citation,monVers = params.defaults{
                    {args.name or args.Name,'Item'},
                    {args.namenotes or args.Namenotes,''},
                    {args.quantity or args.Quantity,'Unknown'},
                    {args.quantitynotes or args.Quantitynotes,''},
                    {args.rarity or args.Rarity,'Unknown'},
                    {args.rarity1 or args.Rarity1,'Unknown'},
                    {args.altrarity or args.AltRarity,''},
                    {args.altraritydash or args.AltRarityDash,''},
                    {args.raritynotes or args.Raritynotes,''},
                    {args.citation,''},
                    {args.version or args.Version,''},
        }
        raritynotes = raritynotes .. citation
    local rolls = tonumber(args.rolls or args.Rolls) or false
    local rollstext = ''
    if rolls then
        rollstext = rolls .. ' × '
    end
    local approx = yesno(args.approx or args.Approx or 'no', false)
    local isCoins = name:lower() == 'coins'
    local isNothing = name:lower() == 'nothing'
    local altname = params.default_to(args.alt or args.Alt,name)
    local gemwname = params.default_to(args.gemwname,name)
    local _smwname = params.default_to(args.smwname,gemwname)
    
    
    
    
     -- Table row creation
    local ret = mw.html.create('tr')
            -- row-wide things
            :css('text-align','center')
            -- inventory image
            :tag('td')
                :addClass('inventory-image')
                :wikitext(image)
            :done()
            -- item name
            :tag('td')
                :css('text-align','left')
                :addClass('item-col')
                :wikitext(string.format('%s',name,altname,#namenotes > 3 and namenotes or ''))
            :done()
            -- quantity
            :tag('td')
                :addClass(quantityClassOverride)
                :attr('data-sort-value',_h)
                :wikitext(quantity)
            :done()
  end          
            
return p