|
|
(184 intermediate revisions by 6 users not shown) |
Line 1: |
Line 1: |
| local p = {}
| | -- This is not an actual module. Do not add code. |
| local getArgs
| |
| | |
| function p.main(frame)
| |
| if not getArgs then
| |
| getArgs = require('Module:Arguments').getArgs
| |
| end
| |
| local args = getArgs(frame, {
| |
| wrappers = 'Template:Sandbox',
| |
| trim = false
| |
| })
| |
| return p._main(args)
| |
| end
| |
| | |
| function p._main(args)
| |
| local container = mw.html.create('div')
| |
| local group
| |
| local function newGroup()
| |
| return mw.html.create('span')
| |
| :attr('class', 'itemboxstatsgroup')
| |
| end
| |
| local function newLine(extraClasses)
| |
| extraClasses = extraClasses or ''
| |
| return mw.html.create('span')
| |
| :attr('class', 'itemboxstatsgroupline ' .. extraClasses)
| |
| end
| |
| local function newColor(label, text)
| |
| if text == nil or text == '' then
| |
| return nil
| |
| end
| |
| return mw.html.create('span')
| |
| :attr('class', 'text-' .. label)
| |
| :wikitext(text)
| |
| end
| |
| args.type = string.lower(args.type)
| |
| if args.type == 'weapon' then
| |
| group = newGroup()
| |
| :node( newLine()
| |
| :wikitext(args.subtype)
| |
| )
| |
| if args.physical then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Physical Damage: ')
| |
| :node( newColor('value', args.physical) )
| |
| )
| |
| end
| |
| if args.fire or args.cold or args.lightning then
| |
| if not doConcat then
| |
| doConcat = require('Module:Concat')._main
| |
| end
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Elemental Damage: ')
| |
| :wikitext(
| |
| doConcat({
| |
| tostring( newColor('fire', args.fire) ),
| |
| tostring( newColor('cold', args.cold) ),
| |
| tostring( newColor('lightning', args.lightning) )
| |
| })
| |
| )
| |
| )
| |
| end
| |
| if args.chaos then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Chaos Damage: ')
| |
| :node( newColor('chaos', args.chaos) )
| |
| )
| |
| end
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Critical Strike Chance: ')
| |
| :node( newColor('value', args.critChance) )
| |
| )
| |
| :node( newLine()
| |
| :wikitext('Attacks per Second: ')
| |
| :node( newColor('value', args.attacksPerSecond) )
| |
| )
| |
| container:node(group)
| |
| elseif args.type == 'armour' then
| |
| if args.blockChance or args.armour or args.evasion or args.energyShield then
| |
| group = newGroup()
| |
| if args.blockChance then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Chance to Block: ')
| |
| :node( newColor('value', args.blockChance) )
| |
| )
| |
| end
| |
| if args.armour then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Armour: ')
| |
| :node( newColor('value', args.armour) )
| |
| )
| |
| end
| |
| if args.evasion then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Evasion: ')
| |
| :node( newColor('value', args.evasion) )
| |
| )
| |
| end
| |
| if args.energyShield then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Energy Shield: ')
| |
| :node( newColor('value', args.energyShield) )
| |
| )
| |
| end
| |
| container:node(group)
| |
| end
| |
| elseif args.type == 'map' then
| |
| if args.mapLevel then
| |
| group = newGroup()
| |
| :node( newLine()
| |
| :wikitext('Map Level: ')
| |
| :node( newColor('value', args.mapLevel) )
| |
| )
| |
| if args.itemQuantity then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Item Quantity: ')
| |
| :node( newColor('value', args.itemQuantity) )
| |
| )
| |
| end
| |
| container:node(group)
| |
| end
| |
| elseif args.type == 'jewel' then
| |
| if args.radius then
| |
| group = newGroup()
| |
| :node( newLine()
| |
| :wikitext('Radius: ')
| |
| :node( newColor('value', args.radius) )
| |
| )
| |
| container:node(group)
| |
| end
| |
| elseif args.type == 'currency' then
| |
| group = newGroup()
| |
| :node( newLine()
| |
| :wikitext('Stack Size: ')
| |
| :node( newColor('value', args.stackSize) )
| |
| )
| |
| container:node(group)
| |
| if args.effect then
| |
| group = newGroup('textwrap')
| |
| :node( newLine()
| |
| :node( newColor('mod', args.effect) )
| |
| )
| |
| container:node(group)
| |
| end
| |
| elseif args.type == 'flask' then
| |
| group = newGroup()
| |
| if args.life then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Recovers ')
| |
| :node( newColor('value', args.life) )
| |
| :wikitext(' Life over ')
| |
| :node( newColor('value', args.duration) )
| |
| :wikitext(' Seconds')
| |
| )
| |
| end
| |
| if args.mana then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Recovers ')
| |
| :node( newColor('value', args.mana) )
| |
| :wikitext(' Mana over ')
| |
| :node( newColor('value', args.duration) )
| |
| :wikitext(' Seconds')
| |
| )
| |
| end
| |
| if args.effect then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Lasts ')
| |
| :node( newColor('value', args.duration) )
| |
| :wikitext(' Seconds')
| |
| )
| |
| end
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Consumes ')
| |
| :node( newColor('value', args.chargeUse) )
| |
| :wikitext(' of ')
| |
| :node( newColor('value', args.chargeCap) )
| |
| :wikitext(' Charges on use')
| |
| )
| |
| if args.effect then
| |
| group = newGroup('textwrap')
| |
| :node( newLine()
| |
| :node( newColor('mod', args.effect) )
| |
| )
| |
| end
| |
| container:node(group)
| |
| elseif args.type == 'microtrans' then
| |
| group = newGroup()
| |
| if args.subtype or args.stackSize then
| |
| group
| |
| :node( newLine()
| |
| :wikitext(args.subtype)
| |
| )
| |
| if args.stackSize then
| |
| group
| |
| :node( newLine()
| |
| :wikitext('Stack Size: ')
| |
| :node( newColor('value', args.stackSize) )
| |
| )
| |
| end
| |
| end
| |
| group = newGroup('textwrap')
| |
| :node( newLine()
| |
| :node( newColor('mod', args.effect) )
| |
| )
| |
| container:node(group)
| |
| end
| |
| return tostring(container)
| |
| end
| |
| | |
| return p
| |